# HG changeset patch # User ib # Date 1330002469 0 # Node ID 6378e3a2ffb8290f93d350da2daafb11d82a1193 # Parent 23f4f210477401a3e20e0e0362854c601bcf40a3 Revise listMgr() command URLLIST_ITEM_ADD. Remove unnecessary variable is_added, replace gstrcmp() by strcmp(), fix memory leakage by freeing list item that won't be added and change return value to pointer to added item. Additionally, insert some blank lines. diff -r 23f4f2104774 -r 6378e3a2ffb8 gui/util/list.c --- a/gui/util/list.c Thu Feb 23 12:59:28 2012 +0000 +++ b/gui/util/list.c Thu Feb 23 13:07:49 2012 +0000 @@ -31,7 +31,6 @@ { plItem *pdat = (plItem *)data; urlItem *udat = (urlItem *)data; - int is_added = 1; switch (cmd) { // playlist @@ -146,26 +145,31 @@ return urlList; case URLLIST_ITEM_ADD: + if (urlList) { urlItem *item = urlList; - is_added = 0; - while (item->next) { - if (!gstrcmp(item->url, udat->url)) { - is_added = 1; + while (item) { + if (strcmp(udat->url, item->url) == 0) { + free(udat->url); + free(udat); + return NULL; + } + + if (item->next) + item = item->next; + else { + item->next = udat; + udat->next = NULL; break; } - - item = item->next; } - - if (!is_added && gstrcmp(item->url, udat->url)) - item->next = udat; } else { udat->next = NULL; urlList = udat; } - return NULL; + + return udat; case URLLIST_DELETE: