Odin is my first foray into manual memory management. I'm using the tracking allocator to help find leaks but I can't seem to figure this this one out. I used strings.cut early in the proc for trimmed_base_path but deleting target_path doesn't have the same result. Any input would be super appreciated.
I did see another related post (https://discord.com/channels/568138951836172421/1183857839538720898) but couldn't work out a solution that worked for my problem.
gen_full_import_path :: proc(base_path: string, import_statement: string) -> string{
ending_slash_index := strings.last_index(base_path, "/")
trimmed_base_path := strings.cut(base_path, 0, ending_slash_index + 1)
defer delete(trimmed_base_path)
file_name_start_index := strings.index(import_statement, "'")
file_name_length := strings.last_index(import_statement, "'") - file_name_start_index
target_path := strings.cut(import_statement, file_name_start_index + 1, file_name_length - 1) // <-- The offender
defer delete(target_path)
if strings.has_prefix(target_path, "./") do target_path = strings.cut(target_path, 2, len(target_path) - 2)
if strings.contains(target_path, "../") do target_path, _ = strings.replace(target_path, "../", "", 1)
completed_path := strings.concatenate({trimmed_base_path, target_path, ".ts"})
delete(completed_path)
return completed_path
}