Thu Aug 31 23:02:10 PDT 2000 Michael Jennings <mej@eterm.org>

Still more big changes.  Working on adding pixmap and GC tracking to
	libmej using the existing allocation tracking routines.


SVN revision: 3291
This commit is contained in:
Michael Jennings 2000-09-01 05:46:04 +00:00
parent d981295368
commit cdbb53b4bf
20 changed files with 351 additions and 283 deletions

View File

@ -3846,3 +3846,9 @@ Thu Aug 31 11:22:30 PDT 2000 Michael Jennings <mej@eterm.org>
Crap. That was not supposed to be committed.
-------------------------------------------------------------------------------
Thu Aug 31 23:02:10 PDT 2000 Michael Jennings <mej@eterm.org>
Still more big changes. Working on adding pixmap and GC tracking to
libmej using the existing allocation tracking routines.
-------------------------------------------------------------------------------

View File

@ -280,6 +280,7 @@
#undef NO_STACK_TRACE
#undef DBX
#undef GDB
#undef GDB_CMD_FILE
#undef PSTACK
/* *BSD utmp stuff */

View File

@ -117,11 +117,19 @@ AC_C_CONST
AC_C_INLINE
AC_PATH_XTRA
if test "$ac_cv_lib_socket_connect" = "yes" ; then
SUBLIBS="-lsocket"
if test ! -z "$X_CFLAGS"; then
if test -z "$CPPFLAGS"; then
CPPFLAGS="$X_CFLAGS"
else
CPPFLAGS="$CPPFLAGS $X_CFLAGS"
fi
fi
if test "$ac_cv_lib_nsl_gethostbyname" = "yes" ; then
SUBLIBS="$SUBLIBS -lnsl"
if test ! -z "$X_LIBS"; then
if test -z "$LDFLAGS"; then
LDFLAGS="$X_LIBS"
else
LDFLAGS="$LDFLAGS $X_LIBS"
fi
fi
dnl# Checks for header files.
@ -146,20 +154,12 @@ seteuid memmove putenv strsep setresuid setresgid \
memmem usleep snprintf strcasestr strcasechr \
strcasepbrk strrev)
dps_snprintf_oflow()
AC_CHECK_LIB(m, pow, LIBS="$LIBS -lm", , $SUBLIBS)
AC_CHECK_LIB(m, pow)
dnl# Check for the need for -lutil on BSD systems
AC_CHECK_FUNC(login,
AC_DEFINE(HAVE_LOGIN)
, AC_CHECK_LIB(util, login, LIBS="$LIBS -lutil" ;
AC_DEFINE(HAVE_LOGIN)
))
AC_CHECK_FUNC(logout,
AC_DEFINE(HAVE_LOGOUT)
, AC_CHECK_LIB(util, logout, LIBS="$LIBS -lutil" ;
AC_DEFINE(HAVE_LOGOUT)
))
AC_CHECK_FUNC(getpwuid, , AC_CHECK_LIB(sun, getpwuid, LIBS="$LIBS -lsun"))
dnl# Portability checks for various functions
AC_SEARCH_LIBS(login, bsd ucb util)
AC_SEARCH_LIBS(logout, util)
AC_SEARCH_LIBS(getpwuid, sun)
dnl#
dnl# Utility stuff
@ -237,6 +237,37 @@ AC_ARG_WITH(pty-group,
fi
)
dnl#
dnl# X LIBRARIES
dnl#
AC_CHECK_LIB(X11, XOpenDisplay, , [
echo "ERROR: You need libX11 to build Eterm. Verify that you have libX11.a or";
echo " libX11.so installed and that it is located in the X libraries";
echo " directory shown above. If it is in a different directory, try using";
echo " the --x-libraries parameter to configure.";
AC_MSG_ERROR([Fatal: libX11 not found.])])
AC_CHECK_LIB(Xext, XextAddDisplay, , [
echo "ERROR: You need libXext to build Eterm. Verify that you have libXext.a or";
echo " libXext.so installed and that it is located in the X libraries";
echo " directory shown above. If it is in a different directory, try using";
echo " the --x-libraries parameter to configure.";
AC_MSG_ERROR([Fatal: libXext not found.])])
AC_CHECK_LIB(Xext, XShapeQueryExtension, AC_DEFINE(HAVE_X_SHAPE_EXT))
# check if we need X_LOCALE definition
AC_CHECK_LIB(X11, _Xsetlocale, , AC_DEFINE(NO_XLOCALE))
# For multibyte selection handling
if test "$MULTICHAR_ENCODING" != "none"; then
AC_CHECK_LIB(Xmu, XmuInternAtom)
fi
# check X11R6 for XIM
if test "$XIM" = "TRUE"; then
AC_CHECK_LIB(X11, XRegisterIMInstantiateCallback, AC_DEFINE(USE_X11R6_XIM))
fi
dnl#
dnl# FEATURES
dnl#
@ -283,7 +314,7 @@ AC_ARG_WITH(imlib,
if test "$withval" != "no"; then
AC_MSG_RESULT(yes)
if test "$withval" != "yes"; then
CFLAGS="$CFLAGS -I${withval}/include"
CPPFLAGS="$CPPFLAGS -I${withval}/include"
LDFLAGS="$LDFLAGS -L${withval}/lib"
fi
USE_IMLIB=1
@ -299,10 +330,11 @@ AC_ARG_WITH(imlib,
USE_IMLIB=1
)
if test $USE_IMLIB -eq 1 ; then
AC_CHECK_LIB(dl, dlopen, GRLIBS="-ldl", , $SUBLIBS $X_LIBS $GRLIBS)
AC_CHECK_LIB(ttf, TT_Init_FreeType, GRLIBS="-lttf $GRLIBS", , $SUBLIBS $X_LIBS $GRLIBS)
AC_CHECK_LIB(dl, dlopen, GRLIBS="-ldl", , $GRLIBS)
AC_CHECK_LIB(ttf, TT_Init_FreeType, GRLIBS="-lttf $GRLIBS", , $GRLIBS)
AC_CHECK_LIB(Imlib2, imlib_create_image,
GRLIBS="-lImlib2 $GRLIBS"
AC_DEFINE(HAVE_LIBIMLIB2)
AC_DEFINE(PIXMAP_SUPPORT)
AC_DEFINE(BACKING_STORE)
,
@ -310,7 +342,7 @@ if test $USE_IMLIB -eq 1 ; then
AC_WARN(*** or could not be linked. Eterm should still work, but it will ***)
AC_WARN(*** not be very happy. Check config.log for more detailed ***)
AC_WARN(*** information on why my attempt to link with Imlib2 failed. ***)
, $SUBLIBS $X_LIBS $GRLIBS)
, $GRLIBS)
fi
@ -357,10 +389,7 @@ AC_ARG_ENABLE(utmp,
UTMP=1
)
if test $UTMP -eq 1; then
AC_CHECK_LIB(utempter, addToUtmp,
AC_DEFINE(HAVE_UTEMPTER)
LIBS="$LIBS -lutempter"
)
AC_CHECK_LIB(utempter, addToUtmp)
fi
AC_MSG_CHECKING(for backspace key configuration)
AC_ARG_WITH(backspace,
@ -602,43 +631,12 @@ dnl# ;;
dnl# esac
dnl# , AC_MSG_RESULT(none))
dnl# if test "$THREADS_LIB" = "posix"; then
dnl# AC_CHECK_LIB(pthread, pthread_create, CFLAGS="$CFLAGS -D_REENTRANT" ; THREADLIBS="-lpthread"
dnl# AC_CHECK_LIB(pthread, pthread_create, CPPFLAGS="$CPPFLAGS -D_REENTRANT" ; THREADLIBS="-lpthread"
dnl# AC_DEFINE(USE_POSIX_THREADS)
dnl# AC_DEFINE(MUTEX_SYNCH)
dnl# , , -D_REENTRANT -L/usr/lib -L/lib -L/usr/local/lib)
dnl# fi
dnl#
dnl# X LIBRARIES
dnl#
AC_CHECK_LIB(X11, XOpenDisplay, X_LIBS="$X_LIBS -lX11", [
echo "ERROR: You need libX11 to build Eterm. Verify that you have libX11.a or";
echo " libX11.so installed and that it is located in the X libraries";
echo " directory shown above. If it is in a different directory, try using";
echo " the --x-libraries parameter to configure.";
AC_MSG_ERROR([Fatal: libX11 not found.])], $X_LIBS $SUBLIBS)
AC_CHECK_LIB(Xext, XextAddDisplay, X_LIBS="-lXext $X_LIBS", [
echo "ERROR: You need libXext to build Eterm. Verify that you have libXext.a or";
echo " libXext.so installed and that it is located in the X libraries";
echo " directory shown above. If it is in a different directory, try using";
echo " the --x-libraries parameter to configure.";
AC_MSG_ERROR([Fatal: libXext not found.])], $X_LIBS $SUBLIBS)
AC_CHECK_LIB(Xext, XShapeQueryExtension, AC_DEFINE(HAVE_X_SHAPE_EXT), , $X_LIBS $SUBLIBS)
# check if we need X_LOCALE definition
AC_CHECK_LIB(X11, _Xsetlocale, , AC_DEFINE(NO_XLOCALE), $X_LIBS $SUBLIBS)
# For multibyte selection handling
if test "$MULTICHAR_ENCODING" != "none"; then
AC_CHECK_LIB(Xmu, XmuInternAtom, X_LIBS="-lXmu $X_LIBS", , $X_LIBS $SUBLIBS)
fi
# check X11R6 for XIM
if test "$XIM" = "TRUE"; then
AC_CHECK_LIB(X11, XRegisterIMInstantiateCallback, AC_DEFINE(USE_X11R6_XIM), , $X_LIBS $SUBLIBS)
fi
AC_PREFIX(Eterm)
AC_PREFIX(gcc)
if test "$prefix" = "NONE"; then
@ -709,18 +707,27 @@ if test "X$PKGDATADIR" = "X" ; then
fi
export PKGDATADIR
AC_DEFINE_UNQUOTED(PKGDATADIR, "$PKGDATADIR")
if test "$GDB" != "no"; then
GDB_CMD_FILE="$PKGDATADIR/gdb.scr"
AC_DEFINE_UNQUOTED(GDB_CMD_FILE, "$GDB_CMD_FILE")
else
GDB_CMD_FILE=""
fi
AC_SUBST(GDB_CMD_FILE)
CPPFLAGS=`eval eval eval eval eval echo "-I$includedir -I$prefix/include $CPPFLAGS"`
CPPFLAGS=`echo $CPPFLAGS | tr ' ' '\n' | uniq | tr '\n' ' '`
CFLAGS=${CFLAGS--O}
LDFLAGS=${LDFLAGS--O}
LDFLAGS=`eval eval eval eval eval echo "-L$libdir -L$prefix/lib ${LDFLAGS--O}"`
LDFLAGS=`echo $LDFLAGS | tr ' ' '\n' | uniq | tr '\n' ' '`
LIBS="$GRLIBS $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
CPPFLAGS="$CPPFLAGS"
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)
AC_SUBST(THREADLIBS)
AC_SUBST(GRLIBS)
basedir=.
@ -733,6 +740,8 @@ AC_OUTPUT(Makefile bg/Makefile doc/Makefile utils/Makefile libmej/Makefile
BINDIR=`eval eval eval eval echo ${bindir}`
export BINDIR bindir prefix exec_prefix datadir PACKAGE
# The awk-fu below replaces @VAR@ in theme config files with the corresponding
# environment variables, kinda like AC_OUTPUT above.
changequote(%&, &%)dnl
%&
for i in utils/kEsetroot themes/Eterm/theme.cfg themes/auto/theme.cfg themes/cEterm/theme.cfg \
@ -758,19 +767,17 @@ if test -z "$GRLIBS"; then
mv doc/Makefile.new doc/Makefile
fi
test $USE_IMLIB = 0 && GRLIBS="*** WARNING: Pixmap support disabled! ***"
echo "
$PACKAGE $VERSION
Configuration:
--------------
Source code location: ${srcdir}
Compiler: ${CC} ${CFLAGS}
Host System Type: ${host}
Graphics libraries: ${GRLIBS}
X libraries/paths: ${X_LIBS}
Install path: ${prefix}
Source code location: $srcdir
Host System Type: $host
Preprocessor: $CC $CPPFLAGS
Compiler: $CC $CFLAGS
Linker: $CC $LDFLAGS $LIBS
Install path: $prefix
See src/feature.h for further configuration information.

View File

@ -5,6 +5,6 @@ include_HEADERS = libmej.h
libmej_la_SOURCES = debug.c mem.c msgs.c strings.c snprintf.c libmej.h
INCLUDES = -I. -I.. -I$(includedir) -I$(prefix)/include
LIBS = -lm
libmej_la_LDFLAGS = -release $(VERSION)

View File

@ -61,6 +61,13 @@
# include <malloc.h>
#endif
#include <X11/Xatom.h>
#include <X11/X.h>
#include <X11/Intrinsic.h>
#ifdef HAVE_LIBIMLIB2
# include <Imlib2.h>
#endif
/******************************* GENERIC GOOP *********************************/
#ifndef TRUE
# define TRUE ((unsigned char)(1))
@ -193,27 +200,40 @@ typedef struct ptr_struct {
size_t size;
} ptr_t;
typedef struct memrec_struct {
unsigned char init;
unsigned long cnt;
ptr_t *ptrs;
} memrec_t;
#if (DEBUG >= DEBUG_MEM)
# define MALLOC(sz) libmej_malloc(__FILE__, __LINE__, (sz))
# define CALLOC(type,n) libmej_calloc(__FILE__, __LINE__, (n), (sizeof(type)))
# define REALLOC(mem,sz) libmej_realloc(#mem, __FILE__, __LINE__, (mem), (sz))
# define FREE(ptr) do { libmej_free(#ptr, __FILE__, __LINE__, (ptr)); (ptr) = NULL; } while (0)
# define STRDUP(s) libmej_strdup(#s, __FILE__, __LINE__, (s))
# define MALLOC(sz) libmej_malloc(__FILE__, __LINE__, (sz))
# define CALLOC(type,n) libmej_calloc(__FILE__, __LINE__, (n), (sizeof(type)))
# define REALLOC(mem,sz) libmej_realloc(#mem, __FILE__, __LINE__, (mem), (sz))
# define FREE(ptr) do { libmej_free(#ptr, __FILE__, __LINE__, (ptr)); (ptr) = NULL; } while (0)
# define STRDUP(s) libmej_strdup(#s, __FILE__, __LINE__, (s))
# define MALLOC_DUMP() libmej_dump_mem_tables()
# define X_CREATE_PIXMAP(d, win, w, h, depth) libmej_x_create_pixmap(__FILE__, __LINE__, (d), (win), (w), (h), (depth))
# define X_FREE_PIXMAP(d, p) libmej_x_free_pixmap(#p, __FILE__, __LINE__, (d), (p))
# define PIXMAP_DUMP() libmej_dump_pixmap_tables()
# define X_CREATE_GC(d, win, f, gcv) libmej_x_create_gc(__FILE__, __LINE__, (d), (win), (f), (gcv))
# define X_FREE_GC(d, gc) libmej_x_free_gc(#gc, __FILE__, __LINE__, (d), (gc))
# define GC_DUMP() libmej_dump_gc_tables()
# define MALLOC_MOD 25
# define REALLOC_MOD 25
# define CALLOC_MOD 25
# define FREE_MOD 25
#else
# define MALLOC(sz) malloc(sz)
# define CALLOC(type,n) calloc((n),(sizeof(type)))
# define REALLOC(mem,sz) ((sz) ? ((mem) ? (realloc((mem), (sz))) : (malloc(sz))) : ((mem) ? (free(mem), NULL) : (NULL)))
# define FREE(ptr) do { free(ptr); (ptr) = NULL; } while (0)
# define STRDUP(s) strdup(s)
# define MALLOC(sz) malloc(sz)
# define CALLOC(type,n) calloc((n),(sizeof(type)))
# define REALLOC(mem,sz) ((sz) ? ((mem) ? (realloc((mem), (sz))) : (malloc(sz))) : ((mem) ? (free(mem), NULL) : (NULL)))
# define FREE(ptr) do { free(ptr); (ptr) = NULL; } while (0)
# define STRDUP(s) strdup(s)
# define MALLOC_DUMP() NOP
# define X_CREATE_PIXMAP(d, win, w, h, depth) XCreatePixmap((d), (win), (w), (h), (depth))
# define X_FREE_PIXMAP(d, p) XFreePixmap((d), (p))
# define PIXMAP_DUMP() NOP
# define X_CREATE_GC(d, win, f, gcv) XCreateGC((d), (win), (f), (gcv))
# define X_FREE_GC(d, gc) XFreeGC((d), (gc))
# define GC_DUMP() NOP
#endif
/* Fast memset() macro contributed by vendu */
@ -289,16 +309,18 @@ extern unsigned int DEBUG_LEVEL;
/* mem.c */
extern void memrec_init(void);
extern void memrec_add_var(void *, size_t);
extern void memrec_rem_var(const char *, const char *, unsigned long, void *);
extern void memrec_chg_var(const char *, const char *, unsigned long, void *, void *, size_t);
extern void memrec_dump(void);
extern void *libmej_malloc(const char *, unsigned long, size_t);
extern void *libmej_realloc(const char *, const char *, unsigned long, void *, size_t);
extern void *libmej_calloc(const char *, unsigned long, size_t, size_t);
extern void libmej_free(const char *, const char *, unsigned long, void *);
extern char *libmej_strdup(const char *, const char *, unsigned long, const char *);
extern void libmej_handle_sigsegv(int);
extern void libmej_dump_mem_tables(void);
extern Pixmap libmej_x_create_pixmap(const char *, unsigned long, Display *, Drawable, unsigned int, unsigned int, unsigned int);
extern void libmej_x_free_pixmap(const char *, const char *, unsigned long, Display *, Pixmap);
extern void libmej_dump_pixmap_tables(void);
extern GC libmej_x_create_gc(const char *, unsigned long, Display *, Drawable, unsigned long, XGCValues *);
extern void libmej_x_free_gc(const char *, const char *, unsigned long, Display *, GC);
extern void libmej_dump_gc_tables(void);
/* strings.c */
extern char *left_str(const char *, unsigned long);

View File

@ -30,6 +30,11 @@ static const char cvs_ident[] = "$Id$";
#include "libmej.h"
static void memrec_add_var(memrec_t *, 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(memrec_t *);
/*
* These're added for a pretty obvious reason -- they're implemented towards
* The beginning of each one's respective function. (The ones with capitalized
@ -42,40 +47,43 @@ static int realloc_count = 0;
static int free_count = 0;
#endif
static memrec_t memrec;
static memrec_t malloc_rec, pixmap_rec, gc_rec;
void
memrec_init(void)
{
D_MEM(("Constructing memrec\n"));
memrec.ptrs = (ptr_t *) malloc(sizeof(ptr_t));
memrec.init = 1;
D_MEM(("Constructing memory allocation records\n"));
malloc_rec.ptrs = (ptr_t *) malloc(sizeof(ptr_t));
pixmap_rec.ptrs = (ptr_t *) malloc(sizeof(ptr_t));
gc_rec.ptrs = (ptr_t *) malloc(sizeof(ptr_t));
}
void
memrec_add_var(void *ptr, size_t size)
static void
memrec_add_var(memrec_t *memrec, void *ptr, size_t size)
{
register ptr_t *p;
memrec.cnt++;
if ((memrec.ptrs = (ptr_t *) realloc(memrec.ptrs, sizeof(ptr_t) * memrec.cnt)) == NULL) {
ASSERT(memrec != NULL);
memrec->cnt++;
if ((memrec->ptrs = (ptr_t *) realloc(memrec->ptrs, sizeof(ptr_t) * memrec->cnt)) == NULL) {
D_MEM(("Unable to reallocate pointer list -- %s\n", strerror(errno)));
}
D_MEM(("Adding variable of size %lu at %8p\n", size, ptr));
p = memrec.ptrs + memrec.cnt - 1;
p = memrec->ptrs + memrec->cnt - 1;
p->ptr = ptr;
p->size = size;
}
void
memrec_rem_var(const char *var, const char *filename, unsigned long line, void *ptr)
static void
memrec_rem_var(memrec_t *memrec, const char *var, const char *filename, unsigned long line, void *ptr)
{
register ptr_t *p = NULL;
register unsigned long i;
for (i = 0; i < memrec.cnt; i++) {
if (memrec.ptrs[i].ptr == ptr) {
p = memrec.ptrs + i;
ASSERT(memrec != NULL);
for (i = 0; i < memrec->cnt; i++) {
if (memrec->ptrs[i].ptr == ptr) {
p = memrec->ptrs + i;
break;
}
}
@ -83,25 +91,26 @@ memrec_rem_var(const char *var, const char *filename, unsigned long line, void *
D_MEM(("ERROR: File %s, line %d attempted to free variable %s (%8p) which was not allocated with MALLOC/REALLOC\n", filename, line, var, ptr));
return;
}
memrec.cnt--;
memrec->cnt--;
D_MEM(("Removing variable of size %lu at %8p\n", p->size, p->ptr));
memmove(p, p + 1, sizeof(ptr_t) * (memrec.cnt - i));
memrec.ptrs = (ptr_t *) realloc(memrec.ptrs, sizeof(ptr_t) * memrec.cnt);
memmove(p, p + 1, sizeof(ptr_t) * (memrec->cnt - i));
memrec->ptrs = (ptr_t *) realloc(memrec->ptrs, sizeof(ptr_t) * memrec->cnt);
}
void
memrec_chg_var(const char *var, const char *filename, unsigned long line, void *oldp, void *newp, size_t size)
static void
memrec_chg_var(memrec_t *memrec, const char *var, const char *filename, unsigned long line, void *oldp, void *newp, size_t size)
{
register ptr_t *p = NULL;
register unsigned long i;
for (i = 0; i < memrec.cnt; i++) {
if (memrec.ptrs[i].ptr == oldp) {
p = memrec.ptrs + i;
ASSERT(memrec != NULL);
for (i = 0; i < memrec->cnt; i++) {
if (memrec->ptrs[i].ptr == oldp) {
p = memrec->ptrs + i;
break;
}
}
if (i == memrec.cnt) {
if (i == memrec->cnt) {
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;
}
@ -110,27 +119,28 @@ memrec_chg_var(const char *var, const char *filename, unsigned long line, void *
p->size = size;
}
void
memrec_dump(void)
static void
memrec_dump(memrec_t *memrec)
{
register ptr_t *p;
unsigned long i, j, k, l, total = 0;
unsigned long len;
unsigned char buff[9];
fprintf(LIBMEJ_DEBUG_FD, "DUMP :: %lu pointers stored.\n", memrec.cnt);
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");
fflush(LIBMEJ_DEBUG_FD);
len = sizeof(ptr_t) * memrec.cnt;
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; p++, 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);
/* First, dump the contents of the memrec->ptrs[] array. */
for (p = memrec->ptrs, j = 0; j < len; p++, 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);
/* 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 */
/* Copy l bytes (up to 8) from memrec->ptrs[] (p) to buffer */
memcpy(buff, p + j, l);
for (k = 0; k < l; k++) {
fprintf(LIBMEJ_DEBUG_FD, "%02x ", buff[k]);
@ -146,7 +156,7 @@ memrec_dump(void)
}
/* Now print out each pointer and its contents. */
for (p = memrec.ptrs, i = 0; i < memrec.cnt; p++, i++) {
for (p = memrec->ptrs, i = 0; i < memrec->cnt; p++, i++) {
/* Add this pointer's size to our total */
total += p->size;
for (j = 0; j < p->size; j += 8) {
@ -172,6 +182,7 @@ memrec_dump(void)
fflush(LIBMEJ_DEBUG_FD);
}
/******************** MEMORY ALLOCATION INTERFACE ********************/
void *
libmej_malloc(const char *filename, unsigned long line, size_t size)
{
@ -189,7 +200,7 @@ libmej_malloc(const char *filename, unsigned long line, size_t size)
temp = (void *) malloc(size);
ASSERT_RVAL(temp != NULL, NULL);
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_add_var(temp, size);
memrec_add_var(&malloc_rec, temp, size);
}
return (temp);
}
@ -213,7 +224,7 @@ libmej_realloc(const char *var, const char *filename, unsigned long line, void *
temp = (void *) realloc(ptr, size);
ASSERT_RVAL(temp != NULL, ptr);
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_chg_var(var, filename, line, ptr, temp, size);
memrec_chg_var(&malloc_rec, var, filename, line, ptr, temp, size);
}
}
return (temp);
@ -235,7 +246,7 @@ libmej_calloc(const char *filename, unsigned long line, size_t count, size_t siz
temp = (void *) calloc(count, size);
ASSERT_RVAL(temp != NULL, NULL);
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_add_var(temp, size * count);
memrec_add_var(&malloc_rec, temp, size * count);
}
return (temp);
}
@ -253,7 +264,7 @@ libmej_free(const char *var, const char *filename, unsigned long line, void *ptr
D_MEM(("libmej_free() called for variable %s (%8p) at %s:%lu\n", var, ptr, filename, line));
if (ptr) {
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_rem_var(var, filename, line, ptr);
memrec_rem_var(&malloc_rec, var, filename, line, ptr);
}
free(ptr);
} else {
@ -276,11 +287,85 @@ libmej_strdup(const char *var, const char *filename, unsigned long line, const c
}
void
libmej_handle_sigsegv(int sig)
libmej_dump_mem_tables(void)
{
#if DEBUG >= DEBUG_MEM
fprintf(LIBMEJ_DEBUG_FD, "Fatal memory fault (%d)! Dumping memory table.\n", sig);
memrec_dump();
#endif
exit(EXIT_FAILURE);
memrec_dump(&malloc_rec);
}
/******************** PIXMAP ALLOCATION INTERFACE ********************/
Pixmap
libmej_x_create_pixmap(const char *filename, unsigned long line, Display *d, Drawable win, unsigned int w, unsigned int h, unsigned int depth)
{
Pixmap p;
D_MEM(("Creating %ux%u pixmap of depth %u for window 0x%08x at %s:%lu\n", w, h, depth, win, filename, line));
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));
}
return (p);
}
void
libmej_x_free_pixmap(const char *var, const char *filename, unsigned long line, Display *d, Pixmap p)
{
D_MEM(("libmej_x_free_pixmap() called for variable %s (0x%08x) at %s:%lu\n", var, p, filename, line));
if (p) {
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_rem_var(&pixmap_rec, var, filename, line, (void *) p);
}
XFreePixmap(d, p);
} else {
D_MEM(("ERROR: Caught attempt to free NULL pixmap\n"));
}
}
void
libmej_dump_pixmap_tables(void)
{
memrec_dump(&pixmap_rec);
}
/********************** GC ALLOCATION INTERFACE **********************/
GC
libmej_x_create_gc(const char *filename, unsigned long line, Display *d, Drawable win, unsigned long mask, XGCValues *gcv)
{
GC gc;
D_MEM(("Creating gc for window 0x%08x at %s:%lu\n", win, filename, line));
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));
}
return (gc);
}
void
libmej_x_free_gc(const char *var, const char *filename, unsigned long line, Display *d, GC gc)
{
D_MEM(("libmej_x_free_gc() called for variable %s (0x%08x) at %s:%lu\n", var, gc, filename, line));
if (gc) {
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_rem_var(&gc_rec, var, filename, line, (void *) gc);
}
XFreeGC(d, gc);
} else {
D_MEM(("ERROR: Caught attempt to free NULL GC\n"));
}
}
void
libmej_dump_gc_tables(void)
{
memrec_dump(&gc_rec);
}

