vr has asked for the wisdom of the Perl Monks concerning the following question:
Having learned about asprintf, I was trying to improve/tidy a couple C fragments, but here's a problem with Strawberry:
use strict; use warnings; use Inline C => <<'END_OF_C'; #define _GNU_SOURCE void foo() { char *s; asprintf(&s, "%s", "foo"); free(s); } END_OF_C foo(); __END__ Free to wrong pool 6334e0 not 8c00140021160806 at asprintf.pl line 13.
This number is frightening. With "free" line disabled, it runs OK, but leaks. In Linux it runs OK as is. Simple and obvious C program compiles and runs OK under same gcc i.e. part of MinGW/Strawberry.
Not sure if some configuration flag can solve the problem, therefore hesitate to report it as "Inline::C" bug, esp. since my C is rudimentary. Didn't find any mention of "asprintf" in whole Inline or Inline::C distributions. I understand "asprintf" is not necessary, but avoiding it doesn't feel right.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Inline::C & Strawberry: can't free a buffer allocated with asprintf
by bliako (Abbot) on Jan 01, 2020 at 22:43 UTC | |
Re: Inline::C & Strawberry: can't free a buffer allocated with asprintf
by Corion (Patriarch) on Jan 01, 2020 at 19:08 UTC | |
by vr (Curate) on Jan 02, 2020 at 11:45 UTC | |
by bliako (Abbot) on Jan 02, 2020 at 12:12 UTC | |
Re: Inline::C & Strawberry: can't free a buffer allocated with asprintf
by syphilis (Archbishop) on Jan 02, 2020 at 01:53 UTC | |
Re: Inline::C & Strawberry: can't free a buffer allocated with asprintf
by syphilis (Archbishop) on Jan 02, 2020 at 03:51 UTC |