~ubuntu-branches/ubuntu/lucid/curl/lucid-security

« back to all changes in this revision

Viewing changes to lib/hash.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-04-29 11:10:29 UTC
  • mfrom: (3.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090429111029-2j5eiyokfw2bw049
Tags: 7.19.4-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop build dependencies: stunnel, libdb4.6-dev, libssh2-1-dev
  - Add build-dependency on openssh-server
  - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.
  - Call automake-1.9 with --add-missing --copy --force
* drop debian/patches/security_CVE-2009-0037.patch 
  - this patch is part of 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: hash.c,v 1.32 2007-11-07 09:21:35 bagder Exp $
 
21
 * $Id: hash.c,v 1.39 2008-10-27 05:29:17 yangtse Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
28
28
 
29
29
#include "hash.h"
30
30
#include "llist.h"
 
31
 
 
32
#define _MPRINTF_REPLACE /* use our functions only */
 
33
#include <curl/mprintf.h>
 
34
 
31
35
#include "memory.h"
32
 
 
33
 
/* this must be the last include file */
 
36
/* The last #include file should be: */
34
37
#include "memdebug.h"
35
38
 
36
39
static void
42
45
  if(e->key)
43
46
    free(e->key);
44
47
 
45
 
  h->dtor(e->ptr);
 
48
  if(e->ptr)
 
49
    h->dtor(e->ptr);
46
50
 
47
51
  free(e);
48
52
}
67
71
  h->size = 0;
68
72
  h->slots = slots;
69
73
 
70
 
  h->table = (struct curl_llist **) malloc(slots * sizeof(struct curl_llist *));
 
74
  h->table = malloc(slots * sizeof(struct curl_llist *));
71
75
  if(h->table) {
72
76
    for (i = 0; i < slots; ++i) {
73
77
      h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor);
96
100
    return NULL; /* failure */
97
101
  }
98
102
 
99
 
  h = (struct curl_hash *) malloc(sizeof(struct curl_hash));
 
103
  h = malloc(sizeof(struct curl_hash));
100
104
  if(h) {
101
105
    if(Curl_hash_init(h, slots, hfunc, comparator, dtor)) {
102
106
      /* failure */
113
117
static struct curl_hash_element *
114
118
mk_hash_element(const void *key, size_t key_len, const void *p)
115
119
{
116
 
  struct curl_hash_element *he =
117
 
    (struct curl_hash_element *) malloc(sizeof(struct curl_hash_element));
 
120
  struct curl_hash_element *he = malloc(sizeof(struct curl_hash_element));
118
121
 
119
122
  if(he) {
120
123
    void *dupkey = malloc(key_len);
233
236
 
234
237
  for (i = 0; i < h->slots; ++i) {
235
238
    Curl_llist_destroy(h->table[i], (void *) h);
 
239
    h->table[i] = NULL;
236
240
  }
237
241
 
238
242
  free(h->table);
270
274
    return;
271
275
 
272
276
  Curl_hash_clean(h);
 
277
 
273
278
  free(h);
274
279
}
275
280