fix cloned string cleanup

This commit is contained in:
2026-02-17 02:03:40 -05:00
parent a6bf357228
commit 225a1533cc
9 changed files with 113 additions and 59 deletions

View File

@@ -16,6 +16,7 @@
package dynamodb
import "core:encoding/json"
import "core:strings"
// ============================================================================
// Condition Evaluation Result
@@ -54,7 +55,7 @@ parse_condition_expression_string :: proc(request_body: []byte) -> (expr: string
return
}
expr = string(ce_str)
expr = strings.clone(string(ce_str))
ok = true
return
}
@@ -88,6 +89,7 @@ evaluate_condition_expression :: proc(
if !has_condition {
return .Passed // No condition → always pass
}
defer delete(condition_str)
// Parse the condition into a filter tree (same grammar as FilterExpression)
filter_node, parse_ok := parse_filter_expression(condition_str, attr_names, attr_values)

View File

@@ -480,7 +480,7 @@ parse_key_condition_expression_string :: proc(request_body: []byte) -> (expr: st
return
}
expr = string(kce_str)
expr = strings.clone(string(kce_str))
ok = true
return
}
@@ -488,6 +488,7 @@ parse_key_condition_expression_string :: proc(request_body: []byte) -> (expr: st
// Convenience: parse a complete Query key condition from request body
parse_query_key_condition :: proc(request_body: []byte) -> (kc: Key_Condition, ok: bool) {
expression := parse_key_condition_expression_string(request_body) or_return
defer delete(expression)
attr_names := parse_expression_attribute_names(request_body)
defer {

View File

@@ -817,7 +817,7 @@ parse_filter_expression_string :: proc(request_body: []byte) -> (expr: string, o
return
}
expr = string(fe_str)
expr = strings.clone(string(fe_str))
ok = true
return
}

View File

@@ -431,7 +431,7 @@ parse_table_name :: proc(request_body: []byte) -> (string, bool) {
return "", false
}
return string(table_name_str), true
return strings.clone(string(table_name_str)), true
}
// Parse Item field from request body

View File

@@ -54,6 +54,10 @@ Cancellation_Reason :: struct {
}
transact_write_action_destroy :: proc(action: ^Transact_Write_Action) {
delete(action.table_name)
if ce, has := action.condition_expr.?; has {
delete(ce)
}
if item, has := action.item.?; has {
item_copy := item
item_destroy(&item_copy)
@@ -618,8 +622,12 @@ Transact_Get_Result :: struct {
}
transact_get_action_destroy :: proc(action: ^Transact_Get_Action) {
delete(action.table_name)
item_destroy(&action.key)
if proj, has := action.projection.?; has {
for path in proj {
delete(path)
}
delete(proj)
}
}

View File

@@ -930,7 +930,7 @@ parse_update_expression_string :: proc(request_body: []byte) -> (expr: string, o
return
}
expr = string(ue_str)
expr = strings.clone(string(ue_str))
ok = true
return
}
@@ -939,24 +939,24 @@ parse_update_expression_string :: proc(request_body: []byte) -> (expr: string, o
parse_return_values :: proc(request_body: []byte) -> string {
data, parse_err := json.parse(request_body, allocator = context.temp_allocator)
if parse_err != nil {
return "NONE"
return strings.clone("NONE")
}
defer json.destroy_value(data)
root, root_ok := data.(json.Object)
if !root_ok {
return "NONE"
return strings.clone("NONE")
}
rv_val, found := root["ReturnValues"]
if !found {
return "NONE"
return strings.clone("NONE")
}
rv_str, str_ok := rv_val.(json.String)
if !str_ok {
return "NONE"
return strings.clone("NONE")
}
return string(rv_str)
return strings.clone(string(rv_str))
}