From 5078bffad799d41f8098e59b50d29dc018549663 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 13 Mar 2017 16:38:24 +0000 Subject: change urldb_set_title API to return an error status --- content/urldb.c | 35 ++++++++++++++++++++++------------- content/urldb.h | 3 ++- 2 files changed, 24 insertions(+), 14 deletions(-) (limited to 'content') diff --git a/content/urldb.c b/content/urldb.c index b190da5eb..2c2ba151c 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -218,9 +218,9 @@ struct path_data { struct path_data *next; /**< Next sibling */ struct path_data *prev; /**< Previous sibling */ - struct path_data *parent; /**< Parent path segment */ - struct path_data *children; /**< Child path segments */ - struct path_data *last; /**< Last child */ + struct path_data *parent; /**< Parent path segment */ + struct path_data *children; /**< Child path segments */ + struct path_data *last; /**< Last child */ }; struct host_part { @@ -241,15 +241,15 @@ struct host_part { char *part; /** - * Linked list of all known proctection spaces known for his + * Linked list of all known proctection spaces known for this * host and all its schems and ports. */ struct prot_space_data *prot_space; struct host_part *next; /**< Next sibling */ struct host_part *prev; /**< Previous sibling */ - struct host_part *parent; /**< Parent host part */ - struct host_part *children; /**< Child host parts */ + struct host_part *parent; /**< Parent host part */ + struct host_part *children; /**< Child host parts */ }; @@ -3171,23 +3171,32 @@ bool urldb_add_url(nsurl *url) /* exported interface documented in content/urldb.h */ -void urldb_set_url_title(nsurl *url, const char *title) +nserror urldb_set_url_title(nsurl *url, const char *title) { struct path_data *p; char *temp; - assert(url && title); + assert(url); p = urldb_find_url(url); - if (!p) - return; + if (p == NULL) { + return NSERROR_NOT_FOUND; + } - temp = strdup(title); - if (!temp) - return; + /* copy the parameter if necessary */ + if (title != NULL) { + temp = strdup(title); + if (temp == NULL) { + return NSERROR_NOMEM; + } + } else { + temp = NULL; + } free(p->urld.title); p->urld.title = temp; + + return NSERROR_OK; } diff --git a/content/urldb.h b/content/urldb.h index 7230d0bb9..734b94a0e 100644 --- a/content/urldb.h +++ b/content/urldb.h @@ -58,8 +58,9 @@ bool urldb_add_url(struct nsurl *url); * * \param url The URL to look for * \param title The title string to use (copied) + * \return NSERROR_OK on success otherwise appropriate error code */ -void urldb_set_url_title(struct nsurl *url, const char *title); +nserror urldb_set_url_title(struct nsurl *url, const char *title); /** -- cgit v1.2.3