| 2812 | } |
| 2813 | |
| 2814 | unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str) |
| 2815 | { |
| 2816 | char** new_keys = (char**)(lodepng_realloc(info->text_keys, sizeof(char*) * (info->text_num + 1))); |
| 2817 | char** new_strings = (char**)(lodepng_realloc(info->text_strings, sizeof(char*) * (info->text_num + 1))); |
| 2818 | if(!new_keys || !new_strings) |
| 2819 | { |
| 2820 | lodepng_free(new_keys); |
| 2821 | lodepng_free(new_strings); |
| 2822 | return 83; /*alloc fail*/ |
| 2823 | } |
| 2824 | |
| 2825 | ++info->text_num; |
| 2826 | info->text_keys = new_keys; |
| 2827 | info->text_strings = new_strings; |
| 2828 | |
| 2829 | string_init(&info->text_keys[info->text_num - 1]); |
| 2830 | string_set(&info->text_keys[info->text_num - 1], key); |
| 2831 | |
| 2832 | string_init(&info->text_strings[info->text_num - 1]); |
| 2833 | string_set(&info->text_strings[info->text_num - 1], str); |
| 2834 | |
| 2835 | return 0; |
| 2836 | } |
| 2837 | |
| 2838 | /******************************************************************************/ |
| 2839 |
no test coverage detected