Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
dhcp
Commits
0cae26a7
Commit
0cae26a7
authored
Mar 06, 2000
by
Ted Lemon
Browse files
- Add reference and dereference functions to hash, so that reference-counted
objects can be cleanly hashed.
parent
5b6b5c33
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/hash.c
View file @
0cae26a7
...
...
@@ -22,20 +22,23 @@
#ifndef lint
static
char
copyright
[]
=
"$Id: hash.c,v 1.1
6
2000/0
1/26 14:55:34
mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.
\n
"
;
"$Id: hash.c,v 1.1
7
2000/0
3/06 23:15:16
mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.
\n
"
;
#endif
/* not lint */
#include
"dhcpd.h"
static
INLINE
int
do_hash
PROTO
((
const
unsigned
char
*
,
unsigned
,
unsigned
));
struct
hash_table
*
new_hash
()
struct
hash_table
*
new_hash
(
hash_reference
referencer
,
hash_dereference
dereferencer
)
{
struct
hash_table
*
rv
=
new_hash_table
(
DEFAULT_HASH_SIZE
,
MDL
);
if
(
!
rv
)
return
rv
;
memset
(
&
rv
->
buckets
[
0
],
0
,
DEFAULT_HASH_SIZE
*
sizeof
(
struct
hash_bucket
*
));
rv
->
referencer
=
referencer
;
rv
->
dereferencer
=
dereferencer
;
return
rv
;
}
...
...
@@ -62,10 +65,11 @@ void add_hash (table, name, len, pointer)
struct
hash_table
*
table
;
unsigned
len
;
const
unsigned
char
*
name
;
unsigned
char
*
pointer
;
void
*
pointer
;
{
int
hashno
;
struct
hash_bucket
*
bp
;
void
*
foo
;
if
(
!
table
)
return
;
...
...
@@ -81,7 +85,11 @@ void add_hash (table, name, len, pointer)
return
;
}
bp
->
name
=
name
;
bp
->
value
=
pointer
;
if
(
table
->
referencer
)
{
foo
=
&
bp
->
value
;
(
*
(
table
->
referencer
))
(
foo
,
pointer
,
MDL
);
}
else
bp
->
value
=
pointer
;
bp
->
next
=
table
->
buckets
[
hashno
];
bp
->
len
=
len
;
table
->
buckets
[
hashno
]
=
bp
;
...
...
@@ -94,6 +102,7 @@ void delete_hash_entry (table, name, len)
{
int
hashno
;
struct
hash_bucket
*
bp
,
*
pbp
=
(
struct
hash_bucket
*
)
0
;
void
*
foo
;
if
(
!
table
)
return
;
...
...
@@ -115,6 +124,10 @@ void delete_hash_entry (table, name, len)
}
else
{
table
->
buckets
[
hashno
]
=
bp
->
next
;
}
if
(
table
->
dereferencer
)
{
foo
=
&
bp
->
value
;
(
*
(
table
->
dereferencer
))
(
foo
,
MDL
);
}
free_hash_bucket
(
bp
,
MDL
);
break
;
}
...
...
@@ -122,7 +135,7 @@ void delete_hash_entry (table, name, len)
}
}
unsigned
char
*
hash_lookup
(
table
,
name
,
len
)
void
*
hash_lookup
(
table
,
name
,
len
)
struct
hash_table
*
table
;
const
unsigned
char
*
name
;
unsigned
len
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment