unit1602.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
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.
13  *
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.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  ***************************************************************************/
22 #include "curlcheck.h"
23 
24 #define ENABLE_CURLX_PRINTF
25 #include "curlx.h"
26 
27 #include "hash.h"
28 
29 #include "memdebug.h" /* LAST include file */
30 
31 static struct curl_hash hash_static;
32 
33 static void mydtor(void *p)
34 {
35  int *ptr = (int *)p;
36  free(ptr);
37 }
38 
39 static CURLcode unit_setup(void)
40 {
43 }
44 
45 static void unit_stop(void)
46 {
48 }
49 
51  int *value;
52  int *value2;
53  int *nodep;
54  size_t klen = sizeof(int);
55 
56  int key = 20;
57  int key2 = 25;
58 
59 
60  value = malloc(sizeof(int));
61  abort_unless(value != NULL, "Out of memory");
62  *value = 199;
64  if(!nodep)
65  free(value);
66  abort_unless(nodep, "insertion into hash failed");
68 
69  /* Attempt to add another key/value pair */
70  value2 = malloc(sizeof(int));
71  abort_unless(value2 != NULL, "Out of memory");
72  *value2 = 204;
74  if(!nodep)
75  free(value2);
76  abort_unless(nodep, "insertion into hash failed");
77 
#define free(ptr)
Definition: curl_memory.h:130
Definition: hash.h:46
#define UNITTEST_START
Definition: curlcheck.h:86
int Curl_hash_init(struct curl_hash *h, int slots, hash_function hfunc, comp_function comparator, curl_hash_dtor dtor)
Definition: hash.c:57
int key2
Definition: unit1602.c:57
abort_unless(value!=NULL,"Out of memory")
UNITTEST_START char * ptr
Definition: unit1330.c:38
CURLcode
Definition: curl.h:454
static struct curl_hash hash_static
Definition: unit1602.c:31
void Curl_hash_destroy(struct curl_hash *h)
Definition: hash.c:208
void Curl_hash_clean(struct curl_hash *h)
Definition: hash.c:226
int * nodep
Definition: unit1602.c:53
#define malloc(size)
Definition: curl_memory.h:124
const char ** p
Definition: unit1394.c:76
size_t klen
Definition: unit1602.c:54
static void unit_stop(void)
Definition: unit1602.c:45
size_t Curl_str_key_compare(void *k1, size_t key1_len, void *k2, size_t key2_len)
Definition: hash.c:274
static CURLcode unit_setup(void)
Definition: unit1602.c:39
#define UNITTEST_STOP
Definition: curlcheck.h:95
static void mydtor(void *p)
Definition: unit1602.c:33
UNITTEST_START int * value
Definition: unit1602.c:51
size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num)
Definition: hash.c:260
void * Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
Definition: hash.c:110
int * value2
Definition: unit1602.c:52
int key
Definition: unit1602.c:56


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:16