in reply to Inline::C & Strawberry: can't free a buffer allocated with asprintf
The success of that script (try2.pl) relies on it being in the same directory as libC_free.a.C:\pscrpt> type free.c #include <malloc.h> void C_free(void * ptr) { free(ptr); } C:\pscrpt> gcc -c free.c C:\pscrpt> ar rcs libC_free.a -o free.o C:\pscrpt> type try2.pl use strict; use warnings; BEGIN{ use Cwd; $m::cwd = getcwd() } use Inline C => Config => LIBS => "-L$m::cwd -lC_free"; use Inline C => <<'END_OF_C'; #define _GNU_SOURCE void foo() { char *s; asprintf(&s, "%s", "foo"); C_free(s); } END_OF_C foo(); __END__ C:\pscrpt> perl try2.pl C:\pscrpt>
|
|---|