implement realloc() for MONITOR_HEAP or vice versa

Add new routine 're_alloc()' that functions as MONITOR_HEAP-aware
libc realloc().  'nhrealloc()' is the version that passes source
file and line info if built with MONITOR_HEAP enabled.  The heaplog
data might now contain '<' (freed by realloc), '>' (replacement
allocation by realloc), and '*' (resized by realloc) entries in
addition to the previous '+' (allocated) and '-' (freed) entries.
heaputil has already been updated in the NHinternal repository.

Move FITSint_() and FITSuint_() from hacklib.c to alloc.c so that
they can be accessed by miscellaneous utility programs.

Remove three or four copies of FITSint_() that were duplicated in
utility programs like dlb and tile2bmp due to those not having
access to src/hacklib.o.  They do have access to src/alloc.o (and
util/panic.o).
This commit is contained in:
PatR
2022-05-30 23:19:35 -07:00
parent 4a8deefaa3
commit 687e7c12f7
8 changed files with 95 additions and 70 deletions

View File

@@ -241,14 +241,5 @@ main(int argc, char *argv[])
return 0;
}
/* we need a local copy of this for alloc.o and because we don't have panic() */
unsigned
FITSuint_(unsigned long long i, const char *file, int line){
unsigned ret = (unsigned)i;
if (ret != i) {
Fprintf(stderr, "Overflow at %s:%d", file, line);
exit(1);
}
return (unsigned)i;
}
/*tile2X11.c*/

View File

@@ -379,14 +379,5 @@ build_bmptile(pixel(*pixels)[TILE_X])
}
}
/* we need a local copy of this for alloc.o and because we don't have panic() */
unsigned
FITSuint_(unsigned long long i, const char *file, int line){
unsigned ret = (unsigned)i;
if (ret != i) {
Fprintf(stderr, "Overflow at %s:%d", file, line);
exit(EXIT_FAILURE);
}
return (unsigned)i;
}
/*tile2bmp.c*/