in reply to help with XS (Newx and

Without testing it and actually going from the perlapi documentation for Newxz, the following should give you an allocated buffer, filled with zeroes:

AirLorconDriver * l_packet; Newxz( l_packet, 1, AirLorconDriver); /* Remember to use SafeFree() to release the memory pointed to by l_pa +cket */

Update: Also see perlguts for more discussion of Newx() and friends

Replies are listed 'Best First'.
Re^2: help with XS (Newx and
by Bpl (Scribe) on Sep 05, 2020 at 19:23 UTC
    Hi! sorry if I ask, but the
    Newxz( l_packet, 1, AirLorconDriver);
    would be referred to the memset or to the malloc function? because in the malloc case (r = (AirLorconDriver *) malloc(sizeof(AirLorconDriver *) );) there isn't any packet_l. thanks Edoardo Mantovani, 2020

      Newxz is a combined malloc() plus memset() call, see perlapi and perlguts on it.

      I think the usage would be to declare the pointer to your struct and then to have it allocated and zeroed like this:

      Newxz( r, 1, AirLorconDriver );