The list will be copied now.

This commit is contained in:
Jari Vetoniemi 2014-04-12 20:56:00 +03:00
parent ab54f2bc07
commit 01ff5f48ed
2 changed files with 7 additions and 5 deletions

View File

@ -252,8 +252,6 @@ bmItem* bmMenuGetHighlightedItem(const bmMenu *menu);
/**
* Set selected items to bmMenu instance.
*
* @warning The list won't be copied, do not free it.
*
* @param menu bmMenu instance where items will be set.
* @param items Array of bmItem pointers to set.
* @param nmemb Total count of items in array.

View File

@ -346,8 +346,6 @@ bmItem* bmMenuGetHighlightedItem(const bmMenu *menu)
/**
* Set selected items to bmMenu instance.
*
* @warning The list won't be copied, do not free it.
*
* @param menu bmMenu instance where items will be set.
* @param items Array of bmItem pointers to set.
* @param nmemb Total count of items in array.
@ -356,7 +354,13 @@ bmItem* bmMenuGetHighlightedItem(const bmMenu *menu)
int bmMenuSetSelectedItems(bmMenu *menu, bmItem **items, unsigned int nmemb)
{
assert(menu);
return _bmItemListSetItemsNoCopy(&menu->selection, items, nmemb);
bmItem **newItems;
if (!(newItems = calloc(sizeof(bmItem*), nmemb)))
return 0;
memcpy(newItems, items, sizeof(bmItem*) * nmemb);
return _bmItemListSetItemsNoCopy(&menu->selection, newItems, nmemb);
}
/**