summaryrefslogtreecommitdiff
path: root/desktop/global_history.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-06-18 18:54:06 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2013-06-18 18:54:06 +0100
commit8c114cdfd824a7ed2fd02ff13e4fd5def6a443b1 (patch)
treef243c2282151fea8a293fc557e49ec9002a7ece2 /desktop/global_history.c
parenta642cab1b7eab0f68f00835ec463bc4b8270995f (diff)
downloadnetsurf-8c114cdfd824a7ed2fd02ff13e4fd5def6a443b1.tar.gz
netsurf-8c114cdfd824a7ed2fd02ff13e4fd5def6a443b1.tar.bz2
Ensure global_history_delete_internal checks treeview node is NULL. Add various documentation comments.
Diffstat (limited to 'desktop/global_history.c')
-rw-r--r--desktop/global_history.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/desktop/global_history.c b/desktop/global_history.c
index e32f2baed..f803b526e 100644
--- a/desktop/global_history.c
+++ b/desktop/global_history.c
@@ -76,7 +76,7 @@ struct global_history_entry *gh_list[N_DAYS];
* Find an entry in the global history
*
* \param url The URL to find
- * \return Pointer to node, or NULL if not found
+ * \return Pointer to history entry, or NULL if not found
*/
static struct global_history_entry *global_history_find(nsurl *url)
{
@@ -89,15 +89,25 @@ static struct global_history_entry *global_history_find(nsurl *url)
while (e != NULL) {
if (nsurl_compare(e->url, url,
NSURL_COMPLETE) == true) {
+ /* Got a match */
return e;
}
e = e->next;
}
}
+
+ /* No match found */
return NULL;
}
+/**
+ * Get the treeview folder for history entires in a particular slot
+ *
+ * \param parent Updated to parent folder.
+ * \param slot Global history slot of entry we want folder node for
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
static inline nserror global_history_get_parent_treeview_node(
struct treeview_node **parent, int slot)
{
@@ -124,6 +134,8 @@ static inline nserror global_history_get_parent_treeview_node(
/* Get the folder */
f = &(gh_ctx.folders[folder_index]);
+ /* TODO: Create the folder if f==NULL */
+
/* Return the parent treeview folder */
*parent = f->folder;
return NSERROR_OK;
@@ -266,9 +278,21 @@ static nserror global_history_add_entry_internal(nsurl *url, int slot,
return NSERROR_OK;
}
+
+/**
+ * Delete a global history entry
+ *
+ * This does not delete the treeview node, rather it should only be called from
+ * the treeview node delete event message.
+ *
+ * \param e Entry to delete
+ */
static void global_history_delete_entry_internal(
struct global_history_entry *e)
{
+ assert(e != NULL);
+ assert(e->entry == NULL);
+
/* Unlink */
if (gh_list[e->slot] == e) {
/* e is first entry */
@@ -564,6 +588,7 @@ static nserror global_history_tree_node_entry_cb(
switch (msg.msg) {
case TREE_MSG_NODE_DELETE:
+ e->entry = NULL;
global_history_delete_entry_internal(e);
break;