in reply to Re^11: Perl XS binding to a struct with an array of chars*
in thread Perl XS binding to a struct with an array of chars*
I think the following Newx() rendition does the same thing (and does it portably):message = (EdjeMessageStringSet*) safemalloc( sizeof(EdjeMessageString +Set) + (count+1)*sizeof(char*) );
Of course, that Newx() approach relies on (sizeof(EdjeMessageStringSet) + (count+1)*sizeof(char*)) being an exact multiple of sizeof(char), which is a pretty safe bet whenever sizeof(char) is 1.Newx( message, (sizeof(EdjeMessageStringSet) + (count+1)*sizeof(char*) +) / sizeof(char), char );
and that works quite well.char ** p; EdjeMessageStringSet* message; ... Newx(message, 1, EdjeMessageStringSet; Newx(p, count + 1, char*); ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^13: Perl XS binding to a struct with an array of chars*
by Marshall (Canon) on Nov 28, 2022 at 07:46 UTC |