On Mon, 30 Apr 2001, Andreas Beck wrote:
> > > However I'd like to know why you want to know it ?
> > I want to know that _before_ calling ggiExtensionDetach(), because
> > ggi{GA|Ovl|Blt}Detach() want to free private structure in the last
> > instance, which are stored in the visual.
>
> Oh - I see. The simple workaround is to simply cache the pointer to said
> structure and then free it. Like this:
>
[snip]
> Solves it ?
No. See:
> int ggiWhateverDetach(ggi_visual_t vis)
> {
> int rc;
> whateverext *we = LIBGGI_WHATEVEREXT(vis);
> void *mypriv = we->mypriv; /* pointer still valid. Cache it. */
>
> rc = ggiExtensionDetach(vis,ggiWhateverID);
> GGIDPRINT("Detached Whatever extension from %p. rc=%i\n", vis, rc);
> if (rc==0) {
free(mypriv);
free(we);
}
> return rc;
> }
I am searching for a way to do 'free(we)' without segfaulting.
Your way crashs.
ggiGADetach() does this:
----------------------------------------------------
...
/* Free the currently active request structure
* if not already.
*/
if (LIBGGI_GALLOCEXT(vis)->current_reslist != NULL) {
ggiGAEmptyList(&(LIBGGI_GALLOCEXT(vis)->current_reslist));
} /* if */
/* Free what's on the the priv sublib hook
* (should be free already!)
*/
if (LIBGGI_GALLOCEXT(vis)->priv != NULL) {
free (LIBGGI_GALLOCEXT(vis)->priv);
} /* if */
/* Free the galloc visual-extension structure itself.
*/
if (LIBGGI_GALLOCEXT(vis) != NULL) {
free (LIBGGI_GALLOCEXT(vis));
} /* if */
...
----------------------------------------------------
Your way crashs, no?
> > And when I call ggiExtensionDetach() before, then a segfault occures.
> > Maybe ggiExtensionDetach() frees the priv, but it can't free a dynamic
> > list at all...
>
> No, it frees the extension struct - nothing more.
And that's too much.
> Other stuff is up to the extension itself.
CU,
Christoph Egger
E-Mail: [EMAIL PROTECTED]