Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 103 lines (78 sloc) 2.419 kB
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* Cherokee
4 *
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 *
920e20b @alobbs Happy new year!
alobbs authored
8 * Copyright (C) 2001-2011 Alvaro Lopez Ortega
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
2c39092 @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@2660 5dc97367-9…
alobbs authored
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
23 */
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
24
25 #include "common-internal.h"
26 #include "avl_r.h"
27
28 typedef struct {
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
29 CHEROKEE_RWLOCK_T(lock);
30 int dummy;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
31 } cherokee_avl_r_priv_t;
32
33 #define AVL_R_PRIV(avl_r) ((cherokee_avl_r_priv_t *)((avl_r)->priv))
34 #define AVL_R_LOCK(avl_r) (&AVL_R_PRIV(avl_r)->lock)
35
36
37 ret_t
38 cherokee_avl_r_init (cherokee_avl_r_t *avl_r)
39 {
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
40 ret_t ret;
41 CHEROKEE_NEW_STRUCT(n, avl_r_priv);
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
42
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
43 ret = cherokee_avl_init (&avl_r->avl);
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
44 if (ret != ret_ok)
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
45 return ret;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
46
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
47 avl_r->priv = n;
48 CHEROKEE_RWLOCK_INIT (AVL_R_LOCK(avl_r), NULL);
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
49
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
50 return ret_ok;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
51 }
52
53
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
54 ret_t
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
55 cherokee_avl_r_mrproper (cherokee_avl_r_t *avl_r, cherokee_func_free_t free_func)
56 {
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
57 if (avl_r->priv) {
58 CHEROKEE_RWLOCK_DESTROY (AVL_R_LOCK(avl_r));
59 free (avl_r->priv);
60 }
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
61
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
62 return cherokee_avl_mrproper (&avl_r->avl, free_func);
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
63 }
64
65
66 ret_t
67 cherokee_avl_r_add (cherokee_avl_r_t *avl_r, cherokee_buffer_t *key, void *value)
68 {
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
69 ret_t ret;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
70
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
71 CHEROKEE_RWLOCK_WRITER (AVL_R_LOCK(avl_r));
72 ret = cherokee_avl_add (&avl_r->avl, key, value);
73 CHEROKEE_RWLOCK_UNLOCK (AVL_R_LOCK(avl_r));
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
74
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
75 return ret;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
76 }
77
78
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
79 ret_t
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
80 cherokee_avl_r_del (cherokee_avl_r_t *avl_r, cherokee_buffer_t *key, void **value)
81 {
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
82 ret_t ret;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
83
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
84 CHEROKEE_RWLOCK_WRITER (AVL_R_LOCK(avl_r));
85 ret = cherokee_avl_del (&avl_r->avl, key, value);
86 CHEROKEE_RWLOCK_UNLOCK (AVL_R_LOCK(avl_r));
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
87
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
88 return ret;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
89 }
90
91
72f6444 @alobbs Clean up: Trims trailing spaces.
alobbs authored
92 ret_t
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
93 cherokee_avl_r_get (cherokee_avl_r_t *avl_r, cherokee_buffer_t *key, void **value)
94 {
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
95 ret_t ret;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
96
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
97 CHEROKEE_RWLOCK_READER (AVL_R_LOCK(avl_r));
98 ret = cherokee_avl_get (&avl_r->avl, key, value);
99 CHEROKEE_RWLOCK_UNLOCK (AVL_R_LOCK(avl_r));
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
100
b35a69a @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@1657 5dc97367-9…
alobbs authored
101 return ret;
fcf784f @alobbs git-svn-id: svn://cherokee-project.com/cherokee/trunk@887 5dc97367-97…
alobbs authored
102 }
Something went wrong with that request. Please try again.