Re: message_box bug?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Terry Constant writes:
> The last for lines of the message_box function in msgbox.e are:

>        return c_func(msgbox_id, {NULL, text_ptr, title_ptr, or_style})
>        free(text_ptr)
>        free(title_ptr)
> end function

> Since the function returns the return value of c_func(), are the two
> free() statements after the return ever reached. That is, everytime
> we call message_box, aren't we losing memory?

Yes, you are right. This creates a small storage leak. Thanks!
In the next release I'll change the code to:

   ret = c_func(msgbox_id, {NULL, text_ptr, title_ptr, or_style})
   free(text_ptr)
   free(title_ptr)
   return ret

where ret will be declared as a private variable:
    atom ret
inside message_box()

Fortunately, very few programs are going to pop up
thousands of message boxes during one run.

Regards,
     Rob Craig
     Rapid Deployment Software

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu