| 2903 | } |
| 2904 | |
| 2905 | static unsigned lodepng_add_text_sized(LodePNGInfo* info, const char* key, const char* str, size_t size) { |
| 2906 | char** new_keys = (char**)(lodepng_realloc(info->text_keys, sizeof(char*) * (info->text_num + 1))); |
| 2907 | char** new_strings = (char**)(lodepng_realloc(info->text_strings, sizeof(char*) * (info->text_num + 1))); |
| 2908 | |
| 2909 | if(new_keys) info->text_keys = new_keys; |
| 2910 | if(new_strings) info->text_strings = new_strings; |
| 2911 | |
| 2912 | if(!new_keys || !new_strings) return 83; /*alloc fail*/ |
| 2913 | |
| 2914 | ++info->text_num; |
| 2915 | info->text_keys[info->text_num - 1] = alloc_string(key); |
| 2916 | info->text_strings[info->text_num - 1] = alloc_string_sized(str, size); |
| 2917 | if(!info->text_keys[info->text_num - 1] || !info->text_strings[info->text_num - 1]) return 83; /*alloc fail*/ |
| 2918 | |
| 2919 | return 0; |
| 2920 | } |
| 2921 | |
| 2922 | unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str) { |
| 2923 | return lodepng_add_text_sized(info, key, str, lodepng_strlen(str)); |
no test coverage detected