replace fixed size array, with dynamic size array to work with font length exceeds 120
It seems that this patch has no reviewers specified. If you are unsure who can review your patch, please check this wiki page and see if anyone can be added: https://phab.enlightenment.org/w/maintainers_reviewers/
well the static buffer was here for a reason(to avoid memory allocation) . so if you are paranoid that the font name can be bigger than 100 character , then use the malloc by doing a strlen() check if its exceeds the buffer, otherwise use the static buffer.
good , now just wrap this block of code in some small function like
or pick your function name :)
then this code block will be replaced with
tag_ret->font = _embedded_font(val);
../src/lib/edje/edje_textblock_styles.c: In function ‘_embedded_font’:
../src/lib/edje/edje_textblock_styles.c:72:13: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
ret = eina_stringshare_add(buffer); ^
../src/lib/edje/edje_textblock_styles.c: In function ‘_edje_format_reparse’:
../src/lib/edje/edje_textblock_styles.c:122:60: warning: passing argument 1 of ‘_embedded_font’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
tag_ret->font = _embedded_font(val); ^~~
../src/lib/edje/edje_textblock_styles.c:55:15: note: expected ‘char *’ but argument is of type ‘const char *’
static char * _embedded_font(char * font)
please fix upon warning messages.
I am not too sure if the intent to use malloc if the size is bigger than 100 is a good idea at all. why not just use alloca ? There is eina_stringshare_nprintf which is normally used for such purposes. And i think it makes a lot of sense to use this here as well. If there is a issue with > 100 characters on the stack, then we simply can resolve this as well in the eina_stringshare implementation and fix this as well for all the other cases.
Just use an Eina_Strbuf! If you want to optimize the memory allocation, you can even use eina_strbuf_manage_read_only_new_length with your buffer_stack. Be careful with complex code that manipulate string, this are hard to get right and not smack things around.