Marko Mlakar wrote:
>
> Prej obratno, realloc je najbolj neumna in nevarna fcija pri
> alociranju pomnilnika.. Tale funkcija (recmo add_char) bo
> sirila rezervirani prostor in unicevala podatke.. prej ali slej
> se bo vse skupej sesulo.
>
Do sedaj nisem nikjer naletel na komentarje podobne tvojim. The GNU C
Library Reference Manual (glibc 2.1.1), datiran na 11. januar 1999
pravi o realloc tole:
void * realloc (void *ptr, size_t newsize)
The realloc function changes the size of the block whose address is
ptr to be newsize.
Since the space after the end of the block may be in use, realloc
may find it necessary to copy the block to a new address where more
free space is available. The value of realloc is the new address of
the block. If the block needs to be moved, realloc copies the old
contents.
If you pass a null pointer for ptr, realloc behaves just like
`malloc (newsize)'. This can be convenient, but beware that older
implementations (before ISO C) may not support this behaviour, and
will probably crash when realloc is passed a null pointer.
Ze sam po sebi si ne drznem trditi, da bi razvijalci knjiznice glibc
vnesli funkcijo realloc, kot si jo ti opisal, zgornji izsek pa to se
potrjuje, saj se rezervira cisto nov blok pomnilnika dane velikosti,
ce nova velikost presega staro.
A lahko s cim podkrepis svojo trditev?
-AlesS
-----------------------------------------------------------------------
[EMAIL PROTECTED]
http://aless.rulz.org/ The Wizzard Of Oz
-----------------------------------------------------------------------