* reallocf: same as realloc() but free memory on failure. */
| 1005 | * reallocf: same as realloc() but free memory on failure. |
| 1006 | */ |
| 1007 | void * |
| 1008 | reallocf(void *addr, size_t size, struct malloc_type *mtp, int flags) |
| 1009 | { |
| 1010 | void *mem; |
| 1011 | |
| 1012 | if ((mem = realloc(addr, size, mtp, flags)) == NULL) |
| 1013 | free(addr, mtp); |
| 1014 | return (mem); |
| 1015 | } |
| 1016 | |
| 1017 | /* |
| 1018 | * malloc_size: returns the number of bytes allocated for a request of the |