-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2 May 00, at 15:36, Federico Barbazza wrote:
> > > stralloc *arrayname;
> > > int numm = 30;
> > > arrayname = (stralloc *) alloc(numm * sizeof(stralloc))
> >
> > Does alloc() initialize the memory it allocates? To which value?
>
> how can i see??
What? You're using a function and you don't know what the
function does??? Oh God!
You may want to read the source of the function, I would think. Or
find a documentation.
> > > for (i=0; i<numm; i++)
> > > stralloc_copys(&arrayname[i], "hello");
> > >
> > > This code exit with a "segmentation fault" sometimes immediatly
> > > sometimes when i = 2. Is it a memory problem??
> >
> > Looks like the memory is initialized to arbitrary values, sometimes
> > - - - by chance - to NULL or something, and therefore not crashing.
> I saw stralloc are initializate as:
> stralloc variable = {0}.
> How can i initialize my stralloc array??
memset(arrayname,0,numm*sizeof(arrayname[0])); is a way.
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.0.2 -- QDPGP 2.60
Comment: http://community.wow.net/grt/qdpgp.html
iQA/AwUBOQ7M0lMwP8g7qbw/EQJlMACeLVqA6403eVTwvIT/hR5Eeqx5E4MAoOgF
WZxhTY93ZON1sCUocVPYgD95
=AMMI
-----END PGP SIGNATURE-----
--
Petr Novotny, ANTEK CS
[EMAIL PROTECTED]
http://www.antek.cz
PGP key ID: 0x3BA9BC3F
-- Don't you know there ain't no devil there's just God when he's drunk.
[Tom Waits]