Create or update a bookmark in the list which will be updated to the next node * automatically when the one referenced gets deleted. * Returns 1 on success (creation of new bookmark or override of an existing one). * Returns 0 on failure (reached the maximum supported number of bookmarks). * NOTE: use short simple names, so that string compare on find is quick. * NOTE: bookmark creation may r
| 1453 | may change and it's the caller responsibilty to update the reference. |
| 1454 | */ |
| 1455 | int quicklistBookmarkCreate(quicklist **ql_ref, const char *name, quicklistNode *node) { |
| 1456 | quicklist *ql = *ql_ref; |
| 1457 | if (ql->bookmark_count >= QL_MAX_BM) |
| 1458 | return 0; |
| 1459 | quicklistBookmark *bm = _quicklistBookmarkFindByName(ql, name); |
| 1460 | if (bm) { |
| 1461 | bm->node = node; |
| 1462 | return 1; |
| 1463 | } |
| 1464 | ql = zrealloc(ql, sizeof(quicklist) + (ql->bookmark_count+1) * sizeof(quicklistBookmark)); |
| 1465 | *ql_ref = ql; |
| 1466 | ql->bookmarks[ql->bookmark_count].node = node; |
| 1467 | ql->bookmarks[ql->bookmark_count].name = zstrdup(name); |
| 1468 | ql->bookmark_count++; |
| 1469 | return 1; |
| 1470 | } |
| 1471 | |
| 1472 | /* Find the quicklist node referenced by a named bookmark. |
| 1473 | * When the bookmarked node is deleted the bookmark is updated to the next node, |
no test coverage detected