From: Tilman Sauerbeck Date: Thu, 17 Aug 2006 16:03:15 +0000 (+0200) Subject: Use a flexiable array to store the filename. X-Git-Tag: ruby-vorbistagger-0.0.1~21 X-Git-Url: http://git.code-monkey.de/?p=ruby-vorbistagger.git;a=commitdiff_plain;h=1395b8113e601b31a8f1f30f97496024fdc72c9e Use a flexiable array to store the filename. --- diff --git a/ext/vcedit.c b/ext/vcedit.c index 832f417..dfad95c 100644 --- a/ext/vcedit.c +++ b/ext/vcedit.c @@ -40,8 +40,6 @@ struct vcedit_state_St { vorbis_comment vc; vorbis_info vi; - char filename[PATH_MAX]; - FILE *in; bool opened; long serial; @@ -53,6 +51,8 @@ struct vcedit_state_St { int prevW; int extrapage; int eosin; + + char filename[0]; }; static void @@ -82,8 +82,11 @@ vcedit_state * vcedit_state_new (const char *filename) { vcedit_state *state; + size_t len; + + len = strlen (filename); - state = malloc (sizeof (vcedit_state)); + state = malloc (sizeof (vcedit_state) + len + 1); if (!state) return NULL; @@ -94,8 +97,7 @@ vcedit_state_new (const char *filename) return NULL; } - snprintf (state->filename, sizeof (state->filename), - "%s", filename); + strcpy (state->filename, filename); return state; }