Mailing List Archive

r3850 - in trunk/c_src/KinoSearch: . Util
Author: creamyg
Date: 2008-09-09 13:30:24 -0700 (Tue, 09 Sep 2008)
New Revision: 3850

Modified:
trunk/c_src/KinoSearch/Obj.bp
trunk/c_src/KinoSearch/Util/MemManager.c
trunk/c_src/KinoSearch/Util/MemManager.h
Log:
Wrap free() to help avert "free to wrong pool" errors which have been
occurring on Windows in xs/KinoSearch/Doc.c and
xs/KinoSearch/Analysis/Tokenizer.c.


Modified: trunk/c_src/KinoSearch/Obj.bp
===================================================================
--- trunk/c_src/KinoSearch/Obj.bp 2008-09-09 20:23:50 UTC (rev 3849)
+++ trunk/c_src/KinoSearch/Obj.bp 2008-09-09 20:30:24 UTC (rev 3850)
@@ -166,7 +166,7 @@
do { \
KINO_IFDEF_DEBUG( kino_Debug_num_freed++; ); \
Kino_Obj_Dec_RefCount(_self->_); \
- free(_self); \
+ kino_MemMan_wrapped_free(_self); \
} while (0)

/* Access an object's refcount.

Modified: trunk/c_src/KinoSearch/Util/MemManager.c
===================================================================
--- trunk/c_src/KinoSearch/Util/MemManager.c 2008-09-09 20:23:50 UTC (rev 3849)
+++ trunk/c_src/KinoSearch/Util/MemManager.c 2008-09-09 20:30:24 UTC (rev 3850)
@@ -36,6 +36,12 @@
return pointer;
}

+void
+kino_MemMan_wrapped_free(void *ptr)
+{
+ free(ptr);
+}
+
/* Copyright 2006-2008 Marvin Humphrey
*
* This program is free software; you can redistribute it and/or modify

Modified: trunk/c_src/KinoSearch/Util/MemManager.h
===================================================================
--- trunk/c_src/KinoSearch/Util/MemManager.h 2008-09-09 20:23:50 UTC (rev 3849)
+++ trunk/c_src/KinoSearch/Util/MemManager.h 2008-09-09 20:30:24 UTC (rev 3850)
@@ -19,6 +19,13 @@
void*
kino_MemMan_wrapped_realloc(void *ptr, size_t size);

+/** Free memory. (Wrapping is necessary in cases where memory allocated
+ * within the KinoSearch library has to freed in an external environment where
+ * "free" may have been redefined.)
+ */
+void
+kino_MemMan_wrapped_free(void *ptr);
+
#define KINO_MALLOCATE(n,t) \
(t*)kino_MemMan_wrapped_malloc((n)*sizeof(t))
#define KINO_CALLOCATE(n,t) \
@@ -30,6 +37,7 @@
#define MemMan_wrapped_malloc kino_MemMan_wrapped_malloc
#define MemMan_wrapped_calloc kino_MemMan_wrapped_calloc
#define MemMan_wrapped_realloc kino_MemMan_wrapped_realloc
+ #define MemMan_wrapped_free kino_MemMan_wrapped_free
#define MALLOCATE(n,t) KINO_MALLOCATE(n,t)
#define CALLOCATE(n,t) KINO_CALLOCATE(n,t)
#define REALLOCATE(v,n,t) KINO_REALLOCATE(v,n,t)


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits