File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,17 @@ static int _push_entry(arena_t* arena,
41
41
const char * const source ,
42
42
size_t length ) {
43
43
44
+ if (source == NULL ) {
45
+ csv -> rows .content [csv -> rows .count ++ ] = NULL ;
46
+ return 0 ;
47
+ }
48
+
49
+ if (csv -> rows .count + 1 >= csv -> rows .capacity ) {
50
+ size_t capacity = csv -> rows .capacity * 2 ;
51
+ csv -> rows .content = realloc (csv -> rows .content , sizeof (char * ) * capacity * csv -> column_count );
52
+ csv -> rows .capacity = capacity ;
53
+ }
54
+
44
55
csv -> rows .content [csv -> rows .count ++ ] =
45
56
arena_string_with_null (arena , source , length + 1 );
46
57
@@ -168,14 +179,14 @@ int csv_parse_custom_delimiter(arena_t* arena,
168
179
} break ;
169
180
case CSV_PARSER_EOL : {
170
181
if (expecting_value ) {
171
- csv -> rows . content [ csv -> rows . count ++ ] = NULL ;
182
+ _push_entry ( arena , csv , NULL , 0 ) ;
172
183
}
173
184
csv -> row_count += * (position + item_length ) != 0 ;
174
185
expecting_value = true;
175
186
} break ;
176
187
case CSV_PARSER_SEPARATOR : {
177
188
if (expecting_value ) {
178
- csv -> rows . content [ csv -> rows . count ++ ] = NULL ;
189
+ _push_entry ( arena , csv , NULL , 0 ) ;
179
190
} else {
180
191
expecting_value = true;
181
192
}
You can’t perform that action at this time.
0 commit comments