fir:
> union rchunk
> {
> chunk c;
> };
>
>
> rchunk AllocChunk(rchunk x, int size)
> {
> x.c.beg = (char*) realloc(x.c.beg, size );
> x.c.end = x.c.beg + size -1;
> return x;
> }
>
>
>
> rchunk dipa;
>
> void rchunk_test()
> {
>
>
> for(int i=1; i<100000; i++)
> {
> dipa = AllocChunk(dipa, i);
> printf("\n %i %p", ChunkLength(dipa.c), dipa.c.beg);
> }
>
> for(int i=100000; i>0; i--)
> {
> dipa = AllocChunk(dipa, i);
> printf("\n %i %p", ChunkLength(dipa.c), dipa.c.beg);
> }
> }
You never use chunk.end .
> it essentially does reallocks on some pointer:
> from 1 uo to 100 000 and then from 100 000 down to
> 1
Basically, you need to employ an allocation-deallo-
cation strategy that will cause maximum memory frag-
mentation -- for I am not sure that your arithmetic
progression is good for that. Then you should cre-
ate your own memory manager or a wrapper around the
standard one that would minimise fragmentation:
https://www.joelonsoftware.com/2001/12/11/back-to-basics/
> is reallocking to zero eqivalent of free?
Yes:
https://manned.org/realloc.3 .
--
Anton Shepelev