From 55d7d1f069d26dc292edad65388659524c0d8ef0 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 6 Sep 2024 00:57:51 +0900 Subject: [PATCH] [qfcc] Expose convert_op and ensafen free_operand Needed for type evaluation codegen, and free_operand needs to be null-safe. --- tools/qfcc/include/statements.h | 1 + tools/qfcc/source/statements.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/include/statements.h b/tools/qfcc/include/statements.h index 77b072b33..6bb0bdc58 100644 --- a/tools/qfcc/include/statements.h +++ b/tools/qfcc/include/statements.h @@ -162,6 +162,7 @@ operand_t *alias_operand (const struct type_s *type, operand_t *op, const struct expr_s *expr); operand_t *label_operand (const struct expr_s *label); operand_t *short_operand (short short_val, const struct expr_s *expr); +const char *convert_op (int op) __attribute__((const)); void free_operand (operand_t *op); sblock_t *new_sblock (void); diff --git a/tools/qfcc/source/statements.c b/tools/qfcc/source/statements.c index d0d1f68d3..442005e86 100644 --- a/tools/qfcc/source/statements.c +++ b/tools/qfcc/source/statements.c @@ -316,7 +316,9 @@ copy_operand (operand_t *src) void free_operand (operand_t *op) { - FREE (operands, op); + if (op) { + FREE (operands, op); + } } static void @@ -571,7 +573,7 @@ short_operand (short short_val, const expr_t *expr) return value_operand (val, expr); } -static const char * +const char * convert_op (int op) { switch (op) {