View File

@ -1,5 +1,7 @@
# $Id$
INCLUDES = -I$(top_srcdir)/libmej
lib_LTLIBRARIES = libEterm.la
bin_PROGRAMS = Eterm
@ -17,6 +19,8 @@ libEterm_la_LDFLAGS = -release $(VERSION)
Eterm_SOURCES = main.c
Eterm_DEPENDENCIES = libEterm.la
Eterm_LDFLAGS = -rpath $(libdir):$(pkglibdir)
Eterm_LDADD = libEterm.la $(top_builddir)/libmej/libmej.la -L$(libdir) -L$(prefix)/lib $(X_LIBS) $(GRLIBS) $(LIBS)
Eterm_LDADD = libEterm.la $(top_builddir)/libmej/libmej.la
INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/libmej -I.. -I$(includedir) -I$(prefix)/include $(X_CFLAGS)
install-exec-hook:
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
test ! -z "$(GDB_CMD_FILE)" && $(INSTALL_DATA) gdb.scr $(DESTDIR)$(pkgdatadir)/

View File

@ -101,7 +101,7 @@ bbar_create(void)
XSelectInput(Xdisplay, bbar->win, mask);
XStoreName(Xdisplay, bbar->win, "Eterm Button Bar");
bbar->gc = X_CREATE_GC(GCForeground | GCFont, &gcvalue);
bbar->gc = LIBMEJ_X_CREATE_GC(GCForeground | GCFont, &gcvalue);
bbar_set_docked(bbar, BBAR_DOCKED_TOP);
bbar_set_visible(bbar, 1);

