On Wed, 06 Jan 2010, Szak�ts Viktor wrote: > So maybe the problem is that our malloc/realloc doesn't > handle zero size, while std version do. > In this case, we should probably allow zero size too.
DLMALLOC malloc()/realloc() allow to use 0 bytes. Only inside hb_xgrab()/hb_xalloc() we have code which generate internal error when argument is 0 and it really can create problems for some C++ code. The hack with 'if( !size ) size++;' inside overloaded operators is sufficient workaround for it. Please also remember that in some cases it maybe necessary to use hb_xalloc() instead of hb_xgrab() - internal error when it's not enough memory can also create problems though here there is very small chance that some code will exploits it. There is bigger chance that we find some code which calls free( NULL ); which also causes internal error in hb_xfree() so some protection like 'if( ptr ) hb_xfree( ptr );' can be useful. Anyhow I still suggest to 1-st check which code exploited the problem and if it's our own code then we should try to fix it. best regards, Przemek _______________________________________________ Harbour mailing list (attachment size limit: 40KB) [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
