Adjust join_strings logic to not auto free

master
kts of kettek (nyaa) 2020-01-14 21:29:20 -08:00
parent b04508fb87
commit 9fc090e795
2 changed files with 10 additions and 6 deletions

View File

@ -1184,7 +1184,9 @@ void fix_object(object *op) {
if (tmp->slaying!=NULL) { if (tmp->slaying!=NULL) {
if (op->slaying != NULL) if (op->slaying != NULL)
op->slaying = join_strings(op->slaying, tmp->slaying, ","); sstring joined_str = join_strings(op->slaying, tmp->slaying, ",");
free_string(op->slaying);
op->slaying = joined_str;
else else
add_refcount(op->slaying = tmp->slaying); add_refcount(op->slaying = tmp->slaying);
} }
@ -1236,7 +1238,9 @@ void fix_object(object *op) {
weapon_speed=0; weapon_speed=0;
if (tmp->slaying!=NULL) { if (tmp->slaying!=NULL) {
if (op->slaying != NULL) if (op->slaying != NULL)
op->slaying = join_strings(op->slaying, tmp->slaying, ","); sstring joined_str = join_strings(op->slaying, tmp->slaying, ",");
free_string(op->slaying);
op->slaying = joined_str;
else else
add_refcount(op->slaying = tmp->slaying); add_refcount(op->slaying = tmp->slaying);
} }
@ -1279,7 +1283,9 @@ void fix_object(object *op) {
max=ARMOUR_SPEED(tmp)/10.0; max=ARMOUR_SPEED(tmp)/10.0;
if (tmp->slaying!=NULL) { if (tmp->slaying!=NULL) {
if (op->slaying != NULL) if (op->slaying != NULL)
op->slaying = join_strings(op->slaying, tmp->slaying, ","); sstring joined_str = join_strings(op->slaying, tmp->slaying, ",");
free_string(op->slaying);
op->slaying = joined_str;
else else
add_refcount(op->slaying = tmp->slaying); add_refcount(op->slaying = tmp->slaying);
} }

View File

@ -237,10 +237,8 @@ sstring join_strings(sstring target_str, sstring source_str, const char *separat
/* create shared string from buffer */ /* create shared string from buffer */
ss = add_string(buf); ss = add_string(buf);
/* free our buffer and our shared string references */ /* free our buffer */
free(buf); free(buf);
free_string(target_str);
free_string(source_str);
return ss; return ss;
} }