Hi,

I expect pointer not to be collected, because it "lives" in variable h. What's wrong with my code?


Best regards,
Mindaugas


PROC main()
LOCAL h
  h := myfunc( h )
  debug( "1" )
  h := myfunc( h )
  debug( "2" )
  h := myfunc( h )
  debug( "3" )
RETURN

#pragma begindump
#include "hbapi.h"

static HB_GARBAGE_FUNC( hb_fctx_destructor )
{
   (void) Cargo;
   fprintf( stdout, "destructor\n" );
}

HB_FUNC( DEBUG )
{
   fprintf( stdout, hb_parc( 1 ) );
   fprintf( stdout, "\n" );
}

HB_FUNC( MYFUNC )
{
   void*  ptr = hb_parptrGC( hb_fctx_destructor, 1 );

   if( ! ptr )
   {
      ptr = hb_gcAlloc( 4, hb_fctx_destructor );
   }
   hb_retptrGC( ptr );
}
#pragma enddump
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to