>From "System V Application Binary Interface" Integral and pointer return values appear in %eax. A function that returns a struct or union value places the address of the result in %eax. Otherwise this is a scratch register. Pointers to anything, even other pointers, are returned in eax. Of course, the object it points to must not be in the stack frame, which as you point out, is deleted when the function returns. (I'm using "object" in the general sense here, not as in "object-oriented programming.") I try to design my code such that the function that creates and object is the only one that can delete it. That is, I try not to write a function that allocates memory, then returns a pointer to it. I allocate the memory in the calling function, then pass a pointer to this memory area to the function that will do something to the memory. Perhaps if you can provide more details about what you need to do we can give more advice. Bob On Sat, 2007-10-06 at 04:28 -0700, Lope De Vega wrote: > Hi list! > > I'm wondering how do you guys use to do when you need > to return a pointer to a pointer from within a > function? > > if I use local storage it get's swept out during > function's return. > > I've though on pushing $0 onto the stack after or > before such a function's arguments, so I could either > store on it during this function's execution and then > moving it to eax at it's end so it will be visible > > Any hints or comments? > > Thanks. > > > > > > ____________________________________________________________________________________ > Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out. > http://answers.yahoo.com/dir/?link=list&sid=396545469 > > - > To unsubscribe from this list: send the line "unsubscribe linux-assembly" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html > - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
- Follow-Ups:
- Re: how to return a pointer to pointer
- From: Lope De Vega
- Re: how to return a pointer to pointer
- References:
- how to return a pointer to pointer
- From: Lope De Vega
- how to return a pointer to pointer
- Prev by Date: how to return a pointer to pointer
- Next by Date: Release Announcement
- Previous by thread: how to return a pointer to pointer
- Next by thread: Re: how to return a pointer to pointer
- Index(es):