improving performance of gwinListAddItem() by Marc Pignat
This commit is contained in:
parent
2a0dfcf1c1
commit
bf8ceb278f
@ -431,13 +431,14 @@ int gwinListAddItem(GHandle gh, const char* item_name, bool_t useAlloc) {
|
|||||||
ListItem *newItem;
|
ListItem *newItem;
|
||||||
|
|
||||||
if (useAlloc) {
|
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;
|
return -1;
|
||||||
|
|
||||||
strcpy((char *)(newItem+1), item_name);
|
memcpy((char *)(newItem+1), item_name, len);
|
||||||
item_name = (const char *)(newItem+1);
|
item_name = (const char *)(newItem+1);
|
||||||
} else {
|
} else {
|
||||||
if (!(newItem = (ListItem *)gfxAlloc(sizeof(ListItem))))
|
if (!(newItem = gfxAlloc(sizeof(ListItem))))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user