[ale] C memory management basic question.
Christopher Fowler
cfowler at outpostsentinel.com
Wed Oct 31 21:51:47 EST 2001
I am begining to write some fuctions that replace <pwd.h> functions.
one will be struct uentry *(char *name). The function will take a name and
return a pointer
to a uentry structure
struct
uentry *(char *name)
{
struct uentry *uuser;
uentry = (struct uentry *)malloc(1); //Allocate space for one;
/* .. Do some stuff get the correct user */
return *uuser;
}
When this function terminates, will the memory allocated for uuser in the
function
be reaped? Therefor exposing me to possible seg faults down the road? What
would be
the best way to do the above. I basically writing a replacement for
gwtpwnam(char *name);
I'm not finding many good topics on memory management in my text books. I
will look on the web
for some good tutorials.
Thanks,
Chris
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list