improving performance of gwinListAddItem() by Marc Pignat

ugfx_release_2.6
Joel Bodenmann 2014-02-02 12:38:47 +01:00
parent 2a0dfcf1c1
commit bf8ceb278f
1 changed files with 4 additions and 3 deletions

View File

@ -431,13 +431,14 @@ int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) {
ListItem *newItem;
if (useAlloc) {
if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem)+strlen(item_name)+1)))
size_t len = strlen(item_name)+1;
if (!(newItem = gfxAlloc(sizeof(ListItem) + len)))
return -1;
strcpy((char *)(newItem+1), item_name);
memcpy((char *)(newItem+1), item_name, len);
item_name = (const char *)(newItem+1);
} else {
if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem))))
if (!(newItem = gfxAlloc(sizeof(ListItem))))
return -1;
}