Skip to content

Commit

Permalink
Some improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Sourav Moitra <sourav.moitr@gmail.com>
  • Loading branch information
xw19 committed Nov 29, 2024
1 parent 3f784ca commit 443dc33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 5 additions & 1 deletion src/ocispec/json_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ make_json_map_string_string (json_t *src, const struct parser_context *ctx,
return NULL;
}

ret->len = 0;
ret->len = len;

ret->keys = calloc (len + 1, sizeof (char *));
if (ret->keys == NULL)
Expand Down Expand Up @@ -685,6 +685,10 @@ make_json_map_string_string (json_t *src, const struct parser_context *ctx,

i++;
}
if (i == 0) {
return NULL;
}

return move_ptr (ret);
}

Expand Down
8 changes: 1 addition & 7 deletions src/ocispec/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,12 @@ def get_obj_arr_obj_array(obj, c_file, prefix):
typename = obj.subtypname
else:
typename = helpers.get_name_substr(obj.name, prefix)

if obj.doublearray:
root_type = "array"
else:
root_type = "object"

c_file.append(f' if (ptr != NULL && ptr->{obj.fixname} != NULL)\n')
c_file.append(' {\n')
c_file.append(' size_t len = 0, i;\n')
c_file.append(f" if (ptr != NULL && ptr->{obj.fixname} != NULL)\n")
c_file.append(f" len = ptr->{obj.fixname}_len;//{obj.subtypobj}\n")
c_file.append(f' json_t *subroot = json_{root_type}();//lalala\n')
c_file.append(f' json_t *subroot = json_array();//lalala\n')
c_file.append(' for (i = 0; i < len; i++)\n')
c_file.append(' {\n')
if obj.doublearray:
Expand Down

0 comments on commit 443dc33

Please sign in to comment.