From c204b3f4299cc3c3f61ebbc5c2223fa913ce5424 Mon Sep 17 00:00:00 2001 From: Chris Hall Date: Wed, 20 Jan 2010 14:18:05 +0000 Subject: Adding verify debug code for qtimers and tidied up. modified: bgpd/bgp_connection.c -- using _unset functions -- added bgp_connection_close_file modified: bgpd/bgp_connection.h modified: bgpd/bgp_fsm.c -- checked notification handling -- uses bgp_connection_close_file modified: bgpd/bgp_notification.c -- added _unset function modified: bgpd/bgp_notification.h modified: bgpd/bgp_open_state.c -- added _unset function modified: bgpd/bgp_open_state.h modified: lib/qtimers.c -- added debug _verify function modified: lib/qtimers.h modified: lib/sockunion.c -- added _unset function modified: lib/sockunion.h --- lib/sockunion.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'lib/sockunion.c') diff --git a/lib/sockunion.c b/lib/sockunion.c index d1fdb189..dbfccfb8 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -732,12 +732,63 @@ sockunion_free (union sockunion *su) } /*============================================================================== - * Clear a given sockunion -- ie zeroise it + * Sockunion reference utilities + */ + +/*------------------------------------------------------------------------------ + * Unset pointer to sockunion -- free any sockunion referenced + * + * Does nothing if there is no sockunion + */ +extern void +sockunion_unset(sockunion* p_su) +{ + if (*p_su != NULL) + XFREE(MTYPE_BGP_NOTIFY, *p_su) ; /* sets *p_su NULL */ +} ; + +/*------------------------------------------------------------------------------ + * Set pointer to sockunion (if any) + * + * Frees any existing sockunion at the destination. + * + * NB: copies the source pointer -- so must be clear about responsibility + * for the sockunion. + */ +extern void +sockunion_set(sockunion* p_dst, sockunion su) +{ + sockunion_unset(p_dst) ; + *p_dst = su ; +} + +/*------------------------------------------------------------------------------ + * Set pointer to a *copy* of the given sockunion + * + * Frees any existing sockunion at the destination. + * + * NB: copies the source pointer -- so must be clear about responsibility + * for the sockunion structure. + */ +extern void +sockunion_set_dup(sockunion* p_dst, sockunion su) +{ + sockunion_set(p_dst, sockunion_dup(su)) ; +} ; + +/*------------------------------------------------------------------------------ + * Set pointer to sockunion (if any) and unset source pointer. + * + * Frees any existing sockunion at the destination. + * + * NB: responsibility for the sockunion passes to the destination. */ extern void -sockunion_clear(union sockunion* su) +sockunion_set_mov(sockunion* p_dst, sockunion* p_src) { - memset(su, 0, sizeof(union sockunion)) ; + sockunion_unset(p_dst) ; + *p_dst = *p_src ; + *p_src = NULL ; } ; /*============================================================================== -- cgit v1.2.3