From 515385a477e014f46197bfd0596ee21734e4820d Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sat, 12 Nov 2022 02:41:01 -0800 Subject: [PATCH] Only calculate length on ser of names --- gamestate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gamestate.c b/gamestate.c index 2677fb9..46b662c 100644 --- a/gamestate.c +++ b/gamestate.c @@ -681,8 +681,12 @@ const static SerMaybeFailure ser_ok = { 0 }; SerMaybeFailure ser_data(SerState* ser, char* data, size_t data_len, const char* name, const char* file, int line) { char var_name[512] = { 0 }; - snprintf(var_name, 512, "%d%s", line, name); // can't have separator before the name, when comparing names skips past the digit - size_t var_name_len = strlen(var_name); + size_t var_name_len = 0; + if(ser->write_varnames) + { + snprintf(var_name, 512, "%d%s", line, name); // can't have separator before the name, when comparing names skips past the digit + var_name_len = strlen(var_name); + } if (ser->serializing) { if (ser->write_varnames)