http://qs1969.pair.com?node_id=11148348


in reply to Re^3: Perl XS binding to a struct with an array of chars*
in thread Perl XS binding to a struct with an array of chars*

"Renewc" The XSUB-writer's interface to the C "realloc" function, with cast. Memory obtained by this should ONLY be freed with "Safefree". void Renewc(void* ptr, int nitems, type, cast)

So actually not how you commented it. The Renewc function modifies the pointer rather than returning anything.

Basically the OP's new version of the code works because sizeof(int) < 2*sizeof(char*)

The renewc is unneeded though, it could just be

message= (EdjeMessageStringSet*) safemalloc( sizeof(EdjeMessageStringSet) + (count-1)*sizeof(char*) )

For this code, the Newx type casting & sizing behavior is simply the wrong API to try to use.