diff --git a/SWIG/Source/DOH/Doh/base.c b/SWIG/Source/DOH/Doh/base.c index 48a895ee2..2bf97c8ed 100644 --- a/SWIG/Source/DOH/Doh/base.c +++ b/SWIG/Source/DOH/Doh/base.c @@ -613,19 +613,25 @@ void DohDelitem(DOH *obj, int index) { /* Set an item in an object */ void DohInsertitem(DOH *obj, int index, DOH *value) { DOH *value_obj; + int no = 0; DohBase *b = (DohBase *) obj; DohError(DOH_CALLS,"DohInsertitem %x, %d, %x\n",obj,index, value); if (DohIsSequence(obj)) { if (!DohCheck(value)) { DohError(DOH_CONVERSION,"Unknown object %x being converted to a string in Insertitem.\n", value); value_obj = NewString(value); + no = 1; + Incref(value_obj); } else { value_obj = value; } if (b->objinfo->doh_sequence->doh_insitem) { (b->objinfo->doh_sequence->doh_insitem)(obj,index,value_obj); - return; } + if (no) { + Delete(value_obj); + } + return; } if (DohCheck(obj)) { DohError(DOH_UNSUPPORTED,"No insitem method defined for type '%s'\n", b->objinfo->objname); diff --git a/SWIG/Source/DOH/Doh/memory.c b/SWIG/Source/DOH/Doh/memory.c index c5a32cc16..9cb134472 100644 --- a/SWIG/Source/DOH/Doh/memory.c +++ b/SWIG/Source/DOH/Doh/memory.c @@ -183,6 +183,7 @@ void DohObjFree(DOH *ptr) { Fragment *f; extern int doh_debug_level; + if (!DohCheck(ptr)) { DohError(DOH_MEMORY,"DohObjFree. %x not a DOH object!\n", ptr); return; /* Oh well. Guess we're leaky */ @@ -246,7 +247,8 @@ void DohFree(void *ptr) { int size; size = *((int *) (cptr - 8)); free(cptr-8); - _DohMemoryCurrent -= (size+8); + _DohMemoryCurrent = _DohMemoryCurrent - (size+8); + /* printf("Free %x %d\n", ptr, size);*/ } /* ----------------------------------------------------------------------------- diff --git a/SWIG/Source/DOH/Include/doh.h b/SWIG/Source/DOH/Include/doh.h index 372519541..8974bf6e6 100644 --- a/SWIG/Source/DOH/Include/doh.h +++ b/SWIG/Source/DOH/Include/doh.h @@ -25,6 +25,9 @@ #ifndef _DOH_H #define _DOH_H +#include +#include + #ifdef __cplusplus extern "C" { #endif