MCPcopy Create free account
hub / github.com/MultiMC/Launcher / create_keyarray_in_table

Function create_keyarray_in_table

libraries/tomlc99/src/toml.c:807–846  ·  view source on GitHub ↗

Create an array in the table. */

Source from the content-addressed store, hash-verified

805/* Create an array in the table.
806 */
807static toml_array_t* create_keyarray_in_table(context_t* ctx,
808 toml_table_t* tab,
809 token_t keytok,
810 char kind)
811{
812 /* first, normalize the key to be used for lookup.
813 * remember to free it if we error out.
814 */
815 char* newkey = normalize_key(ctx, keytok);
816 if (!newkey) return 0;
817
818 /* if key exists: error out */
819 if (key_kind(tab, newkey)) {
820 xfree(newkey); /* don't need this anymore */
821 e_keyexists(ctx, keytok.lineno);
822 return 0;
823 }
824
825 /* make a new array entry */
826 int n = tab->narr;
827 toml_array_t** base;
828 if (0 == (base = (toml_array_t**) expand_ptrarr((void**)tab->arr, n))) {
829 xfree(newkey);
830 e_outofmemory(ctx, FLINE);
831 return 0;
832 }
833 tab->arr = base;
834
835 if (0 == (base[n] = (toml_array_t*) CALLOC(1, sizeof(*base[n])))) {
836 xfree(newkey);
837 e_outofmemory(ctx, FLINE);
838 return 0;
839 }
840 toml_array_t* dest = tab->arr[tab->narr++];
841
842 /* save the key in the new array struct */
843 dest->key = newkey;
844 dest->kind = kind;
845 return dest;
846}
847
848
849static toml_arritem_t* create_value_in_array(context_t* ctx,

Callers 2

parse_keyvalFunction · 0.85
parse_selectFunction · 0.85

Calls 7

normalize_keyFunction · 0.85
key_kindFunction · 0.85
xfreeFunction · 0.85
e_keyexistsFunction · 0.85
expand_ptrarrFunction · 0.85
e_outofmemoryFunction · 0.85
CALLOCFunction · 0.85

Tested by

no test coverage detected