From 7e726545b86e81eb329fe3d853bd0ade0bacef63 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 4 Jan 2021 19:28:27 +0900 Subject: [PATCH] [vulkan] Fix some string retention issues I really need to come up with a better solution for managing strings in quakec. --- libs/video/renderer/vulkan/vkgen/vkfieldcustom.r | 11 +++++++++-- libs/video/renderer/vulkan/vkgen/vkfieldtype.r | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/video/renderer/vulkan/vkgen/vkfieldcustom.r b/libs/video/renderer/vulkan/vkgen/vkfieldcustom.r index 3e9e56c74..7c7843414 100644 --- a/libs/video/renderer/vulkan/vkgen/vkfieldcustom.r +++ b/libs/video/renderer/vulkan/vkgen/vkfieldcustom.r @@ -1,4 +1,5 @@ #include +#include #include "vkfieldcustom.h" #include "vkgen.h" @@ -14,13 +15,19 @@ } PLItem *desc = [item getObjectForKey:"type"]; - pltype = [[desc getObjectAtIndex:1] string]; - parser = [[desc getObjectAtIndex:2] string]; + pltype = str_hold ([[desc getObjectAtIndex:1] string]); + parser = str_hold ([[desc getObjectAtIndex:2] string]); fields = [item getObjectForKey:"fields"]; return self; } +-(void)dealloc +{ + str_free (pltype); + str_free (parser); +} + -writeParseData { fprintf (output_file, "static size_t parse_%s_%s_offsets[] = {\n", diff --git a/libs/video/renderer/vulkan/vkgen/vkfieldtype.r b/libs/video/renderer/vulkan/vkgen/vkfieldtype.r index e3d7cf59d..cb1a04508 100644 --- a/libs/video/renderer/vulkan/vkgen/vkfieldtype.r +++ b/libs/video/renderer/vulkan/vkgen/vkfieldtype.r @@ -14,6 +14,7 @@ -(void)dealloc { + str_free (type); str_free (parser); str_free (parse_type); } @@ -42,12 +43,13 @@ parseItemType (PLItem *item) type = [item string]; if (type) { Type *field_type = [[Type lookup:type] dereference]; + type = str_hold (type); parse_type = [field_type parseType]; parser = str_hold ("parse_" + type); } else { parse_type = parseItemType([item getObjectForKey:"parse_type"]); - type = [[item getObjectForKey:"type"] string]; - parser = [[item getObjectForKey:"parser"] string]; + type = str_hold ([[item getObjectForKey:"type"] string]); + parser = str_hold ([[item getObjectForKey:"parser"] string]); } return self;