1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #include "curlcheck.h"
24 #define ENABLE_CURLX_PRINTF
29 #include "memdebug.h" /* LAST include file */
31 static struct curl_hash hash_static;
33 static void mydtor(void *p)
39 static CURLcode unit_setup(void)
41 return Curl_hash_init(&hash_static, 7, Curl_hash_str,
42 Curl_str_key_compare, mydtor);
45 static void unit_stop(void)
47 Curl_hash_destroy(&hash_static);
54 size_t klen = sizeof(int);
60 value = malloc(sizeof(int));
61 abort_unless(value != NULL, "Out of memory");
63 nodep = Curl_hash_add(&hash_static, &key, klen, value);
66 abort_unless(nodep, "insertion into hash failed");
67 Curl_hash_clean(&hash_static);
69 /* Attempt to add another key/value pair */
70 value2 = malloc(sizeof(int));
71 abort_unless(value2 != NULL, "Out of memory");
73 nodep = Curl_hash_add(&hash_static, &key2, klen, value2);
76 abort_unless(nodep, "insertion into hash failed");