Thanks for you reply Solar
I think I was somewhat unclear.
A function returning a struct is given a pointer where it copies the return value.
Well, I mean, in the disassembly of something like the following
Code: Select all
struct x { int a; .. };
struct x myFun ()
{
struct x u;
u.a=1;
return u;
}
int main()
{
struct x v= myFun();
}
it looked like main allocated v on stack and then passed a pointer to it using %eax, while myFun allocated u on stack, manipulate it and copy the contents of u to v.
I'm not sure, though. Well anyways I found a neat way for returning an empty struct:
Code: Select all
struct x
{
int a;
a (int val) { memset(this, val, sizeof(x)); }
}
struct x NullX() {
return (struct x) 0;
}
In the mean-time, I decided my function would return a pointer as I do not need a copy of the bios32 directory service header.
Cheers
