From 03100bb3c71b24d0d2f99f57087b24fa2c979fce Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 25 Aug 2006 12:35:45 +0000 Subject: [PATCH] kes wx-console crashes because of differences between Bacula and wxWidgets malloc()/free(). Tweek wx-console to use bmalloc()/bfree() for Bacula calls. kes correct improper indenting in wx-console/console_conf.c kes update wx-console header copyrights kes Fix bug #658 where wx-console mangles file/directory names containing commas. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3368 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/bacula.h | 9 +++++++++ bacula/src/lib/bsys.c | 18 +++++++++++++++++- bacula/src/lib/protos.h | 3 ++- bacula/technotes-1.39 | 8 ++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/bacula/src/bacula.h b/bacula/src/bacula.h index 9d49a63aee..5619c0d7f2 100644 --- a/bacula/src/bacula.h +++ b/bacula/src/bacula.h @@ -142,9 +142,18 @@ #include "baconfig.h" #include "lib/lib.h" +/* + * For wx-console compiles, we undo some Bacula defines. + * This prevents conflicts between wx-Widgets and Bacula. + * In wx-console files that malloc or free() Bacula structures + * config/resources and interface to the Bacula libraries, + * you must use bmalloc() and bfree(). + */ #ifdef HAVE_WXCONSOLE #undef New #undef _ +#undef free +#undef malloc #endif #if defined(HAVE_WIN32) diff --git a/bacula/src/lib/bsys.c b/bacula/src/lib/bsys.c index aa2be79c06..a4dc7231aa 100644 --- a/bacula/src/lib/bsys.c +++ b/bacula/src/lib/bsys.c @@ -176,12 +176,16 @@ int cstrlen(const char *str) -#ifndef DEBUG +#ifndef bmalloc void *bmalloc(size_t size) { void *buf; +#ifdef SMARTALLOC + buf = sm_malloc(file, line, size); +#else buf = malloc(size); +#endif if (buf == NULL) { berrno be; Emsg1(M_ABORT, 0, _("Out of memory: ERR=%s\n"), be.strerror()); @@ -207,6 +211,18 @@ void *b_malloc(const char *file, int line, size_t size) } +void bfree(void *buf) +{ +#ifdef SMARTALLOC + sm_free(__FILE__, __LINE__, buf); +#else + free(buf); +#endif +} + + + + void *brealloc (void *buf, size_t size) { buf = realloc(buf, size); diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index dc2a2d9de2..d0ddd5326e 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -42,9 +42,10 @@ char *bstrncat (char *dest, POOL_MEM &src, int maxlen); bool bstrcmp (const char *s1, const char *s2); int cstrlen (const char *str); void *b_malloc (const char *file, int line, size_t size); -#ifndef DEBUG +#ifndef bmalloc void *bmalloc (size_t size); #endif +void bfree (void *buf); void *brealloc (void *buf, size_t size); void *bcalloc (size_t size1, size_t size2); int bsnprintf (char *str, int32_t size, const char *format, ...); diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index 60433e77e0..ab1c6345f7 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -1,6 +1,14 @@ Technical notes on version 1.39 General: +25Aug06 +kes wx-console crashes because of differences between Bacula and wxWidgets + malloc()/free(). Tweek wx-console to use bmalloc()/bfree() for Bacula + calls. +kes correct improper indenting in wx-console/console_conf.c +kes update wx-console header copyrights +kes Fix bug #658 where wx-console mangles file/directory names containing + commas. 24Aug06 kes Add Media.Enabled flag to client backups for dotcmds.c kes Enforce Media.Enabled=1 for a current restore to work. -- 2.39.5