Fixed bug in mem_realloc (check alignment of size)

This commit is contained in:
kieranm 2003-03-31 09:36:18 +00:00
parent 01a53d955e
commit 8636ac26cf

View File

@ -192,6 +192,16 @@ mem_realloc(void *rmem, mem_size_t newsize)
mem_size_t size;
mem_size_t ptr, ptr2;
struct mem *mem, *mem2;
/* Expand the size of the allocated memory region so that we can
adjust for alignment. */
if((newsize % MEM_ALIGNMENT) != 0) {
newsize += MEM_ALIGNMENT - ((newsize + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT);
}
if(newsize > MEM_SIZE) {
return NULL;
}
sys_sem_wait(mem_sem);