develooper Front page | perl.perl5.porters | Postings from September 2014

Re: sv_grow() and malloc()

Thread Previous | Thread Next
From:
Father Chrysostomos
Date:
September 23, 2014 12:49
Subject:
Re: sv_grow() and malloc()
Message ID:
20140923124919.15161.qmail@lists-nntp.develooper.com
Dave Mitchell wrote:
> I'd be interested in what people get with that code on other OSes.

That code does not account for the possibility that the allocated area
may be extended, rather than moved.  (I don't know whether malloc
does that.)

I wrote some similar code a couple of years ago using malloc_size, and
found that 32-bit darwin allocates in 16-octet chunks.

Running your code now, it appears that 64-bit darwin does the same:

$ ./a.out 
after  16 bytes realloc() using different address
after  32 bytes realloc() using different address
after  48 bytes realloc() using different address
after  64 bytes realloc() using different address
after  80 bytes realloc() using different address
after  96 bytes realloc() using different address
after 112 bytes realloc() using different address
after 128 bytes realloc() using different address


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About