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