diff options
author | Joel Bodenmann <joel@unormal.org> | 2014-02-02 12:38:47 +0100 |
---|---|---|
committer | Joel Bodenmann <joel@unormal.org> | 2014-02-02 12:38:47 +0100 |
commit | bf8ceb278fc285eff477294e1ae2cf539ada747b (patch) | |
tree | a713b7599b3f3295dbe85d31d7d2899d80bd1517 /src | |
parent | 2a0dfcf1c141640aa4936dc8a8b6272b654e87e7 (diff) | |
download | uGFX-bf8ceb278fc285eff477294e1ae2cf539ada747b.tar.gz uGFX-bf8ceb278fc285eff477294e1ae2cf539ada747b.tar.bz2 uGFX-bf8ceb278fc285eff477294e1ae2cf539ada747b.zip |
improving performance of gwinListAddItem() by Marc Pignat
Diffstat (limited to 'src')
-rw-r--r-- | src/gwin/list.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gwin/list.c b/src/gwin/list.c index 0f09e86e..972ea1ab 100644 --- a/src/gwin/list.c +++ b/src/gwin/list.c @@ -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; } |