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
dfc7105d
Commit
dfc7105d
authored
Mar 06, 2000
by
Ted Lemon
Browse files
Add allocators/deallocators for DNS zones and TSIG keys.
parent
bdcaf7b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/alloc.c
View file @
dfc7105d
...
...
@@ -22,7 +22,7 @@
#ifndef lint
static
char
copyright
[]
=
"$Id: alloc.c,v 1.4
4
2000/0
2/15
19:3
9:21
mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.
\n
"
;
"$Id: alloc.c,v 1.4
5
2000/0
3/06
19:3
7:38
mellon Exp $ Copyright (c) 1995, 1996, 1998 The Internet Software Consortium. All rights reserved.
\n
"
;
#endif
/* not lint */
#include
"dhcpd.h"
...
...
@@ -1080,6 +1080,176 @@ int packet_dereference (ptr, file, line)
return
1
;
}
int
tsig_key_allocate
(
ptr
,
file
,
line
)
struct
tsig_key
**
ptr
;
const
char
*
file
;
int
line
;
{
int
size
;
if
(
!
ptr
)
{
log_error
(
"%s(%d): null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
return
0
;
#endif
}
if
(
*
ptr
)
{
log_error
(
"%s(%d): non-null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
*
ptr
=
(
struct
tsig_key
*
)
0
;
#endif
}
*
ptr
=
dmalloc
(
sizeof
**
ptr
,
file
,
line
);
if
(
*
ptr
)
{
memset
(
*
ptr
,
0
,
sizeof
**
ptr
);
(
*
ptr
)
->
refcnt
=
1
;
return
1
;
}
return
0
;
}
int
tsig_key_reference
(
ptr
,
bp
,
file
,
line
)
struct
tsig_key
**
ptr
;
struct
tsig_key
*
bp
;
const
char
*
file
;
int
line
;
{
if
(
!
ptr
)
{
log_error
(
"%s(%d): null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
return
0
;
#endif
}
if
(
*
ptr
)
{
log_error
(
"%s(%d): non-null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
*
ptr
=
(
struct
tsig_key
*
)
0
;
#endif
}
*
ptr
=
bp
;
bp
->
refcnt
++
;
rc_register
(
file
,
line
,
ptr
,
bp
,
bp
->
refcnt
);
dmalloc_reuse
(
bp
,
file
,
line
,
1
);
return
1
;
}
int
tsig_key_dereference
(
ptr
,
file
,
line
)
struct
tsig_key
**
ptr
;
const
char
*
file
;
int
line
;
{
int
i
;
struct
tsig_key
*
tsig_key
;
if
(
!
ptr
||
!*
ptr
)
{
log_error
(
"%s(%d): null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
return
0
;
#endif
}
tsig_key
=
*
ptr
;
*
ptr
=
(
struct
tsig_key
*
)
0
;
--
tsig_key
->
refcnt
;
rc_register
(
file
,
line
,
ptr
,
tsig_key
,
tsig_key
->
refcnt
);
if
(
tsig_key
->
refcnt
>
0
)
return
1
;
if
(
tsig_key
->
refcnt
<
0
)
{
log_error
(
"%s(%d): negative refcnt!"
,
file
,
line
);
#if defined (DEBUG_RC_HISTORY)
dump_rc_history
();
#endif
#if defined (POINTER_DEBUG)
abort
();
#else
return
0
;
#endif
}
if
(
tsig_key
->
name
)
dfree
(
tsig_key
->
name
,
file
,
line
);
if
(
tsig_key
->
algorithm
)
dfree
(
tsig_key
->
algorithm
,
file
,
line
);
if
(
tsig_key
->
key
.
buffer
)
data_string_forget
(
&
tsig_key
->
key
,
file
,
line
);
dfree
(
tsig_key
,
file
,
line
);
return
1
;
}
int
dns_zone_allocate
(
ptr
,
file
,
line
)
struct
dns_zone
**
ptr
;
const
char
*
file
;
int
line
;
{
int
size
;
if
(
!
ptr
)
{
log_error
(
"%s(%d): null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
return
0
;
#endif
}
if
(
*
ptr
)
{
log_error
(
"%s(%d): non-null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
*
ptr
=
(
struct
dns_zone
*
)
0
;
#endif
}
*
ptr
=
dmalloc
(
sizeof
**
ptr
,
file
,
line
);
if
(
*
ptr
)
{
memset
(
*
ptr
,
0
,
sizeof
**
ptr
);
(
*
ptr
)
->
refcnt
=
1
;
return
1
;
}
return
0
;
}
int
dns_zone_reference
(
ptr
,
bp
,
file
,
line
)
struct
dns_zone
**
ptr
;
struct
dns_zone
*
bp
;
const
char
*
file
;
int
line
;
{
if
(
!
ptr
)
{
log_error
(
"%s(%d): null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
return
0
;
#endif
}
if
(
*
ptr
)
{
log_error
(
"%s(%d): non-null pointer"
,
file
,
line
);
#if defined (POINTER_DEBUG)
abort
();
#else
*
ptr
=
(
struct
dns_zone
*
)
0
;
#endif
}
*
ptr
=
bp
;
bp
->
refcnt
++
;
rc_register
(
file
,
line
,
ptr
,
bp
,
bp
->
refcnt
);
dmalloc_reuse
(
bp
,
file
,
line
,
1
);
return
1
;
}
int
binding_scope_allocate
(
ptr
,
file
,
line
)
struct
binding_scope
**
ptr
;
const
char
*
file
;
...
...
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