/*
- * $Id: util.c,v 1.53 1998/03/03 00:30:57 rousskov Exp $
+ * $Id: util.c,v 1.54 1998/03/06 01:33:12 wessels Exp $
*
* DEBUG:
* AUTHOR: Harvest Derived
#if MEM_GEN_TRACE
-static FILE *tracefp=NULL;
+static FILE *tracefp = NULL;
void
log_trace_init(char *fn)
{
- tracefp=fopen(fn,"a+");
- if (!tracefp) {
- perror("log_trace_init");
- exit(1);
- }
+ tracefp = fopen(fn, "a+");
+ if (!tracefp) {
+ perror("log_trace_init");
+ exit(1);
+ }
}
void
log_trace_done()
{
- fclose(tracefp);
- tracefp=NULL;
+ fclose(tracefp);
+ tracefp = NULL;
}
#endif
xmalloc_show_trace(p, 1);
#endif
#if MEM_GEN_TRACE
- if (tracefp)
- fprintf(tracefp, "m:%d:%p\n",sz,p);
+ if (tracefp)
+ fprintf(tracefp, "m:%d:%p\n", sz, p);
#endif
return (p);
}
if (s != NULL)
free(s);
#if MEM_GEN_TRACE
- if (tracefp && s)
- fprintf(tracefp,"f:%p\n",s);
+ if (tracefp && s)
+ fprintf(tracefp, "f:%p\n", s);
#endif
}
#endif
free(s);
#if MEM_GEN_TRACE
- if (tracefp && s)
- fprintf(tracefp,"f:%p\n",s);
+ if (tracefp && s)
+ fprintf(tracefp, "f:%p\n", s);
#endif
}
if (sz < 1)
sz = 1;
+#if XMALLOC_DEBUG
+ if (s != NULL)
+ check_free(s);
+#endif
if ((p = realloc(s, sz)) == NULL) {
if (failure_notify) {
snprintf(msg, 128, "xrealloc: Unable to reallocate %d bytes!\n",
xmalloc_show_trace(p, 1);
#endif
#if MEM_GEN_TRACE
- if (tracefp) /* new ptr, old ptr, new size */
- fprintf(tracefp, "r:%p:%p:%d\n",p,s,sz);
+ if (tracefp) /* new ptr, old ptr, new size */
+ fprintf(tracefp, "r:%p:%p:%d\n", p, s, sz);
#endif
return (p);
}
xmalloc_show_trace(p, 1);
#endif
#if MEM_GEN_TRACE
- if (tracefp)
- fprintf(tracefp,"c:%d:%d:%p\n", n, sz,p);
+ if (tracefp)
+ fprintf(tracefp, "c:%d:%d:%p\n", n, sz, p);
#endif
return (p);
}
}
exit(1);
}
- sz = strlen(s)+1;
+ sz = strlen(s) + 1;
p = xmalloc(sz);
memcpy(p, s, sz); /* copy string, including terminating character */
return p;