Code cleanup

This commit is contained in:
Pierre Pronchery 2018-08-03 05:11:45 +02:00
parent 295b7b4afe
commit c24f2d44a1

View File

@ -140,28 +140,25 @@ void * malloc(size_t size)
- (intptr_t)sizeof(*a)
- (intptr_t)a->size)
{
b = (Alloc*)((char*)a + sizeof(*a) + a->size);
b->size = size;
b = (Alloc *)((char *)a + sizeof(*a) + a->size);
a->next->prev = b;
break;
}
if(b == NULL) /* increase process size to allocate memory */
{
if((b = sbrk(inc)) == (void *)-1)
return NULL;
b->size = size;
}
b->size = size;
b->prev = a;
b->next = a->next;
a->next = b;
return (char *)b + sizeof(*b);
return b + 1;
}
/* realloc */
void * realloc(void * ptr, size_t size)
{
Alloc * a = (Alloc*)((char*)ptr - sizeof(*a));
Alloc * a = (Alloc *)((char *)ptr - sizeof(*a));
void * p;
if(ptr == NULL)
@ -169,7 +166,7 @@ void * realloc(void * ptr, size_t size)
if(size == a->size)
return ptr;
size = (size | 0xf) + 1; /* round up to 64 bits */
if(size < a->size || (a->next != NULL && (char*)a->next - (char*)a
if(size < a->size || (a->next != NULL && (char *)a->next - (char *)a
- sizeof(*a) >= size))
{
a->size = size;