SOURCES: dhcp-dhcp4client.h (NEW), dhcp-libdhcp4client.patch (NEW)...

patrys patrys at pld-linux.org
Fri Dec 14 00:12:21 CET 2007


Author: patrys                       Date: Thu Dec 13 23:12:21 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- add libdhcp4client

---- Files affected:
SOURCES:
   dhcp-dhcp4client.h (NONE -> 1.1)  (NEW), dhcp-libdhcp4client.patch (NONE -> 1.1)  (NEW), dhcp-libdhcp_control.h (NONE -> 1.1)  (NEW), dhcp-options.patch (NONE -> 1.1)  (NEW), dhcp-libdhcp4client.pc (NONE -> 1.1)  (NEW), dhcp-libdhcp4client.make (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/dhcp-dhcp4client.h
diff -u /dev/null SOURCES/dhcp-dhcp4client.h:1.1
--- /dev/null	Fri Dec 14 00:12:21 2007
+++ SOURCES/dhcp-dhcp4client.h	Fri Dec 14 00:12:15 2007
@@ -0,0 +1,30 @@
+/* dhcp4client.h
+ *
+ * Interface to the ISC dhcp IPv4 client libdhcp4client library.
+ *
+ * Copyright (C) 2006  Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions of
+ * the GNU General Public License v.2, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY expressed or implied, including the implied warranties of
+ * MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE.  See the GNU General
+ * Public License for more details.  You should have received a copy of the
+ * GNU General Public License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
+ * source code or documentation are not subject to the GNU General Public
+ * License and may only be used or replicated with the express permission of
+ * Red Hat, Inc.
+ *
+ * Red Hat Author(s): Jason Vas Dias
+ *                    David Cantrell <dcantrell at redhat.com>
+ */
+
+/* include libdhcp_control.h or libdhcp.h for this */
+extern struct libdhcp_control_s;
+
+/* The ISC IPv4 DHCP client main() function */
+extern int dhcpv4_client(struct libdhcp_control_s *dhc_ctl,
+                         int argc, char **argv, char **envp);

================================================================
Index: SOURCES/dhcp-libdhcp4client.patch
diff -u /dev/null SOURCES/dhcp-libdhcp4client.patch:1.1
--- /dev/null	Fri Dec 14 00:12:21 2007
+++ SOURCES/dhcp-libdhcp4client.patch	Fri Dec 14 00:12:15 2007
@@ -0,0 +1,1092 @@
+diff -up dhcp-3.1.0/omapip/dispatch.c.libdhcp4client dhcp-3.1.0/omapip/dispatch.c
+--- dhcp-3.1.0/omapip/dispatch.c.libdhcp4client	2005-03-17 15:15:21.000000000 -0500
++++ dhcp-3.1.0/omapip/dispatch.c	2007-10-24 14:55:56.000000000 -0400
+@@ -34,7 +34,7 @@
+ 
+ #include <omapip/omapip_p.h>
+ 
+-static omapi_io_object_t omapi_io_states;
++omapi_io_object_t omapi_io_states;
+ TIME cur_time;
+ 
+ OMAPI_OBJECT_ALLOC (omapi_io,
+diff -up dhcp-3.1.0/omapip/errwarn.c.libdhcp4client dhcp-3.1.0/omapip/errwarn.c
+--- dhcp-3.1.0/omapip/errwarn.c.libdhcp4client	2007-10-24 14:55:56.000000000 -0400
++++ dhcp-3.1.0/omapip/errwarn.c	2007-10-24 14:57:16.000000000 -0400
+@@ -39,6 +39,11 @@ static char copyright[] =
+ #include <omapip/omapip_p.h>
+ #include <errno.h>
+ 
++#ifdef LIBDHCP
++#include <isc-dhcp/libdhcp_control.h>
++extern LIBDHCP_Control *libdhcp_control;
++#endif
++
+ #ifdef DEBUG
+ int log_perror = -1;
+ #else
+@@ -48,7 +53,9 @@ int log_priority;
+ void (*log_cleanup) (void);
+ 
+ #define CVT_BUF_MAX 1023
++#ifndef LIBDHCP
+ static char mbuf [CVT_BUF_MAX + 1];
++#endif
+ static char fbuf [CVT_BUF_MAX + 1];
+ 
+ /* Log an error message, then exit... */
+@@ -58,6 +65,16 @@ void log_fatal (const char * fmt, ... )
+   va_list list;
+ 
+   do_percentm (fbuf, fmt);
++  
++#ifdef LIBDHCP
++  if (libdhcp_control && (libdhcp_control->eh)) {
++      va_start (list, fmt);
++      libdhcp_control->eh(libdhcp_control, LOG_FATAL, fbuf, list);
++      va_end(list);
++      libdhcp_control->finished = 1;
++      return;
++  }
++#else
+ 
+   /* %Audit% This is log output. %2004.06.17,Safe%
+    * If we truncate we hope the user can get a hint from the log.
+@@ -91,6 +108,7 @@ void log_fatal (const char * fmt, ... )
+   if (log_cleanup)
+ 	  (*log_cleanup) ();
+   exit (1);
++#endif
+ }
+ 
+ /* Log an error message... */
+@@ -101,6 +119,13 @@ int log_error (const char * fmt, ...)
+ 
+   do_percentm (fbuf, fmt);
+ 
++#ifdef LIBDHCP
++  if (libdhcp_control && libdhcp_control->eh) {
++      va_start (list, fmt);
++      libdhcp_control->eh(libdhcp_control, LOG_ERR, fbuf, list);
++      va_end(list);
++  }
++#else
+   /* %Audit% This is log output. %2004.06.17,Safe%
+    * If we truncate we hope the user can get a hint from the log.
+    */
+@@ -116,7 +141,7 @@ int log_error (const char * fmt, ...)
+ 	  write (STDERR_FILENO, mbuf, strlen (mbuf));
+ 	  write (STDERR_FILENO, "\n", 1);
+   }
+-
++#endif
+   return 0;
+ }
+ 
+@@ -128,6 +153,13 @@ int log_info (const char *fmt, ...)
+ 
+   do_percentm (fbuf, fmt);
+ 
++#ifdef LIBDHCP
++  if (libdhcp_control && libdhcp_control->eh) {
++      va_start (list, fmt);
++      libdhcp_control->eh(libdhcp_control, LOG_INFO, fbuf, list);
++      va_end(list);
++  }
++#else
+   /* %Audit% This is log output. %2004.06.17,Safe%
+    * If we truncate we hope the user can get a hint from the log.
+    */
+@@ -143,7 +175,7 @@ int log_info (const char *fmt, ...)
+ 	  write (STDERR_FILENO, mbuf, strlen (mbuf));
+ 	  write (STDERR_FILENO, "\n", 1);
+   }
+-
++#endif
+   return 0;
+ }
+ 
+@@ -154,7 +186,13 @@ int log_debug (const char *fmt, ...)
+   va_list list;
+ 
+   do_percentm (fbuf, fmt);
+-
++#ifdef LIBDHCP
++  if (libdhcp_control && libdhcp_control->eh) {
++      va_start (list, fmt);
++      libdhcp_control->eh(libdhcp_control, LOG_DEBUG, fbuf, list);
++      va_end(list);
++  }
++#else
+   /* %Audit% This is log output. %2004.06.17,Safe%
+    * If we truncate we hope the user can get a hint from the log.
+    */
+@@ -170,7 +208,7 @@ int log_debug (const char *fmt, ...)
+ 	  write (STDERR_FILENO, mbuf, strlen (mbuf));
+ 	  write (STDERR_FILENO, "\n", 1);
+   }
+-
++#endif
+   return 0;
+ }
+ 
+diff -up dhcp-3.1.0/omapip/alloc.c.libdhcp4client dhcp-3.1.0/omapip/alloc.c
+--- dhcp-3.1.0/omapip/alloc.c.libdhcp4client	2006-02-24 18:16:30.000000000 -0500
++++ dhcp-3.1.0/omapip/alloc.c	2007-10-24 14:55:56.000000000 -0400
+@@ -40,6 +40,33 @@ static char copyright[] =
+ 
+ #include <omapip/omapip_p.h>
+ 
++#ifdef LIBDHCP
++/* OK, we need a quick and dirty way of freeing all memory used by libdhcp. 
++   All pointers will be stored in a glibc tree on alloc, and removed on free.
++   This is not too expensive for light single-call library use.
++*/
++#include <search.h>  
++extern void tdestroy (void *root, void (*free_node)(void *nodep));
++static void *all_pointers=0L;
++static int ptr_comparator(const void *p1, const void *p2) {
++    return ((p1 == p2) ? 0 : ((p1 > p2) ? 1 : -1));
++}
++
++static void record_pointer(void *ptr) {
++    tsearch(ptr, &(all_pointers), ptr_comparator);
++}
++
++static void forget_pointer(void *ptr) {
++    tdelete(ptr, &(all_pointers), ptr_comparator);
++}
++
++void omapi_free_all_pointers(void) {
++    if (all_pointers != NULL)
++		tdestroy(all_pointers, free);
++    all_pointers = NULL;
++}
++#endif
++
+ #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
+ 		defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ struct dmalloc_preamble *dmalloc_list;
+@@ -78,7 +105,9 @@ VOIDPTR dmalloc (size, file, line)
+ 		return (VOIDPTR)0;
+ 
+ 	foo = malloc(len);
+-
++#ifdef LIBDHCP
++	record_pointer(foo);
++#endif
+ 	if (!foo)
+ 		return (VOIDPTR)0;
+ 	bar = (VOIDPTR)(foo + DMDOFFSET);
+@@ -200,6 +229,9 @@ void dfree (ptr, file, line)
+ 		     0, (unsigned char *)ptr + DMDOFFSET, 0, 1, RC_MALLOC);
+ #endif
+ 	free (ptr);
++#ifdef LIBDHCP
++	forget_pointer(ptr);
++#endif
+ }
+ 
+ #if defined (DEBUG_MEMORY_LEAKAGE) || defined (DEBUG_MALLOC_POOL) || \
+diff -up dhcp-3.1.0/configure.libdhcp4client dhcp-3.1.0/configure
+--- dhcp-3.1.0/configure.libdhcp4client	2005-03-17 15:14:55.000000000 -0500
++++ dhcp-3.1.0/configure	2007-10-24 14:55:56.000000000 -0400
+@@ -246,7 +246,7 @@ if [ ! -d $workname ]; then
+ fi
+ 
+ if [ x"$dirs" = x ]; then
+-  dirs=". client server relay common omapip dhcpctl minires dst"
++  dirs=". client server relay common omapip dhcpctl minires dst libdhcp4client"
+ fi
+ 
+ for foo in $dirs; do
+diff -up dhcp-3.1.0/dst/hmac_link.c.libdhcp4client dhcp-3.1.0/dst/hmac_link.c
+--- dhcp-3.1.0/dst/hmac_link.c.libdhcp4client	2001-02-22 02:22:08.000000000 -0500
++++ dhcp-3.1.0/dst/hmac_link.c	2007-10-24 14:55:56.000000000 -0400
+@@ -38,6 +38,10 @@ static const char rcsid[] = "$Header: /p
+ 
+ #include "dst_internal.h"
+ 
++#ifdef LIBDHCP
++extern void* dmalloc(size_t,char *,int);
++#endif
++
+ #ifdef USE_MD5
+ # include "md5.h"
+ # ifndef _MD5_H_
+@@ -86,7 +90,11 @@ dst_hmac_md5_sign(const int mode, DST_KE
+ 	MD5_CTX *ctx = NULL;
+ 
+ 	if (mode & SIG_MODE_INIT) 
++#ifdef LIBDHCP
++		ctx = (MD5_CTX *) dmalloc(sizeof(*ctx),__FILE__,__LINE__);
++#else
+ 		ctx = (MD5_CTX *) malloc(sizeof(*ctx));
++#endif
+ 	else if (context)
+ 		ctx = (MD5_CTX *) *context;
+ 	if (ctx == NULL) 
+@@ -153,7 +161,11 @@ dst_hmac_md5_verify(const int mode, DST_
+ 	MD5_CTX *ctx = NULL;
+ 
+ 	if (mode & SIG_MODE_INIT) 
++#ifdef LIBDHCP
++		ctx = (MD5_CTX *) dmalloc(sizeof(*ctx),__FILE__,__LINE__);
++#else
+ 		ctx = (MD5_CTX *) malloc(sizeof(*ctx));
++#endif
+ 	else if (context)
+ 		ctx = (MD5_CTX *) *context;
+ 	if (ctx == NULL) 
+@@ -217,8 +229,11 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, co
+ 
+ 	if (dkey == NULL || key == NULL || keylen < 0)
+ 		return (-1);
+-
++#ifdef  LIBDHCP
++	if ((hkey = (HMAC_Key *) dmalloc(sizeof(HMAC_Key),__FILE__,__LINE__)) == NULL)
++#else
+ 	if ((hkey = (HMAC_Key *) malloc(sizeof(HMAC_Key))) == NULL)
++#endif
+ 		  return (-2);
+ 
+ 	memset(hkey->hk_ipad, 0, sizeof(hkey->hk_ipad));
+@@ -347,7 +362,11 @@ dst_hmac_md5_key_from_file_format(DST_KE
+ 	if (eol == NULL)
+ 		return (-4);
+ 	len = eol - p;
++#ifdef LIBDHCP
++	tmp = dmalloc(len + 2,__FILE__,__LINE__);
++#else
+ 	tmp = malloc(len + 2);
++#endif
+ 	memcpy(tmp, p, len);
+ 	*(tmp + len) = 0x0;
+ 	key_len = b64_pton((char *)tmp, key, HMAC_LEN+1);	/* see above */
+@@ -439,8 +458,11 @@ dst_hmac_md5_generate_key(DST_KEY *key, 
+ 		return(0);
+ 	
+ 	len = size > 64 ? 64 : size;
++#ifdef LIBDHCP
++	buff = dmalloc(len+8,__FILE__,__LINE__);
++#else
+ 	buff = malloc(len+8);
+-
++#endif
+ 	n = dst_random(DST_RAND_SEMI, len, buff);
+ 	n += dst_random(DST_RAND_KEY, len, buff);
+ 	if (n <= len) {	/* failed getting anything */
+@@ -463,7 +485,11 @@ dst_hmac_md5_init()
+ {
+ 	if (dst_t_func[KEY_HMAC_MD5] != NULL)
+ 		return (1);
++#ifdef LIBDHCP
++	dst_t_func[KEY_HMAC_MD5] = dmalloc(sizeof(struct dst_func),__FILE__,__LINE__);
++#else
+ 	dst_t_func[KEY_HMAC_MD5] = malloc(sizeof(struct dst_func));
++#endif
+ 	if (dst_t_func[KEY_HMAC_MD5] == NULL)
+ 		return (0);
+ 	memset(dst_t_func[KEY_HMAC_MD5], 0, sizeof(struct dst_func));
+diff -up dhcp-3.1.0/common/discover.c.libdhcp4client dhcp-3.1.0/common/discover.c
+--- dhcp-3.1.0/common/discover.c.libdhcp4client	2006-11-07 18:41:39.000000000 -0500
++++ dhcp-3.1.0/common/discover.c	2007-10-24 14:55:56.000000000 -0400
+@@ -121,6 +121,10 @@ isc_result_t interface_initialize (omapi
+    register that interface with the network I/O software, figure out what
+    subnet it's on, and add it to the list of interfaces. */
+ 
++#ifdef LIBDHCP
++int have_setup_fallback = 0;
++#endif
++
+ void discover_interfaces (state)
+ 	int state;
+ {
+@@ -141,7 +145,9 @@ void discover_interfaces (state)
+ 	char *s;
+ #endif
+ 	isc_result_t status;
++#ifndef LIBDHCP
+ 	static int setup_fallback = 0;
++#endif
+ 	int wifcount = 0;
+ 
+ 	/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
+@@ -695,10 +701,17 @@ void discover_interfaces (state)
+ 		log_fatal ("Not configured to listen on any interfaces!");
+ 	}
+ 
++#ifdef LIBDHCP
++	if (!have_setup_fallback) {
++		have_setup_fallback = 1;
++		maybe_setup_fallback ();
++	}
++#else
+ 	if (!setup_fallback) {
+ 		setup_fallback = 1;
+ 		maybe_setup_fallback ();
+ 	}
++#endif
+ 
+ #if defined (HAVE_SETFD)
+ 	if (fallback_interface) {
+diff -up dhcp-3.1.0/common/tree.c.libdhcp4client dhcp-3.1.0/common/tree.c
+--- dhcp-3.1.0/common/tree.c.libdhcp4client	2007-02-14 17:41:22.000000000 -0500
++++ dhcp-3.1.0/common/tree.c	2007-10-24 14:55:56.000000000 -0400
+@@ -41,7 +41,7 @@ static char copyright[] =
+ #include <omapip/omapip_p.h>
+ #include <ctype.h>
+ 
+-struct binding_scope *global_scope;
++struct binding_scope __attribute__ ((visibility ("default"))) *global_scope;
+ 
+ static int do_host_lookup PROTO ((struct data_string *,
+ 				  struct dns_host_entry *));
+@@ -2761,6 +2761,7 @@ int evaluate_numeric_expression (result,
+    result of that evaluation.   There should never be both an expression
+    and a valid data_string. */
+ 
++__attribute__ ((visibility ("default")))
+ int evaluate_option_cache (result, packet, lease, client_state,
+ 			   in_options, cfg_options, scope, oc, file, line)
+ 	struct data_string *result;
+diff -up dhcp-3.1.0/common/options.c.libdhcp4client dhcp-3.1.0/common/options.c
+--- dhcp-3.1.0/common/options.c.libdhcp4client	2007-05-23 15:26:22.000000000 -0400
++++ dhcp-3.1.0/common/options.c	2007-10-24 14:55:56.000000000 -0400
+@@ -2501,6 +2501,7 @@ int fqdn_option_space_encapsulate (resul
+ 	return 1;
+ }
+ 
++__attribute__ ((visibility ("default")))
+ void option_space_foreach (struct packet *packet, struct lease *lease,
+ 			   struct client_state *client_state,
+ 			   struct option_state *in_options,
+diff -up dhcp-3.1.0/common/dispatch.c.libdhcp4client dhcp-3.1.0/common/dispatch.c
+--- dhcp-3.1.0/common/dispatch.c.libdhcp4client	2007-10-24 14:55:56.000000000 -0400
++++ dhcp-3.1.0/common/dispatch.c	2007-10-24 14:55:56.000000000 -0400
+@@ -39,8 +39,24 @@ static char copyright[] =
+ 
+ #include "dhcpd.h"
+ 
+-struct timeout *timeouts;
+-static struct timeout *free_timeouts;
++struct timeout {
++#ifndef LIBDHCP
++	struct timeout *next;
++#endif
++	TIME when;
++	void (*func) PROTO ((void *));
++	void *what;
++	tvref_t ref;
++	tvunref_t unref;
++};
++
++#ifdef LIBDHCP
++static struct timeout *timeouts = NULL;
++static int ntimeouts = 0;
++#else
++static struct timeout *timeouts = NULL;
++static struct timeout *free_timeouts = NULL;
++#endif
+ 
+ void set_time(TIME t)
+ {
+@@ -53,9 +69,41 @@ void set_time(TIME t)
+ 
+ struct timeval *process_outstanding_timeouts (struct timeval *tvp)
+ {
++#ifdef LIBDHCP
++	int i;
++	struct timeout t = { 0 };
++#endif
+ 	/* Call any expired timeouts, and then if there's
+ 	   still a timeout registered, time out the select
+ 	   call then. */
++#ifdef LIBDHCP
++	if (!ntimeouts)
++		return NULL;
++
++	for (i = 0; i < ntimeouts && timeouts[i].when <= cur_time;) {
++		struct timeout *new_timeouts;
++		size_t n;
++
++		memmove(&t, &timeouts[i], sizeof (t));
++
++		n = (ntimeouts - i - 1) * sizeof (t);
++		memmove(&timeouts[i+1], &timeouts[i], n);
++
++		n = --ntimeouts * sizeof (t);
++		new_timeouts = realloc(timeouts, n);
++		/* XXX broken API, no way to return error here */
++		if (new_timeouts || !n)
++			timeouts = new_timeouts;
++
++		if (t.func)
++			t.func(t.what);
++		if (t.unref)
++			t.unref(t.what, MDL);
++	}
++	if (tvp && ntimeouts) {
++		tvp->tv_sec = timeouts[0].when;
++		tvp->tv_usec = 0;
++#else
+       another:
+ 	if (timeouts) {
+ 		struct timeout *t;
+@@ -73,9 +121,15 @@ struct timeval *process_outstanding_time
+ 			tvp -> tv_sec = timeouts -> when;
+ 			tvp -> tv_usec = 0;
+ 		}
++#endif
+ 		return tvp;
++#ifdef LIBDHCP
++	}
++	return NULL;
++#else
+ 	} else
+ 		return (struct timeval *)0;
++#endif
+ }
+ 
+ /* Wait for packets to come in using select().   When one does, call
+@@ -104,13 +158,28 @@ void add_timeout (when, where, what, ref
+ 	tvref_t ref;
+ 	tvunref_t unref;
+ {
++#ifdef LIBDHCP
++	struct timeout t = {
++		.when = when,
++		.func = where,
++		.what = what,
++		.ref = ref,
++		.unref = unref
++	};
++	struct timeout *new_timeouts;
++	int i, pos = 0;
++#else
+ 	struct timeout *t, *q;
++#endif
+ 
+ 	/* See if this timeout supersedes an existing timeout. */
++#ifdef LIBDHCP
++	for (i = 0; i < ntimeouts; i++) {
++		struct timeout *q = &timeouts[i];
++#else
+ 	t = (struct timeout *)0;
+ 	for (q = timeouts; q; q = q -> next) {
+-		if ((where == NULL || q -> func == where) &&
+-		    q -> what == what) {
++		if ((where == NULL || q -> func == where) && q -> what == what) {
+ 			if (t)
+ 				t -> next = q -> next;
+ 			else
+@@ -119,7 +188,29 @@ void add_timeout (when, where, what, ref
+ 		}
+ 		t = q;
+ 	}
++#endif
+ 
++#ifdef LIBDHCP
++		/* If this one is already in the list with a different time,
++		 * remove it and re-add */
++		if ((where == NULL || q->func == where) &&
++				q->what == what) {
++			size_t n = (--ntimeouts - i) * sizeof (*q);
++			memmove(&t, q, sizeof (t));
++
++			if (n)
++				memmove(&timeouts[i], &timeouts[i+1], n);
++
++			if (ntimeouts) {
++				new_timeouts = realloc(timeouts, ntimeouts * sizeof (*q));
++				/* XXX broken API, no way to return error here */
++				if (new_timeouts)
++					timeouts = new_timeouts;
++			} else {
++				timeouts = NULL;
++			}
++			add_timeout(when, where, what, ref, unref);
++#else
+ 	/* If we didn't supersede a timeout, allocate a timeout
+ 	   structure now. */
+ 	if (!q) {
+@@ -128,7 +219,7 @@ void add_timeout (when, where, what, ref
+ 			free_timeouts = q -> next;
+ 		} else {
+ 			q = ((struct timeout *)
+-			     dmalloc (sizeof (struct timeout), MDL));
++				dmalloc (sizeof (struct timeout), MDL));
+ 			if (!q)
+ 				log_fatal ("add_timeout: no memory!");
+ 		}
+@@ -158,22 +249,76 @@ void add_timeout (when, where, what, ref
+ 		if (t -> next -> when > q -> when) {
+ 			q -> next = t -> next;
+ 			t -> next = q;
++#endif
+ 			return;
++#ifdef LIBDHCP
++		} else if (timeouts[i].when > when) {
++			pos = i;
++#endif
+ 		}
+ 	}
+ 
++#ifdef LIBDHCP
++	/* If we didn't supersede an existing timeout, then pos is set
++	 * to the timeout which will post after this one.  Insert this
++	 * one before it. */
++
++	new_timeouts = realloc(timeouts, sizeof (t) * (ntimeouts+1));
++	/* XXX broken API, no way to return error here */
++	if (new_timeouts) {
++		/* ntimeouts = 10
++		 * pos = 3;
++		 * n = 10-3 * sizeof (t) = 7 * sizeof (t) 
++		 */
++		size_t n = (ntimeouts - pos) * sizeof (t);
++
++		timeouts = new_timeouts;
++		memmove(&timeouts[pos+1], &timeouts[pos], n);
++		memmove(&timeouts[pos], &t, sizeof (t));
++		ntimeouts++;
++	}
++#else
+ 	/* End of list. */
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list