Skip to content

Commit 16b89fa

Browse files
add memory alignment
1 parent 2e5c12d commit 16b89fa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

markdown_compiler.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,12 @@ int is_inline_tag(const char * c) {
227227
}
228228

229229
void * allocate(unsigned long memory_needed) {
230-
unsigned long memory_free = (g.memory_allocated-g.memory_idx);
230+
unsigned long memory_free = (g.memory_allocated - g.memory_idx);
231231
assert_d(memory_needed < memory_free, (int)(g.memory_allocated + memory_needed));
232232
void * block = &g.memory[g.memory_idx];
233-
g.memory_idx += memory_needed;
234-
//printf("allocated %20d needed %20d\n", memory_free, memory_needed);
233+
unsigned long align = 8 - (memory_needed % 8);
234+
g.memory_idx += memory_needed + align;
235+
//printf("allocated %20lu needed %20lu align %20lu \n", memory_free, memory_needed, align);
235236
return block;
236237
}
237238

0 commit comments

Comments
 (0)