Hi Przemek,

If I have understood well I agree with best solution is automatic destructors for pHrb type pointer and them automatic call hb_hrbUnLoad() when release, in other words, do you plan to convert pHrb in collectible pointer?

pHrb := __hrbLoad( cHrb ) // pHrb it's the unique instance (reference GC) of this hrb module
pHrb := nil   // call hb_hrbUnLoad() and free memory

Another thing that I don't understand, why be forced the parameters to character as if are from the command line? IMHO: This subtracts functionality and if they proceed of the command line also would be accepted.

Thank you and sorry for my wrong English.
Best regards.
Xavi

Przemyslaw Czerpak escribió:
On Sun, 06 Jul 2008, Javier wrote:

Hi Javier,

Sorry for my wrong explanation, my problem is that I costs less program it that write this post. :'( Please, see my Test() function if there is error in the init functions of hrb, __hrbLoad() returns a wrong pointer (normally nil) disabling the discharge of the hrb and memmory leaks.

No It doesn't. The return value is still inside hb_stackReturnItem() and
it's enough to retrieve it. You can make it using difference between
procedure and function. Just simply create:

   procedure my_hrbLoad( cHrb, oErr )
      oErr := NIL
      begin sequence with {|e|break(e)}
         hb_hrbLoad( cHrb )
      recover using oErr
      endsequnce
   return

and simply use:

   pHrb := my_hrbLoad( cHrb, @oErr )
   if empty( pHrb )
      ? "Errors during .hrb file loading."
   else
      if oErr != NIL
         ? "Errors during initialization."
      else
         doSomeThing()
      endif
      begin sequence with {|e|break(e)}
         hb_hrbUnload( pHrb )
      recover using oErr
         ? "Error in EXIT procedures"
      endsequnce
   endif

pHrb will be always initialized with valid pointer if .hrb file
is properly loaded and inside oErr you will have error object if
error will appear inside hb_hrbLoad().
The other solution is adding automatic destructors to pHrb pointers
and probably it's sth what we should make because it will resolve
also few other problems.
Anyhow because it will change current behavior and .hrb code will
be automatically unloaded when all pHrb pointers will be cleared
then I would like to agree such modifications with group before
I'll make it.

The problem is that __hrbLoad() return the pointer of hrb in the stack return not in the stack parameter frame.-

As you can see above it's not a problem but it forces that user have
to create additional hack. Storing pointers in parameters is also
such hack though done in different way inside runner.c code.
IMHO the valid solution is adding automatic destructors and if group
agree then I'll make it.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to