Shane Wegner (shane@cm.nu)
Fri, 15 Jan 1999 13:31:12 -0800 (PST)
-----BEGIN PGP SIGNED MESSAGE-----
Hi,
I have a few questions with Memory allocation under Linux and am hoping
someone here has some experience with it. In particular malloc(2) and
free(2) questions. In the following function, does s free itself?
int test(void) {
char *s;
s = malloc(1024);
return 0;
}
The reason I ask this is I am wondering if I have to free all my variables
whenever I return out of a function. For example, when I use char *strstr
in a function, is it necessary to free the result inorder to prevent a
memory leak?
- --
Shane Wegner: shane@cm.nu
Tel: (604) 930-0530
Sysadmin, Continuum Systems: http://www.cm.nu
Personal website: http://www.cm.nu/~shane
Celine Dion Fan site: http://www.celine.nu/
PGP key: http://www.cm.nu/~shane/pgp.txt
ICQ UIN: 15706546
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3a
Charset: noconv
iQEVAwUBNp+zoVzLgRKaVg+xAQEqjAf/SMRej0UGCq+D0/O4qB9ZsOGQ/iOw5oDv
AJiwkGp4jSIJBxxOFDsRczEHrtwHkm0M7tT139oZe3CwrFf9QLwHUrXJPu986HF/
hD350B+fBN8zwyFhYVwCwHjQ9K+2UmetyMIFqjEQeoByQ/K7JBBlaNN0pEO2Sai9
lmgp1jHEvU6BTm3pyxcd9C3x9ja1DXUuaWeUdh+IsR7dInHGb0ph9Prx+9MwBoao
kDBulrCOr61XX2FkYzuBTFSHByXLCARUi7DOlsv73Ne7jFHSebRtXzMnd3EqZUyN
mkf+GOr8cca1nd/U8F2tskuJEhXycwaN/Htj5MZayOzj3xNzTm7Y7w==
=SHpS
-----END PGP SIGNATURE-----
This archive was generated by hypermail 2.0b3 on Fri 15 Jan 1999 - 13:31:48 PST