Use a flexiable array to store the filename.
authorTilman Sauerbeck <tilman@code-monkey.de>
Thu, 17 Aug 2006 16:03:15 +0000 (18:03 +0200)
committerTilman Sauerbeck <tilman@code-monkey.de>
Wed, 23 Aug 2006 17:39:15 +0000 (19:39 +0200)
ext/vcedit.c

index 832f417b2b30519cba6661b3dfb063c52a43f925..dfad95caf8a807bb5dee614e2590cfa567eaa726 100644 (file)
@@ -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;
 }