diff options
author | Ted Lemon <source@isc.org> | 2000-05-16 23:03:49 +0000 |
---|---|---|
committer | Ted Lemon <source@isc.org> | 2000-05-16 23:03:49 +0000 |
commit | 20916cae759a24cc5c3af899e701102da70b0a33 (patch) | |
tree | edf7bc71c7dd7cf417d0af5b756692377bd398c6 /includes/omapip | |
parent | 7deff076431473fc42497582cf47df14c89533f2 (diff) | |
download | isc-dhcp-20916cae759a24cc5c3af899e701102da70b0a33.tar.gz |
- Fix all the OMAPI objects in the DHCP server and client that weren't
being correctly reference-counted.
- Make and use object-specific allocators.
- Add reference/dereference support to hash functions and to timeout
functions.
Diffstat (limited to 'includes/omapip')
-rw-r--r-- | includes/omapip/omapip.h | 64 | ||||
-rw-r--r-- | includes/omapip/omapip_p.h | 36 |
2 files changed, 77 insertions, 23 deletions
diff --git a/includes/omapip/omapip.h b/includes/omapip/omapip.h index bc48f181..289bb273 100644 --- a/includes/omapip/omapip.h +++ b/includes/omapip/omapip.h @@ -121,6 +121,9 @@ typedef struct __omapi_object_type_t { omapi_object_t *); isc_result_t (*create) (omapi_object_t **, omapi_object_t *); isc_result_t (*remove) (omapi_object_t *, omapi_object_t *); + isc_result_t (*freer) (omapi_object_t *, const char *, int); + isc_result_t (*sizer) (size_t); + size_t size; } omapi_object_type_t; #define OMAPI_OBJECT_PREAMBLE \ @@ -150,6 +153,31 @@ typedef struct { omapi_addr_t *addresses; } omapi_addr_list_t; +#define OMAPI_OBJECT_ALLOC(name, stype, type) \ +isc_result_t name##_allocate (stype **p, const char *file, int line) \ +{ \ + return omapi_object_allocate ((omapi_object_t **)p, \ + type, 0, file, line); \ +} \ + \ +isc_result_t name##_reference (stype **pptr, stype *ptr, \ + const char *file, int line) \ +{ \ + return omapi_object_reference ((omapi_object_t **)pptr, \ + (omapi_object_t *)ptr, file, line); \ +} \ + \ +isc_result_t name##_dereference (stype **ptr, const char *file, int line) \ +{ \ + return omapi_object_dereference ((omapi_object_t **)ptr, file, line); \ +} + +#define OMAPI_OBJECT_ALLOC_DECL(name, stype, type) \ +isc_result_t name##_allocate (stype **p, const char *file, int line); \ +isc_result_t name##_reference (stype **pptr, stype *ptr, \ + const char *file, int line); \ +isc_result_t name##_dereference (stype **ptr, const char *file, int line); + isc_result_t omapi_protocol_connect (omapi_object_t *, const char *, unsigned, omapi_object_t *); isc_result_t omapi_connect_list (omapi_object_t *, omapi_addr_list_t *, @@ -222,7 +250,6 @@ isc_result_t omapi_connection_put_string (omapi_object_t *, const char *); isc_result_t omapi_connection_put_handle (omapi_object_t *c, omapi_object_t *h); - isc_result_t omapi_listen (omapi_object_t *, unsigned, int); isc_result_t omapi_listen_addr (omapi_object_t *, omapi_addr_t *, int); @@ -335,7 +362,10 @@ isc_result_t omapi_object_type_register (omapi_object_type_t **, isc_result_t (*) (omapi_object_t **, omapi_object_t *), isc_result_t (*) (omapi_object_t *, - omapi_object_t *)); + omapi_object_t *), + isc_result_t (*) (omapi_object_t *, + const char *, int), + isc_result_t (*) (size_t), size_t); isc_result_t omapi_signal (omapi_object_t *, const char *, ...); isc_result_t omapi_signal_in (omapi_object_t *, const char *, ...); isc_result_t omapi_set_value (omapi_object_t *, omapi_object_t *, @@ -385,6 +415,24 @@ isc_result_t omapi_object_handle (omapi_handle_t *, omapi_object_t *); isc_result_t omapi_handle_lookup (omapi_object_t **, omapi_handle_t); isc_result_t omapi_handle_td_lookup (omapi_object_t **, omapi_typed_data_t *); +void * dmalloc (unsigned, const char *, int); +void dfree (void *, const char *, int); +#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) +void dmalloc_reuse (void *, const char *, int, int); +void dmalloc_dump_outstanding (void); +#else +#define dmalloc_reuse(x,y,l,z) +#endif +#define MDL __FILE__, __LINE__ +#if defined (DEBUG_RC_HISTORY) +void dump_rc_history (void); +#endif +isc_result_t omapi_object_allocate (omapi_object_t **, + omapi_object_type_t *, + size_t, const char *, int); +isc_result_t omapi_object_initialize (omapi_object_t *, + omapi_object_type_t *, + size_t, size_t, const char *, int); isc_result_t omapi_object_reference (omapi_object_t **, omapi_object_t *, const char *, int); isc_result_t omapi_object_dereference (omapi_object_t **, const char *, int); @@ -414,16 +462,4 @@ isc_result_t omapi_addr_list_reference (omapi_addr_list_t **, isc_result_t omapi_addr_list_dereference (omapi_addr_list_t **, const char *, int); -void * dmalloc (unsigned, const char *, int); -void dfree (void *, const char *, int); -#if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) -void dmalloc_reuse (void *, const char *, int, int); -void dmalloc_dump_outstanding (void); -#else -#define dmalloc_reuse(x,y,l,z) -#endif -#define MDL __FILE__, __LINE__ -#if defined (DEBUG_RC_HISTORY) -void dump_rc_history (void); -#endif #endif /* _OMAPIP_H_ */ diff --git a/includes/omapip/omapip_p.h b/includes/omapip/omapip_p.h index 5fd64cf4..cb9b995e 100644 --- a/includes/omapip/omapip_p.h +++ b/includes/omapip/omapip_p.h @@ -3,7 +3,7 @@ Private master include file for the OMAPI library. */ /* - * Copyright (c) 1996-1999 Internet Software Consortium. + * Copyright (c) 1996-2000 Internet Software Consortium. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -146,6 +146,12 @@ typedef struct { #include <omapip/buffer.h> +typedef struct __omapi_listener_object { + OMAPI_OBJECT_PREAMBLE; + int socket; /* Connection socket. */ + struct sockaddr_in address; +} omapi_listener_object_t; + typedef struct __omapi_connection_object { OMAPI_OBJECT_PREAMBLE; int socket; /* Connection socket. */ @@ -160,16 +166,10 @@ typedef struct __omapi_connection_object { omapi_buffer_t *inbufs; u_int32_t out_bytes; /* Bytes of output in buffers. */ omapi_buffer_t *outbufs; - omapi_object_t *listener; /* Listener that accepted this - connection, if any. */ + omapi_listener_object_t *listener; /* Listener that accepted this + connection, if any. */ } omapi_connection_object_t; -typedef struct __omapi_listener_object { - OMAPI_OBJECT_PREAMBLE; - int socket; /* Connection socket. */ - struct sockaddr_in address; -} omapi_listener_object_t; - typedef struct __omapi_io_object { OMAPI_OBJECT_PREAMBLE; struct __omapi_io_object *next; @@ -206,6 +206,24 @@ typedef struct __omapi_handle_table { #include <omapip/alloc.h> +OMAPI_OBJECT_ALLOC_DECL (omapi_protocol, omapi_protocol_object_t, + omapi_type_protocol) +OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener, + omapi_protocol_listener_object_t, + omapi_type_protocol_listener) +OMAPI_OBJECT_ALLOC_DECL (omapi_connection, + omapi_connection_object_t, omapi_type_connection) +OMAPI_OBJECT_ALLOC_DECL (omapi_listener, + omapi_listener_object_t, omapi_type_listener) +OMAPI_OBJECT_ALLOC_DECL (omapi_io, + omapi_io_object_t, omapi_type_io_object) +OMAPI_OBJECT_ALLOC_DECL (omapi_waiter, + omapi_waiter_object_t, omapi_type_waiter) +OMAPI_OBJECT_ALLOC_DECL (omapi_generic, + omapi_generic_object_t, omapi_type_generic) +OMAPI_OBJECT_ALLOC_DECL (omapi_message, + omapi_message_object_t, omapi_type_message) + extern int log_priority; extern int log_perror; extern void (*log_cleanup) (void); |