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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.