View File

@ -972,10 +972,10 @@ hard_exit(void) {
_exit(-1);
#elif defined(SIGKILL)
kill(cmd_pid, SIGKILL);
raise(SIGKILL);
abort();
#else
kill(cmd_pid, 9);
raise(9);
abort();
#endif
}
@ -984,8 +984,8 @@ hard_exit(void) {
void
dump_stack_trace(void)
{
char cmd[256];
struct stat st;
#ifdef NO_STACK_TRACE
return;
@ -998,7 +998,10 @@ dump_stack_trace(void)
U_STACK_TRACE();
return;
#elif defined(GDB)
snprintf(cmd, sizeof(cmd), "/bin/echo '\n\nbacktrace' | " GDB " " APL_NAME " %d", getpid());
if (((stat(GDB_CMD_FILE, &st)) != 0) || (!S_ISREG(st.st_mode))) {
return;
}
snprintf(cmd, sizeof(cmd), GDB " -x " GDB_CMD_FILE " " APL_NAME " %d", getpid());
#elif defined(PSTACK)
snprintf(cmd, sizeof(cmd), PSTACK " %d", getpid());
#elif defined(DBX)
@ -1014,7 +1017,7 @@ dump_stack_trace(void)
return;
#endif
signal(SIGALRM, (eterm_sighandler_t) hard_exit);
alarm(10);
alarm(3);
system(cmd);
}
@ -1138,7 +1141,9 @@ clean_exit(void)
privileges(REVERT);
#if DEBUG >= DEBUG_MEM
if (DEBUG_LEVEL >= DEBUG_MEM) {
memrec_dump();
MALLOC_DUMP();
PIXMAP_DUMP();
GC_DUMP();
}
#endif
PABLO_STOP_TRACING();

View File

@ -54,8 +54,8 @@ draw_shadow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w
static GC gc_top = (GC) 0, gc_bottom = (GC) 0;
if (gc_top == 0) {
gc_top = X_CREATE_GC(0, NULL);
gc_bottom = X_CREATE_GC(0, NULL);
gc_top = LIBMEJ_X_CREATE_GC(0, NULL);
gc_bottom = LIBMEJ_X_CREATE_GC(0, NULL);
}
XSetForeground(Xdisplay, gc_top, top);
@ -109,8 +109,8 @@ draw_arrow_from_colors(Drawable d, Pixel top, Pixel bottom, int x, int y, int w,
static GC gc_top = (GC) 0, gc_bottom = (GC) 0;
if (gc_top == 0) {
gc_top = X_CREATE_GC(0, NULL);
gc_bottom = X_CREATE_GC(0, NULL);
gc_top = LIBMEJ_X_CREATE_GC(0, NULL);
gc_bottom = LIBMEJ_X_CREATE_GC(0, NULL);
}
XSetForeground(Xdisplay, gc_top, top);
@ -230,8 +230,8 @@ bevel_pixmap(Pixmap p, int w, int h, Imlib_Border *bord, unsigned char up)
MOD_PIXEL_HIGH(x, y, !up);
}
}
gc = X_CREATE_GC(0, NULL);
gc = LIBMEJ_X_CREATE_GC(0, NULL);
XPutImage(Xdisplay, p, gc, ximg, 0, 0, 0, 0, w, h);
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
XDestroyImage(ximg);
}

