1
/***************************************************************************
3
* Project ___| | | | _ \| |
5
* | (__| |_| | _ <| |___
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2011, 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 http://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"
27
static CURLcode unit_setup(void)
32
static void unit_stop(void)
37
static void splayprint(struct Curl_tree * t, int d, char output)
39
struct Curl_tree *node;
45
splayprint(t->larger, d+1, output);
51
printf("%ld.%ld[%d]", (long)t->key.tv_sec,
52
(long)t->key.tv_usec, i);
55
for(count=0, node = t->same; node; node = node->same, count++)
60
printf(" [%d more]\n", count);
65
splayprint(t->smaller, d+1, output);
70
/* number of nodes to add to the splay tree */
73
struct Curl_tree *root;
74
struct Curl_tree nodes[NUM_NODES];
77
root = NULL; /* the empty tree */
79
for(i = 0; i < NUM_NODES; i++) {
83
key.tv_usec = (541*i)%1023;
85
nodes[i].payload = (void *)key.tv_usec; /* for simplicity */
86
root = Curl_splayinsert(key, root, &nodes[i]);
90
splayprint(root, 0, 1);
92
for(i = 0; i < NUM_NODES; i++) {
93
int rem = (i+7)%NUM_NODES;
94
printf("Tree look:\n");
95
splayprint(root, 0, 1);
96
printf("remove pointer %d, payload %ld\n", rem,
97
(long)(nodes[rem].payload));
98
rc = Curl_splayremovebyaddr(root, &nodes[rem], &root);
101
printf("remove %d failed!\n", rem);