Fri Sep 1 15:25:28 PDT 2000 Michael Jennings <mej@eterm.org>

Okay, everything seems hunky-dorey now.  If you have memory debugging
	turned on, exiting Eterm will give a dump of the leftover allocated
	memory including where it came from and how much there is.  You'll
	also get a listing of all the remaining Pixmap ID's and GC ID's along
	with where they were created.

	I also added some macros to the debugging stuff in libmej.h so that
	if you pass the --without-debugging option to ./configure, it will
	optimize out all the ASSERT and REQUIRE goop.  This will make it
	harder to trap bugs before they cause problems, so don't do it if you
	want to help development, but if speed is critical to you, give it a
	shot.


SVN revision: 3294
This commit is contained in:
Michael Jennings 2000-09-01 22:14:17 +00:00
parent f1bf2bfb54
commit e1573e95c8
11 changed files with 138 additions and 84 deletions

View File

@ -3859,3 +3859,19 @@ Fri Sep 1 00:39:41 PDT 2000 Michael Jennings <mej@eterm.org>
a pixmap ID would be a good thing. Sigh. I need sleep.
-------------------------------------------------------------------------------
Fri Sep 1 15:25:28 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, everything seems hunky-dorey now. If you have memory debugging
turned on, exiting Eterm will give a dump of the leftover allocated
memory including where it came from and how much there is. You'll
also get a listing of all the remaining Pixmap ID's and GC ID's along
with where they were created.
I also added some macros to the debugging stuff in libmej.h so that
if you pass the --without-debugging option to ./configure, it will
optimize out all the ASSERT and REQUIRE goop. This will make it
harder to trap bugs before they cause problems, so don't do it if you
want to help development, but if speed is critical to you, give it a
shot.
-------------------------------------------------------------------------------

View File

