On Sun, 07 Feb 2010, April White wrote:
Hi,
> Przemek, I want to confirm something. I'm not yet using the new code
> you wrote, so bear with me here.
> If I allocate memory using hb_xgrab_fm() as you suggested before and
> then call p1 = hb_itemNew(p2) if I do not release p1 the line
> reported by FM statistics appears to be where hb_xgrab_fm() is
> called. This is what I believe I am seeing, can you confirm this?
It depends on few different things.
By default when HB_TR_LEVEL is not set to HB_TR_DEBUG
hb_traceset( HB_TR_FM, szFile, iLine, NULL );
set's the information about file and line used by the nearest call
to hb_xgrab()/hb_xalloc() and after using it it's reset so it can
be used only once.
In such case if you make:
hb_traceset( HB_TR_FM, "MYFILE", 123, NULL );
ptr = hb_xgrab( 100 ); // use MYFILE:123 set above
pItem = hb_itemNew( NULL ); // use PROCNAME():PROCLINE()
but if you make:
hb_traceset( HB_TR_FM, "MYFILE", 123, NULL );
ptr = hb_xgrab( 100 ); // use MYFILE:123
hb_traceset( HB_TR_FM, "MYFILE2", 125, NULL );
pItem = hb_itemNew( NULL ); // use MYFILE2:125
then 1-st memory block allocated by hb_xgrab()/hb_xalloc()
inside hb_itemNew() will use MYFILE2:125 and next ones (if any)
will use PROCNAME():PROCLINE().
If you set HB_TR_LEVEL to HB_TR_DEBUG then hb_traceset() will
set default file and line number for all blocks until next call
to hb_traceset() or HB_TRACE() message in C code because compiled
into final code HB_TRACE() messages (not stripped but C macrocompiler)
overwrite values set by hb_traceset().
So you described situation which happens when core code is compiled
without HB_TRACE() debug messages (default) and you set HB_TR_LEVEL
envvar to HB_TR_DEBUG.
BTW you can define macro HB_FM_MARKER and use it in your code
before functions which allocates memory:
#ifdef DEBUG
#define HB_FM_MARKER hb_traceset( HB_TR_FM, __FILE__, __LINE__, NULL );
#else
#define HB_FM_MARKER
#endif
[...]
HB_FM_MARKER
ptr = hb_xgrab( 100 );
HB_FM_MARKER
pItem = hb_itemNew( NULL );
best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour