strstore() is defined as a strdup which ensures to free the target
pointer before duping the source char * into it. Make use of it in
two more cases where it can simplify the code.
#include "curl_memory.h"
#include "memdebug.h"
+static void strstore(char **str, const char *newstr);
+
static void freecookie(struct Cookie *co)
{
free(co->expirestr);
/* #-fragments are already cut off! */
if(0 == strlen(uri_path) || uri_path[0] != '/') {
- free(uri_path);
- uri_path = strdup("/");
+ strstore(&uri_path, "/");
if(!uri_path)
return FALSE;
}
/* RFC6265 5.2.4 The Path Attribute */
if(new_path[0] != '/') {
/* Let cookie-path be the default-path. */
- free(new_path);
- new_path = strdup("/");
+ strstore(&new_path, "/");
return new_path;
}