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

@@ -267,7 +267,7 @@ parse_transact_put_action :: proc(
if !tn_ok {
return {}, false
}
action.table_name = string(tn_str)
action.table_name = strings.clone(string(tn_str))
// Item
item_val, item_found := obj["Item"]
@@ -301,7 +301,7 @@ parse_transact_key_action :: proc(
if !tn_ok {
return {}, false
}
action.table_name = string(tn_str)
action.table_name = strings.clone(string(tn_str))
// Key
key_val, key_found := obj["Key"]
@@ -335,7 +335,7 @@ parse_transact_update_action :: proc(
if !tn_ok {
return {}, false
}
action.table_name = string(tn_str)
action.table_name = strings.clone(string(tn_str))
// Key
key_val, key_found := obj["Key"]
@@ -483,7 +483,9 @@ handle_transact_get_items :: proc(
}
// Build response
builder := strings.builder_make()
builder := strings.builder_make(context.allocator)
defer strings.builder_destroy(&builder)
strings.write_string(&builder, `{"Responses":[`)
for maybe_item, i in result.items {
@@ -492,8 +494,9 @@ handle_transact_get_items :: proc(
}
if item, has_item := maybe_item.?; has_item {
item_json := dynamodb.serialize_item(item)
fmt.sbprintf(&builder, `{{"Item":%s}}`, item_json)
strings.write_string(&builder, `{"Item":`)
dynamodb.serialize_item_to_builder(&builder, item)
strings.write_string(&builder, `}`)
} else {
strings.write_string(&builder, "{}")
}
@@ -501,7 +504,8 @@ handle_transact_get_items :: proc(
strings.write_string(&builder, "]}")
resp_body := strings.to_string(builder)
// Clone the string or we gonna have issues again
resp_body := strings.clone(strings.to_string(builder))
response_set_body(response, transmute([]byte)resp_body)
}
@@ -519,7 +523,7 @@ parse_transact_get_action :: proc(obj: json.Object) -> (dynamodb.Transact_Get_Ac
if !tn_ok {
return {}, false
}
action.table_name = string(tn_str)
action.table_name = strings.clone(string(tn_str))
// Key
key_val, key_found := obj["Key"]