re_alloc() with heap logging; we lack access to the old alloc size */
| 167 | |
| 168 | /* re_alloc() with heap logging; we lack access to the old alloc size */ |
| 169 | long * |
| 170 | nhrealloc( |
| 171 | long *oldptr, |
| 172 | unsigned int newlth, |
| 173 | const char *file, |
| 174 | int line) |
| 175 | { |
| 176 | long *newptr = re_alloc(oldptr, newlth); |
| 177 | |
| 178 | if (!tried_heaplog) |
| 179 | heapmon_init(); |
| 180 | if (heaplog) { |
| 181 | char op = '*'; /* assume realloc() will change size of previous |
| 182 | * allocation rather than make a new one */ |
| 183 | |
| 184 | if (newptr != oldptr) { |
| 185 | /* if oldptr wasn't Null, realloc() freed it */ |
| 186 | if (oldptr) |
| 187 | (void) fprintf(heaplog, "%c%5s %s %4d %s\n", '<', "", |
| 188 | fmt_ptr((genericptr_t) oldptr), line, file); |
| 189 | op = '>'; /* new allocation rather than size-change of old one */ |
| 190 | } |
| 191 | (void) fprintf(heaplog, "%c%5u %s %4d %s\n", op, newlth, |
| 192 | fmt_ptr((genericptr_t) newptr), line, file); |
| 193 | } |
| 194 | /* potential panic in re_alloc() was deferred til here; |
| 195 | "extend to": assume it won't ever fail if asked to shrink; |
| 196 | even if that assumption happens to be wrong, we lack access to |
| 197 | the old size so can't use alternate phrasing for that case */ |
| 198 | if (newlth && !newptr) |
| 199 | panic("Cannot extend to %u bytes, line %d of %s", newlth, line, file); |
| 200 | |
| 201 | return newptr; |
| 202 | } |
| 203 | |
| 204 | void |
| 205 | nhfree(genericptr_t ptr, const char *file, int line) |
nothing calls this directly
no test coverage detected