Create an array in the table. */
| 805 | /* Create an array in the table. |
| 806 | */ |
| 807 | static 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 | |
| 849 | static toml_arritem_t* create_value_in_array(context_t* ctx, |
no test coverage detected