fix of by 1 error, add a hack for pointer arrays
authorMatthias Braun <matze@braunis.de>
Tue, 20 Jan 2009 09:49:17 +0000 (09:49 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 20 Jan 2009 09:49:17 +0000 (09:49 +0000)
[r25288]

wrappergen/write_jna.c

index add8d4b..b3e0469 100644 (file)
@@ -96,6 +96,11 @@ static void write_pointer_type(const pointer_type_t *type)
                fputs("String", out);
                return;
        }
+       if (is_type_pointer(points_to)) {
+               /* hack... */
+               fputs("Pointer[]", out);
+               return;
+       }
        fputs("Pointer", out);
 }
 
@@ -459,8 +464,8 @@ void write_jna_decls(FILE *output, const translation_unit_t *unit)
                        if (buf[0] == 0)
                                continue;
 
-                       char   *str = malloc(len);
-                       memcpy(str, buf, len);
+                       char *str = malloc(len+1);
+                       memcpy(str, buf, len+1);
                        symbol_t *symbol = symbol_table_insert(str);
                        pset_new_insert(&avoid_symbols, symbol);
                }