MCPcopy Create free account
hub / github.com/DFHack/dfhack / lodepng_add_text_sized

Function lodepng_add_text_sized

depends/lodepng/lodepng.cpp:2905–2920  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2903}
2904
2905static 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
2922unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str) {
2923 return lodepng_add_text_sized(info, key, str, lodepng_strlen(str));

Callers 2

lodepng_add_textFunction · 0.85
readChunk_zTXtFunction · 0.85

Calls 3

lodepng_reallocFunction · 0.85
alloc_stringFunction · 0.85
alloc_string_sizedFunction · 0.85

Tested by

no test coverage detected