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:
@@ -15,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
static void xexit(int) NORETURN;
|
||||
extern void panic(const char *, ...) NORETURN;
|
||||
char *eos(char *); /* also used by dlb.c */
|
||||
FILE *fopen_datafile(const char *, const char *);
|
||||
unsigned FITSuint_(unsigned long long, const char *, int);
|
||||
@@ -545,25 +546,15 @@ xexit(int retcd)
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
/* In hacklib.c, but we don't have that and it calls panic() */
|
||||
/* from hacklib.c */
|
||||
unsigned
|
||||
FITSuint_(unsigned long long i, const char *file, int line){
|
||||
unsigned ret = (unsigned)i;
|
||||
if (ret != i) {
|
||||
printf("Overflow at %s:%d\n", file, line);
|
||||
xexit(EXIT_FAILURE);
|
||||
}
|
||||
return (unsigned)i;
|
||||
}
|
||||
|
||||
/* ditto */
|
||||
unsigned
|
||||
Strlen_(const char *str, const char *file, int line){
|
||||
Strlen_(const char *str, const char *file, int line)
|
||||
{
|
||||
size_t len = strnlen(str, LARGEST_INT);
|
||||
|
||||
if (len == LARGEST_INT) {
|
||||
printf("%s:%d string too long", file, line);
|
||||
xexit(EXIT_FAILURE);
|
||||
panic("%s:%d string too long", file, line);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
return (unsigned) len;
|
||||
}
|
||||
|
||||
@@ -2351,14 +2351,4 @@ struct attribs attrmax, attrmin;
|
||||
#endif
|
||||
#endif /* STRICT_REF_DEF */
|
||||
|
||||
/* In hacklib.c, but we don't have that and it calls panic() */
|
||||
unsigned
|
||||
FITSuint_(unsigned long long i, const char *file, int line){
|
||||
unsigned ret = (unsigned)i;
|
||||
if (ret != i) {
|
||||
Fprintf(stdout, "Overflow at %s:%d\n", file, line);
|
||||
makedefs_exit(EXIT_FAILURE);
|
||||
}
|
||||
return (unsigned)i;
|
||||
}
|
||||
/*makedefs.c*/
|
||||
|
||||
Reference in New Issue
Block a user