@ -177,6 +177,7 @@ AC_ARG_WITH(debugging, [ --with-debugging[=num] enable debugging output, num i
AC_DEFINE_UNQUOTED(DEBUG, $withval)
else
echo "no debugging"
AC_DEFINE_UNQUOTED(DEBUG, 0)
fi, echo "4"
AC_DEFINE_UNQUOTED(DEBUG, 4)
)

View File

@ -110,49 +110,59 @@
#endif
/* A quick and dirty macro to say, "Hi! I got here without crashing!" */
#define MOO() do { __DEBUG(); fprintf(LIBMEJ_DEBUG_FD, "Moo.\n"); fflush(LIBMEJ_DEBUG_FD); } while (0)
#define MOO() do {__DEBUG(); libmej_dprintf("Moo.\n");} while (0)
/* Assertion/abort macros which are quite a bit more useful than assert() and abort(). */
#if defined(__FILE__) && defined(__LINE__)
# ifdef __GNUC__
# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
else {print_warning("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);}}} while (0)
# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
else {print_warning("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
return (val);}} while (0)
# define ASSERT_NOTREACHED() do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
else {print_warning("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
} while (0)
# define ASSERT_NOTREACHED_RVAL(val) do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
else {print_warning("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
return (val);} while (0)
# define ABORT() fatal_error("Aborting in %s() at %s:%d.", __FUNCTION__, __FILE__, __LINE__)
#if DEBUG >= 1
# if defined(__FILE__) && defined(__LINE__)
# ifdef __GNUC__
# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
else {print_warning("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);}}} while (0)
# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
else {print_warning("ASSERT failed in %s() at %s:%d: %s", __FUNCTION__, __FILE__, __LINE__, #x);} \
return (val);}} while (0)
# define ASSERT_NOTREACHED() do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
else {print_warning("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
} while (0)
# define ASSERT_NOTREACHED_RVAL(val) do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
else {print_warning("ASSERT failed in %s() at %s:%d: This code should not be reached.", __FUNCTION__, __FILE__, __LINE__);} \
return (val);} while (0)
# define ABORT() fatal_error("Aborting in %s() at %s:%d.", __FUNCTION__, __FILE__, __LINE__)
# else
# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
else {print_warning("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);}}} while (0)
# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
else {print_warning("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
return (val);}} while (0)
# define ASSERT_NOTREACHED() do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
else {print_warning("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
} while (0)
# define ASSERT_NOTREACHED_RVAL(val) do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
else {print_warning("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
return (val);} while (0)
# define ABORT() fatal_error("Aborting at %s:%d.", __FILE__, __LINE__)
# endif
# else
# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
else {print_warning("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);}}} while (0)
# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
else {print_warning("ASSERT failed at %s:%d: %s", __FILE__, __LINE__, #x);} \
return (val);}} while (0)
# define ASSERT_NOTREACHED() do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
else {print_warning("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
} while (0)
# define ASSERT_NOTREACHED_RVAL(val) do {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
else {print_warning("ASSERT failed at %s:%d: This code should not be reached.", __FILE__, __LINE__);} \
return (val);} while (0)
# define ABORT() fatal_error("Aborting at %s:%d.", __FILE__, __LINE__)
# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed: %s", #x);} \
else {print_warning("ASSERT failed: %s", #x);}}} while (0)
# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed: %s", #x);} \
else {print_warning("ASSERT failed: %s", #x);} return (val);}} while (0)
# define ASSERT_NOTREACHED() return
# define ASSERT_NOTREACHED_RVAL(x) return (x)
# define ABORT() fatal_error("Aborting.\n")
# endif
# define REQUIRE(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {__DEBUG(); libmej_dprintf("REQUIRE failed: %s\n", #x);} return;}} while (0)
# define REQUIRE_RVAL(x, v) do {if (!(x)) {if (DEBUG_LEVEL>=1) {__DEBUG(); libmej_dprintf("REQUIRE failed: %s\n", #x);} return (v);}} while (0)
#else
# define ASSERT(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed: %s", #x);} \
else {print_warning("ASSERT failed: %s", #x);}}} while (0)
# define ASSERT_RVAL(x, val) do {if (!(x)) {if (DEBUG_LEVEL>=1) {fatal_error("ASSERT failed: %s", #x);} \
else {print_warning("ASSERT failed: %s", #x);} return (val);}} while (0)
# define ASSERT_NOTREACHED() return
# define ASSERT_NOTREACHED_RVAL(x) return (x)
# define ABORT() fatal_error("Aborting.\n")
# define ASSERT(x) NOP
# define ASSERT_RVAL(x, val) NOP
# define ASSERT_NOTREACHED() return
# define ASSERT_NOTREACHED_RVAL(val) return (val)
# define ABORT() fatal_error("Aborting.\n")
# define REQUIRE(x) do {if (!(x)) return;} while 0
# define REQUIRE_RVAL(x, v) do {if (!(x)) return (v);} while 0
#endif
#define REQUIRE(x) do {if (!(x)) {if (DEBUG_LEVEL>=1) {__DEBUG(); libmej_dprintf("REQUIRE failed: %s\n", #x);} return;}} while (0)
#define REQUIRE_RVAL(x, v) do {if (!(x)) {if (DEBUG_LEVEL>=1) {__DEBUG(); libmej_dprintf("REQUIRE failed: %s\n", #x);} return (v);}} while (0)
#define NONULL(x) ((x) ? (x) : ("<null>"))
/* Macros for printing debugging messages */
@ -195,9 +205,13 @@
/********************************* MEM GOOP ***********************************/
#define LIBMEJ_FNAME_LEN 20
typedef struct ptr_struct {
void *ptr;
size_t size;
char file[LIBMEJ_FNAME_LEN + 1];
unsigned long line;
} ptr_t;
typedef struct memrec_struct {
unsigned long cnt;

View File

@ -30,7 +30,7 @@ static const char cvs_ident[] = "$Id$";
#include "libmej.h"
static void memrec_add_var(memrec_t *, void *, size_t);
static void memrec_add_var(memrec_t *, const char *, unsigned long, void *, size_t);
static void memrec_rem_var(memrec_t *, const char *, const char *, unsigned long, void *);
static void memrec_chg_var(memrec_t *, const char *, const char *, unsigned long, void *, void *, size_t);
static void memrec_dump_pointers(memrec_t *);
@ -60,7 +60,7 @@ memrec_init(void)
}
static void
memrec_add_var(memrec_t *memrec, void *ptr, size_t size)
memrec_add_var(memrec_t *memrec, const char *filename, unsigned long line, void *ptr, size_t size)
{
register ptr_t *p;
@ -70,9 +70,13 @@ memrec_add_var(memrec_t *memrec, void *ptr, size_t size)
D_MEM(("Unable to reallocate pointer list -- %s\n", strerror(errno)));
}
p = memrec->ptrs + memrec->cnt - 1;
D_MEM(("Adding variable of size %lu at %8p. Storing as pointer #%lu at %8p (from %8p).\n", size, ptr, memrec->cnt, p, memrec->ptrs));
D_MEM(("Adding variable (%8p, %lu bytes) from %s:%lu.\n", ptr, size, filename, line));
D_MEM(("Storing as pointer #%lu at %8p (from %8p).\n", memrec->cnt, p, memrec->ptrs));
p->ptr = ptr;
p->size = size;
strncpy(p->file, filename, LIBMEJ_FNAME_LEN);
p->file[LIBMEJ_FNAME_LEN] = 0;
p->line = line;
}
static void
@ -93,7 +97,8 @@ memrec_rem_var(memrec_t *memrec, const char *var, const char *filename, unsigned
return;
}
memrec->cnt--;
D_MEM(("Removing variable %s (%8p) of size %lu which is stored at %8p (from %8p)\n", var, ptr, p->size, p, memrec->ptrs));
D_MEM(("Removing variable %s (%8p) of size %lu\n", var, ptr, p->size));
D_MEM(("Pointer #%lu is stored at %8p (from %8p)\n", i + 1, p, memrec->ptrs));
memmove(p, p + 1, sizeof(ptr_t) * (memrec->cnt - i));
memrec->ptrs = (ptr_t *) realloc(memrec->ptrs, sizeof(ptr_t) * memrec->cnt);
}
@ -115,9 +120,12 @@ memrec_chg_var(memrec_t *memrec, const char *var, const char *filename, unsigned
D_MEM(("ERROR: File %s, line %d attempted to realloc variable %s (%8p) which was not allocated with MALLOC/REALLOC\n", filename, line, var, oldp));
return;
}
D_MEM(("Changing variable %s (%8p, %lu -> %8p, %lu) stored at %8p (from %8p)\n", var, oldp, p->size, newp, size, p, memrec->ptrs));
D_MEM(("Changing variable %s (%8p, %lu -> %8p, %lu)\n", var, oldp, p->size, newp, size));
D_MEM(("Pointer #%lu stored at %8p (from %8p)\n", i + 1, p, memrec->ptrs));
p->ptr = newp;
p->size = size;
strncpy(p->file, filename, LIBMEJ_FNAME_LEN);
p->line = line;
}
static void
@ -129,21 +137,22 @@ memrec_dump_pointers(memrec_t *memrec)
unsigned char buff[9];
ASSERT(memrec != NULL);
fprintf(LIBMEJ_DEBUG_FD, "DUMP :: %lu pointers stored.\n", memrec->cnt);
fprintf(LIBMEJ_DEBUG_FD, "DUMP :: Pointer | Address | Size | Offset | 00 01 02 03 04 05 06 07 | ASCII \n");
fprintf(LIBMEJ_DEBUG_FD, "DUMP :: ---------+----------+--------+---------+-------------------------+---------\n");
fprintf(LIBMEJ_DEBUG_FD, "PTR: %lu pointers stored.\n", memrec->cnt);
fprintf(LIBMEJ_DEBUG_FD, "PTR: Pointer | Filename | Line | Address | Size | Offset | 00 01 02 03 04 05 06 07 | ASCII \n");
fprintf(LIBMEJ_DEBUG_FD, "PTR: ---------+----------------------+--------+----------+--------+---------+-------------------------+---------\n");
fflush(LIBMEJ_DEBUG_FD);
len = sizeof(ptr_t) * memrec->cnt;
memset(buff, 0, sizeof(buff));
/* First, dump the contents of the memrec->ptrs[] array. */
for (p = memrec->ptrs, j = 0; j < len; j += 8) {
fprintf(LIBMEJ_DEBUG_FD, "DUMP :: %07lu | %8p | %06lu | %07x | ", (unsigned long) 0, memrec->ptrs, (unsigned long) (sizeof(ptr_t) * memrec->cnt), (unsigned int) j);
fprintf(LIBMEJ_DEBUG_FD, "PTR: %07lu | %20s | %6lu | %8p | %06lu | %07x | ", (unsigned long) 0, "", (unsigned long) 0, memrec->ptrs,
(unsigned long) (sizeof(ptr_t) * memrec->cnt), (unsigned int) j);
/* l is the number of characters we're going to output */
l = ((len - j < 8) ? (len - j) : (8));
/* Copy l bytes (up to 8) from memrec->ptrs[] (p) to buffer */
memset(buff, 0, sizeof(buff));
memcpy(buff, ((char *) p) + j, l);
buff[l] = 0;
for (k = 0; k < l; k++) {
fprintf(LIBMEJ_DEBUG_FD, "%02x ", buff[k]);
}
@ -162,11 +171,10 @@ memrec_dump_pointers(memrec_t *memrec)
/* Add this pointer's size to our total */
total += p->size;
for (j = 0; j < p->size; j += 8) {
fprintf(LIBMEJ_DEBUG_FD, "DUMP :: %07lu | %8p | %06lu | %07x | ", i + 1, p->ptr, (unsigned long) p->size, (unsigned int) j);
fprintf(LIBMEJ_DEBUG_FD, "PTR: %07lu | %20s | %6lu | %8p | %06lu | %07x | ", i + 1, NONULL(p->file), p->line, p->ptr, (unsigned long) p->size, (unsigned int) j);
/* l is the number of characters we're going to output */
l = ((p->size - j < 8) ? (p->size - j) : (8));
/* Copy l bytes (up to 8) from p->ptr to buffer */
memset(buff, 0, sizeof(buff));
memcpy(buff, ((char *) p->ptr) + j, l);
buff[l] = 0;
for (k = 0; k < l; k++) {
@ -182,7 +190,7 @@ memrec_dump_pointers(memrec_t *memrec)
fflush(LIBMEJ_DEBUG_FD);
}
}
fprintf(LIBMEJ_DEBUG_FD, "DUMP :: Total allocated memory: %10lu bytes\n\n", total);
fprintf(LIBMEJ_DEBUG_FD, "PTR: Total allocated memory: %10lu bytes\n", total);
fflush(LIBMEJ_DEBUG_FD);
}
@ -190,12 +198,24 @@ static void
memrec_dump_resources(memrec_t *memrec)
{
register ptr_t *p;
unsigned long i, j, k, l, total = 0;
unsigned long i, total;
unsigned long len;
unsigned char buff[9];
ASSERT(memrec != NULL);
len = memrec->cnt;
fprintf(LIBMEJ_DEBUG_FD, "RES: %lu resources stored.\n", memrec->cnt);
fprintf(LIBMEJ_DEBUG_FD, "RES: Index | Resource ID | Filename | Line | Size \n");
fprintf(LIBMEJ_DEBUG_FD, "RES: -------+-------------+----------------------+--------+--------\n");
fflush(LIBMEJ_DEBUG_FD);
for (p = memrec->ptrs, i = 0, total = 0; i < len; i++, p++) {
total += p->size;
fprintf(LIBMEJ_DEBUG_FD, "RES: %5lu | 0x%08x | %20s | %6lu | %6lu\n", i, (unsigned) p->ptr, NONULL(p->file), p->line, (unsigned long) p->size);
/* Flush after every line in case we crash */
fflush(LIBMEJ_DEBUG_FD);
}
fprintf(LIBMEJ_DEBUG_FD, "RES: Total size: %lu bytes\n", total);
fflush(LIBMEJ_DEBUG_FD);
}
/******************** MEMORY ALLOCATION INTERFACE ********************/
@ -211,12 +231,12 @@ libmej_malloc(const char *filename, unsigned long line, size_t size)
}
#endif
D_MEM(("libmej_malloc(%lu) called at %s:%lu\n", size, filename, line));
D_MEM(("%lu bytes requested at %s:%lu\n", size, filename, line));
temp = (void *) malloc(size);
ASSERT_RVAL(temp != NULL, NULL);
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_add_var(&malloc_rec, temp, size);
memrec_add_var(&malloc_rec, filename, line, temp, size);
}
return (temp);
}
@ -233,7 +253,7 @@ libmej_realloc(const char *var, const char *filename, unsigned long line, void *
}
#endif
D_MEM(("libmej_realloc(%lu) called for variable %s (%8p) at %s:%lu\n", size, var, ptr, filename, line));
D_MEM(("Variable %s (%8p -> %lu) at %s:%lu\n", var, ptr, (unsigned long) size, filename, line));
if (ptr == NULL) {
temp = (void *) libmej_malloc(__FILE__, __LINE__, size);
} else {
@ -258,11 +278,11 @@ libmej_calloc(const char *filename, unsigned long line, size_t count, size_t siz
}
#endif
D_MEM(("libmej_calloc(%lu, %lu) called at %s:%lu\n", count, size, filename, line));
D_MEM(("%lu units of %lu bytes each requested at %s:%lu\n", count, size, filename, line));
temp = (void *) calloc(count, size);
ASSERT_RVAL(temp != NULL, NULL);
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_add_var(&malloc_rec, temp, size * count);
memrec_add_var(&malloc_rec, filename, line, temp, size * count);
}
return (temp);
}
@ -277,7 +297,7 @@ libmej_free(const char *var, const char *filename, unsigned long line, void *ptr
}
#endif
D_MEM(("libmej_free() called for variable %s (%8p) at %s:%lu\n", var, ptr, filename, line));
D_MEM(("Variable %s (%8p) at %s:%lu\n", var, ptr, filename, line));
if (ptr) {
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_rem_var(&malloc_rec, var, filename, line, ptr);
@ -294,7 +314,7 @@ libmej_strdup(const char *var, const char *filename, unsigned long line, const c
register char *newstr;
register size_t len;
D_MEM(("libmej_strdup() called for variable %s (%8p) at %s:%lu\n", var, str, filename, line));
D_MEM(("Variable %s (%8p) at %s:%lu\n", var, str, filename, line));
len = strlen(str) + 1; /* Copy NUL byte also */
newstr = (char *) libmej_malloc(filename, line, len);
@ -305,6 +325,7 @@ libmej_strdup(const char *var, const char *filename, unsigned long line, const c
void
libmej_dump_mem_tables(void)
{
fprintf(LIBMEJ_DEBUG_FD, "Dumping memory allocation table:\n");
memrec_dump_pointers(&malloc_rec);
}
@ -322,7 +343,7 @@ libmej_x_create_pixmap(const char *filename, unsigned long line, Display *d, Dra
p = XCreatePixmap(d, win, w, h, depth);
ASSERT_RVAL(p != None, None);
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_add_var(&pixmap_rec, (void *) p, w * h * (depth / 8));
memrec_add_var(&pixmap_rec, filename, line, (void *) p, w * h * (depth / 8));
}
return (p);
}
@ -344,6 +365,7 @@ libmej_x_free_pixmap(const char *var, const char *filename, unsigned long line,
void
libmej_dump_pixmap_tables(void)
{
fprintf(LIBMEJ_DEBUG_FD, "Dumping X11 Pixmap allocation table:\n");
memrec_dump_resources(&pixmap_rec);
}
@ -361,7 +383,7 @@ libmej_x_create_gc(const char *filename, unsigned long line, Display *d, Drawabl
gc = XCreateGC(d, win, mask, gcv);
ASSERT_RVAL(gc != None, None);
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_add_var(&gc_rec, (void *) gc, sizeof(XGCValues));
memrec_add_var(&gc_rec, filename, line, (void *) gc, sizeof(XGCValues));
}
return (gc);
}
@ -383,5 +405,6 @@ libmej_x_free_gc(const char *var, const char *filename, unsigned long line, Disp
void
libmej_dump_gc_tables(void)
{
fprintf(LIBMEJ_DEBUG_FD, "Dumping X11 GC allocation table:\n");
memrec_dump_resources(&gc_rec);
}

View File

@ -36,9 +36,9 @@ libmej_dprintf(const char *format, ...)
int n;
va_start(args, format);
n = vfprintf(stderr, format, args);
n = vfprintf(LIBMEJ_DEBUG_FD, format, args);
va_end(args);
fflush(stderr);
fflush(LIBMEJ_DEBUG_FD);
return (n);
}

View File

@ -2736,7 +2736,7 @@ v_writeBig(int f, char *d, int len)
}
if (v_bufend < v_bufptr + len) {
/* still won't fit: get more space */
/* Don't use Xtlibmej_realloc because an error is not fatal. */
/* Don't use XtRealloc because an error is not fatal. */
int size = v_bufptr - v_buffer; /* save across realloc */
v_buffer = REALLOC(v_buffer, size + len);

View File

@ -62,10 +62,11 @@ static unsigned char get_corner(const char *corner);
void
eterm_font_add(char ***plist, const char *fontname, unsigned char idx) {
char **flist = *plist;
char **flist;
D_FONT(("eterm_font_add(\"%s\", %u): plist == %8p\n", NONULL(fontname), (unsigned int) idx, plist));
D_FONT(("Adding \"%s\" at %u (%8p)\n", NONULL(fontname), (unsigned int) idx, plist));
ASSERT(plist != NULL);
flist = *plist;
if (idx >= font_cnt) {
unsigned char new_size = sizeof(char *) * (idx + 1);
@ -74,17 +75,17 @@ eterm_font_add(char ***plist, const char *fontname, unsigned char idx) {
etfonts = (char **) REALLOC(etfonts, new_size);
#ifdef MULTI_CHARSET
etmfonts = (char **) REALLOC(etmfonts, new_size);
D_FONT((" -> libmej_reallocating fonts lists to a size of %u bytes gives %8p/%8p\n", new_size, etfonts, etmfonts));
D_FONT((" -> Reallocated font lists: %u bytes at %8p/%8p\n", new_size, etfonts, etmfonts));
#else
D_FONT((" -> libmej_reallocating fonts list to a size of %u bytes gives %8p\n", new_size, etfonts));
D_FONT((" -> Reallocated font list: %u bytes at %8p\n", new_size, etfonts));
#endif
} else {
etfonts = (char **) MALLOC(new_size);
#ifdef MULTI_CHARSET
etmfonts = (char **) MALLOC(new_size);
D_FONT((" -> Allocating fonts lists to a size of %u bytes gives %8p/%8p\n", new_size, etfonts, etmfonts));
D_FONT((" -> Allocated font lists: %u bytes at %8p/%8p\n", new_size, etfonts, etmfonts));
#else
D_FONT((" -> Allocating fonts list to a size of %u bytes gives %8p\n", new_size, etfonts));
D_FONT((" -> Allocating font list: %u bytes at %8p\n", new_size, etfonts));
#endif
}
MEMSET(etfonts + font_cnt, 0, sizeof(char *) * (idx - font_cnt + 1));

View File

@ -1228,8 +1228,7 @@ conf_register_context(char *name, ctx_handler_t handler) {
}
context[ctx_idx].name = STRDUP(name);
context[ctx_idx].handler = handler;
D_OPTIONS(("conf_register_context(): Added context \"%s\" with ID %d and handler 0x%08x\n",
context[ctx_idx].name, ctx_idx, context[ctx_idx].handler));
D_OPTIONS(("Added context \"%s\" with ID %d and handler 0x%08x\n", context[ctx_idx].name, ctx_idx, context[ctx_idx].handler));
return (ctx_idx);
}

View File

@ -66,9 +66,9 @@ typedef void *Imlib_Color_Modifier;
# define IMLIB_FREE_PIXMAP(p) NOP
#endif
#define LIBMEJ_X_CREATE_PIXMAP(w, h) X_CREATE_PIXMAP(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (w), (h), Xdepth)
#define LIBMEJ_X_FREE_PIXMAP(p) X_FREE_PIXMAP(Xdisplay, (p))
#define LIBMEJ_X_FREE_PIXMAP(p) X_FREE_PIXMAP(Xdisplay, p)
#define LIBMEJ_X_CREATE_GC(f, gcv) X_CREATE_GC(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (f), (gcv))
#define LIBMEJ_X_FREE_GC(gc) X_FREE_GC(Xdisplay, (gc))
#define LIBMEJ_X_FREE_GC(gc) X_FREE_GC(Xdisplay, gc)
#define GEOM_LEN 19

View File

@ -177,7 +177,7 @@ get_modifiers(void)
}
}
/* To handle buffer overflows properly, we must malloc a buffer. libmej_free it when done. */
/* To handle buffer overflows properly, we must malloc a buffer. Free it when done. */
#ifdef USE_XIM
# define LK_RET() do {if (kbuf_alloced) FREE(kbuf); return;} while (0)
#else

View File

@ -68,7 +68,7 @@ static const char cvs_ident[] = "$Id$";
# ifdef HAVE_LASTLOG_H
# include <lastlog.h>
# endif
# if defined(__libmej_freeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# include <ttyent.h>
# endif
@ -83,7 +83,7 @@ static const char cvs_ident[] = "$Id$";
/* don't go off end of ut_id & remember if an entry has been made */
# ifndef HAVE_UTEMPTER
# if defined(USE_SYSV_UTMP) || defined(__libmej_freeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
# if defined(USE_SYSV_UTMP) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__)
static char ut_id[5]; /* remember if entry to utmp made */
# else
static int utmp_pos; /* BSD position of utmp-stamp */
@ -274,7 +274,7 @@ remove_utmp_entry(void)
# else /* USE_SYSV_UTMP */
/* BSD utmp support */
# if defined(__libmej_freeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
/* used to hold the line we are using */
static char ut_line[32];
@ -322,7 +322,7 @@ b_login(struct utmp *ut)
}
}
# else /* __libmej_freeBSD__ || NetBSD || BSDI */
# else /* __FreeBSD__ || NetBSD || BSDI */
static int utmp_pos = 0; /* position of utmp-stamp */
/*----------------------------------------------------------------------*
@ -380,7 +380,7 @@ write_utmp(struct utmp *putmp)
return rval;
}
# endif /* __libmej_freeBSD__ || NetBSD || BSDI */
# endif /* __FreeBSD__ || NetBSD || BSDI */
void
add_utmp_entry(const char *pty, const char *hostname, int fd)
@ -400,7 +400,7 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
return;
}
# if defined(__libmej_freeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
strncpy(ut_line, pty, 31);
strncpy(utmp.ut_line, pty, UT_LINESIZE);
@ -409,7 +409,7 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
utmp.ut_time = time(NULL);
b_login(&utmp);
# else /* __libmej_freeBSD__ || NetBSD || BSDI */
# else /* __FreeBSD__ || NetBSD || BSDI */
strncpy(utmp.ut_line, ut_id, sizeof(utmp.ut_line));
strncpy(utmp.ut_name, pwent->pw_name, sizeof(utmp.ut_name));
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
@ -428,10 +428,10 @@ add_utmp_entry(const char *pty, const char *hostname, int fd)
void
remove_utmp_entry(void)
{
# if defined(__libmej_freeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__bsdi__)
logout(ut_line);
logwtmp(ut_line, "", "");
# else /* __libmej_freeBSD__ */
# else /* __FreeBSD__ */
FILE *fd;
privileges(INVOKE);
@ -445,7 +445,7 @@ remove_utmp_entry(void)
fclose(fd);
}
privileges(REVERT);
# endif /* __libmej_freeBSD__ || NetBSD || BSDI */
# endif /* __FreeBSD__ || NetBSD || BSDI */
}
# endif /* USE_SYSV_UTMP */