]> git.draconx.ca Git - upkg.git/blobdiff - src/uobject/module.c
Stop using gnulib's flexmember module.
[upkg.git] / src / uobject / module.c
index 057d1d0080ee23d685baf05113862208a8cace3d..1d41d0758be650eb5505e57947cdc6d9c9a6cf25 100644 (file)
@@ -1,21 +1,22 @@
 /*
- *  upkg: tool for manipulating Unreal Tournament packages.
- *  Copyright © 2009-2011 Nick Bowler
+ * upkg: tool for manipulating Unreal Tournament packages.
+ * Copyright © 2009-2012, 2022 Nick Bowler
  *
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
  *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -79,19 +80,16 @@ int u_object_module_exit(void)
 
 static int lookup_module(GTypeModule **out, const char *name)
 {
-       struct { GTypeModule pkg; char buf[]; } *search_key;
-       GTypeModule *result;
+       GTypeModule *result, key = {0};
+       char *buf;
 
-       search_key = malloc(sizeof *search_key + strlen(name) + 1);
-       if (!search_key)
+       buf = malloc(strlen(name) + 1);
+       if (!buf)
                return -1;
 
-       search_key->pkg = (GTypeModule) {
-               .name = str_cpy_lower(search_key->buf, name),
-       };
-
-       result = avl_find(package_tree, search_key);
-       free(search_key);
+       key.name = str_cpy_lower(buf, name);
+       result = avl_find(package_tree, &key);
+       free(buf);
 
        *out = result;
        return 0;