Код: Выделить всё
lib/gc.c: In function ‘gcLocalRealloc’:
lib/gc.c:625:9: warning: pointer ‘old’ may be used after ‘realloc’ [-Wuse-after-free]
625 | gcLocalPop ( gc,old ) ;
| ^~~~~~~~~~~~~~~~~~~~~
lib/gc.c:621:11: note: call to ‘realloc’ here
621 | ptr = (void*) realloc ( ptr,SIZE ) ;
Код: Выделить всё
void* gcLocalRealloc(gc_t *gc, void* ptr, size_t SIZE) {
//assert(SIZE!=0); // realloc(array, 0) is not equivalent to free(array).
if (SIZE == 0) {
gcFree(ptr);
return ptr = NULL;
}
assert(SIZE > 0);
if (ptr == NULL) return gcLocalMalloc(gc, SIZE);
void* old = ptr;
ptr = (void*) realloc(ptr, SIZE);
if (ptr != NULL) {
gcLocalPop(gc, old);
gcLocalPush(gc, ptr, SIZE);
assert(ptr != NULL);
}
return ptr;
}
Заранее спасибо за помощь!
Подробнее здесь: https://stackoverflow.com/questions/793 ... ree-warnin
Мобильная версия