[vulkan] Fix some string retention issues

I really need to come up with a better solution for managing strings in
quakec.
This commit is contained in:
Bill Currie 2021-01-04 19:28:27 +09:00
parent d919a85c8e
commit 7e726545b8
2 changed files with 13 additions and 4 deletions

View file

@ -1,4 +1,5 @@
#include <PropertyList.h> #include <PropertyList.h>
#include <string.h>
#include "vkfieldcustom.h" #include "vkfieldcustom.h"
#include "vkgen.h" #include "vkgen.h"
@ -14,13 +15,19 @@
} }
PLItem *desc = [item getObjectForKey:"type"]; PLItem *desc = [item getObjectForKey:"type"];
pltype = [[desc getObjectAtIndex:1] string]; pltype = str_hold ([[desc getObjectAtIndex:1] string]);
parser = [[desc getObjectAtIndex:2] string]; parser = str_hold ([[desc getObjectAtIndex:2] string]);
fields = [item getObjectForKey:"fields"]; fields = [item getObjectForKey:"fields"];
return self; return self;
} }
-(void)dealloc
{
str_free (pltype);
str_free (parser);
}
-writeParseData -writeParseData
{ {
fprintf (output_file, "static size_t parse_%s_%s_offsets[] = {\n", fprintf (output_file, "static size_t parse_%s_%s_offsets[] = {\n",

View file

@ -14,6 +14,7 @@
-(void)dealloc -(void)dealloc
{ {
str_free (type);
str_free (parser); str_free (parser);
str_free (parse_type); str_free (parse_type);
} }
@ -42,12 +43,13 @@ parseItemType (PLItem *item)
type = [item string]; type = [item string];
if (type) { if (type) {
Type *field_type = [[Type lookup:type] dereference]; Type *field_type = [[Type lookup:type] dereference];
type = str_hold (type);
parse_type = [field_type parseType]; parse_type = [field_type parseType];
parser = str_hold ("parse_" + type); parser = str_hold ("parse_" + type);
} else { } else {
parse_type = parseItemType([item getObjectForKey:"parse_type"]); parse_type = parseItemType([item getObjectForKey:"parse_type"]);
type = [[item getObjectForKey:"type"] string]; type = str_hold ([[item getObjectForKey:"type"] string]);
parser = [[item getObjectForKey:"parser"] string]; parser = str_hold ([[item getObjectForKey:"parser"] string]);
} }
return self; return self;