XS(XS_Net__LibnetRaw_libnet_init_packet) [...] u_char * buf = (u_char *)SvPV(ST(1),PL_na); [...] RETVAL = libnet_init_packet(p_size, &buf); sv_setpv((SV*)ST(1), buf); #### int libnet_init_packet(size_t p_size, u_char **buf); #### int libnet_build_ip([...], u_char *buf); #### u_char *buf; libnet_init_packet(IP_H + TCP_H, &buf); /* This calls malloc() and sets buf as a pointer to that new memory */ [...] libnet_build_ip([...], buf); /* The pointer value is the same, but data pointed to is altered */