comparison dowa/d_string.c @ 112:d6d578b49a19

[PostDog] Got CRUD working.
author June Park <parkjune1995@gmail.com>
date Sun, 04 Jan 2026 11:38:44 -0800
parents 655ea0b661fd
children a2720eac50ce
comparison
equal deleted inserted replaced
111:48f260576059 112:d6d578b49a19
18 return buffer; 18 return buffer;
19 } 19 }
20 20
21 char **Dowa_String_Split(char *from, char *token, int32 from_length, int32 token_length, Dowa_Arena *p_arena) 21 char **Dowa_String_Split(char *from, char *token, int32 from_length, int32 token_length, Dowa_Arena *p_arena)
22 { 22 {
23 if (!from || from[0] == '\n') 23 if (!from)
24 return NULL; 24 return NULL;
25 25
26 int32 *token_pos_arr = NULL; 26 int32 *token_pos_arr = NULL;
27 for (int32 i = 0; i < from_length; i++) 27 for (int32 i = 0; i < from_length; i++)
28 { 28 {
35 break; 35 break;
36 curr_token_pointer++; 36 curr_token_pointer++;
37 } 37 }
38 38
39 if (curr_token_pointer == token_length) 39 if (curr_token_pointer == token_length)
40 {
41 Dowa_Array_Push(token_pos_arr, i); 40 Dowa_Array_Push(token_pos_arr, i);
42 }
43 } 41 }
44 } 42 }
45 43
46 char **splitted_strings = NULL; 44 char **splitted_strings = NULL;
47 int32 start = 0; 45 int32 start = 0;
52 int32 end = (i < num_tokens) ? token_pos_arr[i] : from_length; 50 int32 end = (i < num_tokens) ? token_pos_arr[i] : from_length;
53 51
54 char *val = Dowa_String_Slice(from, start, end, p_arena); 52 char *val = Dowa_String_Slice(from, start, end, p_arena);
55 53
56 if (p_arena) 54 if (p_arena)
57 {
58 Dowa_Array_Push_Arena(splitted_strings, val, p_arena); 55 Dowa_Array_Push_Arena(splitted_strings, val, p_arena);
59 }
60 else 56 else
61 {
62 Dowa_Array_Push(splitted_strings, val); 57 Dowa_Array_Push(splitted_strings, val);
63 }
64 58
65 if (i < num_tokens) { 59 if (i < num_tokens)
66 start = token_pos_arr[i] + token_length; 60 start = token_pos_arr[i] + token_length;
67 }
68 } 61 }
69 62
70 Dowa_Array_Free(token_pos_arr); 63 Dowa_Array_Free(token_pos_arr);
71 return splitted_strings; 64 return splitted_strings;
72 } 65 }