2
src/gdb.scr Normal file
View File

@ -0,0 +1,2 @@
backtrace
quit

View File

@ -124,9 +124,9 @@ menu_init(void)
return;
}
gcvalue.foreground = PixColors[menuTopShadowColor];
topShadowGC = X_CREATE_GC(GCForeground, &gcvalue);
topShadowGC = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
gcvalue.foreground = PixColors[menuBottomShadowColor];
botShadowGC = X_CREATE_GC(GCForeground, &gcvalue);
botShadowGC = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
event_register_dispatcher(menu_dispatch_event, menu_event_init_dispatcher);
}
@ -450,7 +450,7 @@ menu_create(char *title)
menu->swin = XCreateWindow(Xdisplay, menu->win, 0, 0, 1, 1, 0, Xdepth, InputOutput, CopyFromParent,
CWOverrideRedirect | CWSaveUnder | CWBackingStore | CWBorderPixel | CWColormap, &xattr);
menu->gc = X_CREATE_GC(0, NULL);
menu->gc = LIBMEJ_X_CREATE_GC(0, NULL);
menuitem_clear_current(menu);
return menu;

View File

@ -226,26 +226,6 @@ parse_escaped_string(char *str)
return (pnew - str);
}
const char *
find_file(const char *file, const char *ext)
{
const char *f;
#if defined(PIXMAP_SUPPORT)
if ((f = search_path(rs_path, file, ext)) != NULL) {
return (f);
} else if ((f = search_path(getenv(PATH_ENV), file, ext)) != NULL) {
return (f);
} else {
return (search_path(initial_dir, file, ext));
}
#else
return ((const char *) NULL);
#endif
}
char *
safe_print_string(char *str, unsigned long len)
{

View File

@ -40,8 +40,6 @@ extern const char *my_basename(const char *str);
extern unsigned long str_leading_match(register const char *, register const char *);
extern char *str_trim(char *str);
extern int parse_escaped_string(char *str);
extern const char *search_path(const char *pathlist, const char *file, const char *ext);
extern const char *find_file(const char *file, const char *ext);
extern char *safe_print_string(char *buff, unsigned long len);
extern unsigned long add_carriage_returns(unsigned char *buff, unsigned long cnt);
extern unsigned char mkdirhier(const char *);

View File

@ -512,8 +512,8 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
return None;
}
XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy);
p = X_CREATE_PIXMAP(width, height);
gc = X_CREATE_GC(0, NULL);
p = LIBMEJ_X_CREATE_PIXMAP(width, height);
gc = LIBMEJ_X_CREATE_GC(0, NULL);
D_PIXMAP(("Created p [0x%08x] as a %hux%hu pixmap at %d, %d relative to window 0x%08x\n", p, width, height, x, y, desktop_window));
if (p != None) {
if (pw < scr->width || ph < scr->height) {
@ -535,7 +535,7 @@ create_trans_pixmap(simage_t *simg, unsigned char which, Drawable d, int x, int
bevel_pixmap(p, width, height, simg->iml->bevel->edges, simg->iml->bevel->up);
}
}
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
return p;
}
@ -609,10 +609,10 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
}
}
if (p == None) {
p = X_CREATE_PIXMAP(width, height);
p = LIBMEJ_X_CREATE_PIXMAP(width, height);
D_PIXMAP(("Created p == 0x%08x\n", p));
}
gc = X_CREATE_GC(0, NULL);
gc = LIBMEJ_X_CREATE_GC(0, NULL);
XTranslateCoordinates(Xdisplay, d, desktop_window, x, y, &x, &y, &dummy);
D_PIXMAP(("Translated coords are %d, %d\n", x, y));
if ((images[image_bg].current->pmap->w > 0) || (images[image_bg].current->pmap->op & OP_SCALE)) {
@ -623,7 +623,7 @@ create_viewport_pixmap(simage_t *simg, Drawable d, int x, int y, unsigned short
XSetFillStyle(Xdisplay, gc, FillTiled);
XFillRectangle(Xdisplay, p, gc, 0, 0, width, height);
}
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
return p;
}
@ -668,13 +668,13 @@ paste_simage(simage_t *simg, unsigned char which, Drawable d, unsigned short x,
FREE(reply);
enl_ipc_sync();
if (pmap) {
gc = X_CREATE_GC(0, NULL);
gc = LIBMEJ_X_CREATE_GC(0, NULL);
XSetClipMask(Xdisplay, gc, mask);
XSetClipOrigin(Xdisplay, gc, x, y);
XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, x, y);
snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap);
enl_ipc_send(buff);
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
return;
} else {
print_error("Enlightenment returned a null pixmap, which I can't use. Disallowing \"auto\" mode for this image.\n");
@ -687,23 +687,23 @@ paste_simage(simage_t *simg, unsigned char which, Drawable d, unsigned short x,
} else if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) {
Pixmap p;
gc = X_CREATE_GC(0, NULL);
gc = LIBMEJ_X_CREATE_GC(0, NULL);
/* FIXME: The conditional on the next line works, but it's a hack. Worth fixing? :-) */
p = create_trans_pixmap(simg, which, ((which == image_st) ? scrollbar.sa_win : d), x, y, w, h);
XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y);
X_FREE_PIXMAP(p);
X_FREE_GC(gc);
LIBMEJ_X_FREE_PIXMAP(p);
LIBMEJ_X_FREE_GC(gc);
} else if (image_mode_is(which, MODE_VIEWPORT) && image_mode_is(which, ALLOW_VIEWPORT)) {
Pixmap p;
gc = X_CREATE_GC(0, NULL);
gc = LIBMEJ_X_CREATE_GC(0, NULL);
p = create_viewport_pixmap(simg, d, x, y, w, h);
if (simg->iml->bevel != NULL) {
bevel_pixmap(p, w, h, simg->iml->bevel->edges, simg->iml->bevel->up);
}
XCopyArea(Xdisplay, p, d, gc, 0, 0, w, h, x, y);
X_FREE_PIXMAP(p);
X_FREE_GC(gc);
LIBMEJ_X_FREE_PIXMAP(p);
LIBMEJ_X_FREE_GC(gc);
}
}
@ -730,14 +730,14 @@ paste_simage(simage_t *simg, unsigned char which, Drawable d, unsigned short x,
reset_simage(simg, RESET_ALL_SIMG);
return;
}
gc = X_CREATE_GC(0, NULL);
gc = LIBMEJ_X_CREATE_GC(0, NULL);
if (mask) {
XSetClipMask(Xdisplay, gc, mask);
XSetClipOrigin(Xdisplay, gc, x, y);
}
XCopyArea(Xdisplay, pmap, d, gc, 0, 0, w, h, x, y);
IMLIB_FREE_PIXMAP(pmap);
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
}
}
@ -796,9 +796,9 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width,
XGCValues gcvalue;
ASSERT(buffer_pixmap == None);
buffer_pixmap = X_CREATE_PIXMAP(width, height);
buffer_pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
gcvalue.foreground = (Pixel) fill;
gc = X_CREATE_GC(GCForeground, &gcvalue);
gc = LIBMEJ_X_CREATE_GC(GCForeground, &gcvalue);
XSetGraphicsExposures(Xdisplay, gc, False);
if (mode == MODE_SOLID) {
@ -806,15 +806,15 @@ copy_buffer_pixmap(unsigned char mode, unsigned long fill, unsigned short width,
simg = images[image_bg].current;
if (simg->pmap->pixmap) {
X_FREE_PIXMAP(simg->pmap->pixmap);
LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
}
simg->pmap->pixmap = X_CREATE_PIXMAP(width, height);
simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
XCopyArea(Xdisplay, simg->pmap->pixmap, buffer_pixmap, gc, 0, 0, width, height, 0, 0);
} else {
XCopyArea(Xdisplay, (Pixmap) fill, buffer_pixmap, gc, 0, 0, width, height, 0, 0);
}
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
}
void
@ -852,11 +852,11 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
return;
gcvalue.foreground = gcvalue.background = PixColors[bgColor];
gc = X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
gc = LIBMEJ_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
pixmap = simg->pmap->pixmap; /* Save this for later */
if ((which == image_bg) && (buffer_pixmap != None)) {
X_FREE_PIXMAP(buffer_pixmap);
LIBMEJ_X_FREE_PIXMAP(buffer_pixmap);
buffer_pixmap = None;
}
@ -898,9 +898,9 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
XSetClipOrigin(Xdisplay, gc, 0, 0);
}
if (simg->pmap->pixmap) {
X_FREE_PIXMAP(simg->pmap->pixmap);
LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
}
simg->pmap->pixmap = X_CREATE_PIXMAP(width, height);
simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
XCopyArea(Xdisplay, pmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0);
XSetWindowBackgroundPixmap(Xdisplay, win, simg->pmap->pixmap);
snprintf(buff, sizeof(buff), "imageclass %s free_pixmap 0x%08x", iclass, (int) pmap);
@ -914,7 +914,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
} else {
snprintf(buff, sizeof(buff), "imageclass %s apply 0x%x %s", iclass, (int) win, state);
enl_ipc_send(buff);
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
return;
}
}
@ -924,7 +924,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
# ifdef PIXMAP_OFFSET
if (image_mode_is(which, MODE_TRANS) && image_mode_is(which, ALLOW_TRANS)) {
if (simg->pmap->pixmap != None) {
X_FREE_PIXMAP(simg->pmap->pixmap);
LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
}
simg->pmap->pixmap = create_trans_pixmap(simg, which, win, 0, 0, width, height);
if (simg->pmap->pixmap != None) {
@ -944,7 +944,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
p = create_viewport_pixmap(simg, win, 0, 0, width, height);
if (p && (p != simg->pmap->pixmap)) {
if (simg->pmap->pixmap != None) {
X_FREE_PIXMAP(simg->pmap->pixmap);
LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
}
simg->pmap->pixmap = p;
}
@ -1038,7 +1038,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
single = ((xscaled < width || yscaled < height) && !(simg->pmap->op & OP_TILE)) ? 1 : 0;
pixmap = simg->pmap->pixmap;
simg->pmap->pixmap = X_CREATE_PIXMAP(width, height);
simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
if (single) {
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
}
@ -1053,7 +1053,7 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
IMLIB_FREE_PIXMAP(pixmap);
} else if (renderop & RENDER_FORCE_PIXMAP) {
pixmap = simg->pmap->pixmap;
simg->pmap->pixmap = X_CREATE_PIXMAP(width, height);
simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
XCopyArea(Xdisplay, pixmap, simg->pmap->pixmap, gc, 0, 0, width, height, 0, 0);
IMLIB_FREE_PIXMAP(pixmap);
}
@ -1089,9 +1089,9 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
} else {
if ((renderop & RENDER_FORCE_PIXMAP) || (simg->iml->bevel != NULL)) {
if (simg->pmap->pixmap) {
X_FREE_PIXMAP(simg->pmap->pixmap);
LIBMEJ_X_FREE_PIXMAP(simg->pmap->pixmap);
}
simg->pmap->pixmap = X_CREATE_PIXMAP(width, height);
simg->pmap->pixmap = LIBMEJ_X_CREATE_PIXMAP(width, height);
XSetForeground(Xdisplay, gc, ((which == image_bg) ? (PixColors[bgColor]) : (simg->bg)));
XFillRectangle(Xdisplay, simg->pmap->pixmap, gc, 0, 0, width, height);
if (simg->iml->bevel != NULL && simg->iml->bevel->edges != NULL) {
@ -1106,13 +1106,13 @@ render_simage(simage_t * simg, Window win, unsigned short width, unsigned short
}
}
XClearWindow(Xdisplay, win);
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
return;
}
#ifdef PIXMAP_SUPPORT
const char *
search_path(const char *pathlist, const char *file, const char *ext)
search_path(const char *pathlist, const char *file)
{
static char name[PATH_MAX];
char *p;
@ -1123,12 +1123,9 @@ search_path(const char *pathlist, const char *file, const char *ext)
if (!pathlist || !file) { /* If either one is NULL, there really isn't much point in going on.... */
return ((const char *) NULL);
}
if (!ext) {
ext = "";
}
getcwd(name, PATH_MAX);
len = strlen(name);
D_OPTIONS(("search_path(\"%s\", \"%s\", \"%s\") called from \"%s\".\n", pathlist, file, ext, name));
D_OPTIONS(("search_path(\"%s\", \"%s\") called from \"%s\".\n", pathlist, file, name));
if (len < PATH_MAX - 1) {
strcat(name, "/");
strncat(name, file, PATH_MAX - len - 1);
@ -1148,18 +1145,8 @@ search_path(const char *pathlist, const char *file, const char *ext)
p = strchr(file, '\0');
len = (p - file);
/* check about adding a trailing extension */
if (ext != NULL) {
char *dot;
dot = strrchr(p, '.');
path = strrchr(p, '/');
if (dot != NULL || (path != NULL && dot <= path))
ext = NULL;
}
/* leave room for an extra '/' and trailing '\0' */
maxpath = sizeof(name) - (len + (ext ? strlen(ext) : 0) + 2);
maxpath = sizeof(name) - (len + 2);
if (maxpath <= 0)
return NULL;
@ -1173,15 +1160,6 @@ search_path(const char *pathlist, const char *file, const char *ext)
if (!S_ISDIR(fst.st_mode))
return name;
}
if (ext) {
strcat(name, ext);
D_OPTIONS(("Checking for file \"%s\"\n", name));
if (!access(name, R_OK)) {
stat(name, &fst);
if (!S_ISDIR(fst.st_mode))
return name;
}
}
for (path = pathlist; path != NULL && *path != '\0'; path = p) {
int n;
@ -1208,15 +1186,6 @@ search_path(const char *pathlist, const char *file, const char *ext)
if (!S_ISDIR(fst.st_mode))
return name;
}
if (ext) {
strcat(name, ext);
D_OPTIONS(("Checking for file \"%s\"\n", name));
if (!access(name, R_OK)) {
stat(name, &fst);
if (!S_ISDIR(fst.st_mode))
return name;
}
}
}
}
D_OPTIONS(("File \"%s\" not found in path.\n", file));
@ -1244,8 +1213,8 @@ load_image(const char *file, simage_t *simg)
if (geom != NULL) {
set_pixmap_scale(geom, simg->pmap);
}
if ((f = search_path(rs_path, file, PIXMAP_EXT)) == NULL) {
f = search_path(getenv(PATH_ENV), file, PIXMAP_EXT);
if ((f = search_path(rs_path, file)) == NULL) {
f = search_path(getenv(PATH_ENV), file);
}
if (f != NULL) {
im = imlib_load_image_immediately(f);
@ -1850,7 +1819,7 @@ get_desktop_pixmap(void)
}
if (color_pixmap != None) {
D_PIXMAP(("Removing old solid color pixmap 0x%08x.\n", color_pixmap));
X_FREE_PIXMAP(color_pixmap);
LIBMEJ_X_FREE_PIXMAP(color_pixmap);
color_pixmap = None;
}
if (prop != None) {
@ -1875,19 +1844,19 @@ get_desktop_pixmap(void)
Screen *scr = ScreenOfDisplay(Xdisplay, Xscreen);
gcvalue.foreground = gcvalue.background = PixColors[bgColor];
gc = X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
gc = LIBMEJ_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
XGetGeometry(Xdisplay, p, &w, &px, &py, &pw, &ph, &pb, &pd);
D_PIXMAP(("XGetGeometry() returned w = 0x%08x, pw == %u, ph == %u\n", w, pw, ph));
if (pw < (unsigned int) scr->width || ph < (unsigned int) scr->height) {
desktop_pixmap = X_CREATE_PIXMAP(pw, ph);
desktop_pixmap = LIBMEJ_X_CREATE_PIXMAP(pw, ph);
XCopyArea(Xdisplay, p, desktop_pixmap, gc, 0, 0, pw, ph, 0, 0);
colormod_trans(desktop_pixmap, images[image_bg].current->iml, gc, pw, ph);
} else {
desktop_pixmap = X_CREATE_PIXMAP(scr->width, scr->height);
desktop_pixmap = LIBMEJ_X_CREATE_PIXMAP(scr->width, scr->height);
XCopyArea(Xdisplay, p, desktop_pixmap, gc, 0, 0, scr->width, scr->height, 0, 0);
colormod_trans(desktop_pixmap, images[image_bg].current->iml, gc, scr->width, scr->height);
}
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
desktop_pixmap_is_mine = 1;
D_PIXMAP(("Returning 0x%08x\n", (unsigned int) desktop_pixmap));
return (desktop_pixmap);
@ -1913,12 +1882,12 @@ get_desktop_pixmap(void)
D_PIXMAP((" Found solid color 0x%08x\n", pix));
gcvalue.foreground = pix;
gcvalue.background = pix;
gc = X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
gc = LIBMEJ_X_CREATE_GC(GCForeground | GCBackground, &gcvalue);
color_pixmap = X_CREATE_PIXMAP(16, 16);
color_pixmap = LIBMEJ_X_CREATE_PIXMAP(16, 16);
XFillRectangle(Xdisplay, color_pixmap, gc, 0, 0, 16, 16);
D_PIXMAP(("Created solid color pixmap 0x%08x for desktop_pixmap.\n", color_pixmap));
X_FREE_GC(gc);
LIBMEJ_X_FREE_GC(gc);
return (desktop_pixmap = color_pixmap);
}
}
@ -1933,7 +1902,7 @@ free_desktop_pixmap(void)
{
if (desktop_pixmap_is_mine && desktop_pixmap != None) {
X_FREE_PIXMAP(desktop_pixmap);
LIBMEJ_X_FREE_PIXMAP(desktop_pixmap);
desktop_pixmap_is_mine = 0;
}
desktop_pixmap = None;
@ -1990,8 +1959,8 @@ set_icon_pixmap(char *filename, XWMHints * pwm_hints)
}
if (filename && *filename) {
if ((icon_path = search_path(rs_path, filename, NULL)) == NULL)
icon_path = search_path(getenv(PATH_ENV), filename, NULL);
if ((icon_path = search_path(rs_path, filename)) == NULL)
icon_path = search_path(getenv(PATH_ENV), filename);
if (icon_path != NULL) {
XIconSize *icon_sizes;

View File

@ -44,17 +44,17 @@ typedef void *Imlib_Color_Modifier;
# define background_is_viewport() (images[image_bg].mode & MODE_VIEWPORT)
# define background_is_auto() (images[image_bg].mode & MODE_AUTO)
# define background_is_pixmap() (background_is_image() || (images[image_bg].mode & (MODE_TRANS | MODE_VIEWPORT | MODE_AUTO)))
# define delete_simage(simg) do { \
imlib_free_pixmap_and_mask((simg)->pmap->pixmap); \
imlib_context_set_image((simg)->iml->im); \
imlib_free_image_and_decache(); \
(simg)->pmap->pixmap = None; (simg)->iml->im = NULL; \
} while (0)
# define CONVERT_SHADE(s) (0xff - (((s) * 0xff) / 100))
# define CONVERT_TINT_RED(t) (((t) & 0xff0000) >> 16)
# define CONVERT_TINT_GREEN(t) (((t) & 0x00ff00) >> 8)
# define CONVERT_TINT_BLUE(t) ((t) & 0x0000ff)
# define IMLIB_FREE_PIXMAP(p) do {D_PIXMAP(("libmej_freeing pixmap: imlib_free_pixmap_and_mask(0x%08x)\n", (p))); imlib_free_pixmap_and_mask(p);} while (0)
# define delete_simage(simg) do { \
imlib_free_pixmap_and_mask((simg)->pmap->pixmap); \
imlib_context_set_image((simg)->iml->im); \
imlib_free_image_and_decache(); \
(simg)->pmap->pixmap = None; (simg)->iml->im = NULL; \
} while (0)
# define CONVERT_SHADE(s) (0xff - (((s) * 0xff) / 100))
# define CONVERT_TINT_RED(t) (((t) & 0xff0000) >> 16)
# define CONVERT_TINT_GREEN(t) (((t) & 0x00ff00) >> 8)
# define CONVERT_TINT_BLUE(t) ((t) & 0x0000ff)
# define IMLIB_FREE_PIXMAP(p) do {D_PIXMAP(("Freeing pixmap: imlib_free_pixmap_and_mask(0x%08x)\n", (p))); imlib_free_pixmap_and_mask(p);} while (0)
#else
# define background_is_image() (0)
# define background_is_trans() (0)
@ -65,19 +65,10 @@ typedef void *Imlib_Color_Modifier;
# define delete_simage(simg) NOP
# define IMLIB_FREE_PIXMAP(p) NOP
#endif
#ifdef __GNUC__
# define X_CREATE_PIXMAP(w, h) __extension__ ({Pixmap __my_tmp_pmap = XCreatePixmap(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (w), (h), Xdepth); \
D_PIXMAP(("Created pixmap 0x%08x (width %d, height %d)\n", (__my_tmp_pmap), (w), (h))); \
(__my_tmp_pmap);})
# define X_CREATE_GC(flags, gcv) __extension__ ({GC __my_tmp_gc = XCreateGC(Xdisplay, (TermWin.parent ? TermWin.parent : Xroot), (flags), (gcv)); \