Commit 0f4a03cb authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

free: instead of Curl_safefree()

Since we just started make use of free(NULL) in order to simplify code,
this change takes it a step further and:

- converts lots of Curl_safefree() calls to good old free()
- makes Curl_safefree() not check the pointer before free()

The (new) rule of thumb is: if you really want a function call that
frees a pointer and then assigns it to NULL, then use Curl_safefree().
But we will prefer just using free() from now on.
parent 9e661601
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -533,7 +533,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
  bufp = strdup(hostname);
  if(bufp) {
    struct ResolverResults *res = NULL;
    Curl_safefree(conn->async.hostname);
    free(conn->async.hostname);
    conn->async.hostname = bufp;
    conn->async.port = port;
    conn->async.done = FALSE;   /* not done */
@@ -541,7 +541,7 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
    conn->async.dns = NULL;     /* clear */
    res = calloc(sizeof(struct ResolverResults),1);
    if(!res) {
      Curl_safefree(conn->async.hostname);
      free(conn->async.hostname);
      conn->async.hostname = NULL;
      return NULL;
    }
+1 −1
Original line number Diff line number Diff line
@@ -393,7 +393,7 @@ static bool init_resolve_thread (struct connectdata *conn,
  if(!init_thread_sync_data(td, hostname, port, hints))
    goto err_exit;

  Curl_safefree(conn->async.hostname);
  free(conn->async.hostname);
  conn->async.hostname = strdup(hostname);
  if(!conn->async.hostname)
    goto err_exit;
+1 −1
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ CURLcode Curl_base64_decode(const char *src,
  for(i = 0; i < numQuantums; i++) {
    size_t result = decodeQuantum(pos, src);
    if(!result) {
      Curl_safefree(newstr);
      free(newstr);

      return CURLE_BAD_CONTENT_ENCODING;
    }
+2 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 2012, Linus Nielsen Feltzing, <linus@haxx.se>
 * Copyright (C) 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 2012-2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -74,7 +74,7 @@ void Curl_bundle_destroy(struct connectbundle *cb_ptr)
    Curl_llist_destroy(cb_ptr->conn_list, NULL);
    cb_ptr->conn_list = NULL;
  }
  Curl_safefree(cb_ptr);
  free(cb_ptr);
}

/* Add a connection to a bundle */
+1 −1
Original line number Diff line number Diff line
@@ -949,7 +949,7 @@ struct CookieInfo *Curl_cookie_init(struct SessionHandle *data,
  return c;

fail:
  Curl_safefree(line);
  free(line);
  if(!inc)
    /* Only clean up if we allocated it here, as the original could still be in
     * use by a share handle */
Loading