|
From: Ioannis V. <no...@ho...> - 2002-09-03 18:24:59
|
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Carlos
Garc=EDa del Monte
Sent: Tuesday, September 03, 2002 7:23 PM
To: dev-cpp-users-list
Subject: Re: [Dev-C++] realloc =20
I tried to make an example reasigning to a so big block that it couldn't
be succeeding (I did something like realloc(pointer,
15545454554545455454545454554545); but then windows closed the console,
and I couldn't see the result.=20
So, in the end, just what I feared at first, but couldn't prove the
second part with the experiment:=20
numbers =3D (int*)realloc(numbers, newsize); =20
=20
The casting is redundant (always speaking of C).
=20
=20
is a practice better to avoid. Because if it fails then you get a block
of memory which had been allocated , but not freed. =20
=20
For accuracy, if it fails you remain with the old allocated memory.
=20
so=20
if(!r){=20
[...]=20
free(p);=20
} =20
=20
Ioannis
* Ioannis Vranos
* Programming pages: http://www.noicys.cjb.net
<http://www.noicys.cjb.net/>=20
* Alternative URL: http://run.to/noicys
|