1. message_box bug?
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?
--
Terry Constant
constant at flash.net
2. Re: message_box bug?
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