Commit 584dc8b8 authored by Yang Tse's avatar Yang Tse
Browse files

OOM handling/cleanup slight adjustments

parent a84b8a39
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -144,9 +144,9 @@ void Curl_cookie_loadfiles(struct SessionHandle *data)
                                       data->set.cookiesession);
      list = list->next;
    }
    Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
    curl_slist_free_all(data->change.cookielist); /* clean up list */
    data->change.cookielist = NULL; /* don't do this again! */
    Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
  }
}

+1 −2
Original line number Diff line number Diff line
@@ -48,8 +48,7 @@ void Curl_fileinfo_dtor(void *user, void *element)
  if(!finfo)
    return;

  if(finfo->b_data)
    free(finfo->b_data);
  Curl_safefree(finfo->b_data);

  free(finfo);
}
+13 −4
Original line number Diff line number Diff line
@@ -38,11 +38,14 @@ hash_element_dtor(void *user, void *element)
  struct curl_hash *h = (struct curl_hash *) user;
  struct curl_hash_element *e = (struct curl_hash_element *) element;

  if(e->key)
    free(e->key);
  Curl_safefree(e->key);

  if(e->ptr)
  if(e->ptr) {
    h->dtor(e->ptr);
    e->ptr = NULL;
  }

  e->key_len = 0;

  free(e);
}
@@ -78,14 +81,17 @@ Curl_hash_init(struct curl_hash *h,
        }
        free(h->table);
        h->table = NULL;
        h->slots = 0;
        return 1; /* failure */
      }
    }
    return 0; /* fine */
  }
  else
  else {
    h->slots = 0;
    return 1; /* failure */
  }
}

struct curl_hash *
Curl_hash_alloc(int slots,
@@ -190,6 +196,7 @@ int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
    he = le->ptr;
    if(h->comp_func(he->key, he->key_len, key, key_len)) {
      Curl_llist_remove(l, le, (void *) h);
      --h->size;
      return 0;
    }
  }
@@ -244,6 +251,8 @@ Curl_hash_clean(struct curl_hash *h)

  free(h->table);
  h->table = NULL;
  h->size = 0;
  h->slots = 0;
}

void
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ Curl_llist_alloc(curl_llist_dtor dtor)
  struct curl_llist *list;

  list = malloc(sizeof(struct curl_llist));
  if(NULL == list)
  if(!list)
    return NULL;

  llist_init(list, dtor);
+8 −6
Original line number Diff line number Diff line
@@ -425,12 +425,13 @@ CURLM *curl_multi_init(void)
  return (CURLM *) multi;

  error:
  if(multi->sockhash)

  Curl_hash_destroy(multi->sockhash);
  if(multi->hostcache)
  multi->sockhash = NULL;
  Curl_hash_destroy(multi->hostcache);
  if(multi->connc)
  multi->hostcache = NULL;
  Curl_rm_connc(multi->connc);
  multi->connc = NULL;

  free(multi);
  return NULL;
@@ -1801,6 +1802,7 @@ CURLMcode curl_multi_cleanup(CURLM *multi_handle)
    }

    Curl_rm_connc(multi->connc);
    multi->connc = NULL;

    /* remove the pending list of messages */
    Curl_llist_destroy(multi->msglist, NULL);
Loading