All pastes #369599 Raw Edit

Unnamed

public c v1 · immutable
#369599 ·published 2007-02-23 22:58 UTC
rendered paste body
void * realloc(void * ptr, size_t size) {    struct Malloc * head = malloc_begin;    while (head) {        if (head->a==ptr) {            struct Malloc * newmem;            if (head->size >= size) return head->a; /* no problem */            /* otherwise allocate new and copy over */            newmem = findFirstFree(size);            if (!newmem) return NULL;            memcpy(newmem->a,head->a,size);            free(head->a);            return newmem->a;        }        head=head->next;    }    fprintf(stderr,"attempt to realloc memory unknown to allocator\n"); return NULL;}