[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster-devel] c socket lib



Martin Johnson wrote:
Hi All,


I've come accross a couple of minor probs with the c-socket lib under windows for the current release. Some of these may have old news by now.

There are memory allocations made by the lib under the semantics that the
client shall 'free' the memory.

Unfortunatly this will not work on this platform, different heaps etc, lib
could be compiled under vc7 and client under vc6 etc...

There should be a library supported functions for memory allocation etc.

The C-library has a free() wrapper which support this:

Dll_Export void xmlBlasterFree(char *p)
{
   if (p != (char *)0) {
      free(p);
   }
}


Also for the record, 'bool' though probably supported by 'C' for a long time is another gotcha under vc6 this would compile though when if(func()) was tested it would fail.

with return bool it would go something like mov ah, 1 but when if() came it
would go like cmp eax, 1
and this was the cause of the error. So beware.

So this is a bug in VC6, do all our demo and test C clients run fine under VC6 or do we have code which is hit by the VC6 bug? Is there any easy workaround like #ifdef VC6 -> typedef bool long; ?


Also there is a memory leak in 'freeMsgUnitArrInternal(MsgUnitArr *msgUnitArr)'

free(msgUnitArr->msgUnitArr); needs to be uncommented, otherwise I see a
leak.

In my msgUtil.c the code is:

Dll_Export void freeMsgUnitArrInternal(MsgUnitArr *msgUnitArr)
{
   size_t i;
   if (msgUnitArr == (MsgUnitArr *)0) return;
   for (i=0; i<msgUnitArr->len; i++) {
      freeMsgUnitData(&msgUnitArr->msgUnitArr[i]);
   }
   free(msgUnitArr->msgUnitArr);
   msgUnitArr->len = 0;
}

This looks fine for me.

Thanks,

Marcel


Thanks Guys


Martin




--
http://www.xmlBlaster.org