in reply to Inline::C & Strawberry: can't free a buffer allocated with asprintf

Most likely, free() has been replaced/redefined to another function, maybe because this Perl was compiled with -Dusemymalloc. I'm not sure how you can get back the "original" free(), but maybe even a simple #undefine free already is enough?

Replies are listed 'Best First'.
Re^2: Inline::C & Strawberry: can't free a buffer allocated with asprintf
by vr (Curate) on Jan 02, 2020 at 11:45 UTC

    Thank you everyone for answers. Either of #undef free or __mingw_str_free(s); indeed work as expected (don't die, do de-allocate). In the end, asprintf brings more mess than convenience in this environment, so I'd rather revert to manual allocation/concatenation etc. :)

      asprintf is just one of many functions in C which will allocate memory and expect the caller to free it, so this is bound to happen again with other functions. Using __mingw_str_free() will cause portability issues.