From: Dave Hart Date: Tue, 27 Oct 2009 21:53:59 +0000 (+0000) Subject: stub out isc/mem.c using NTP-local /include/isc/mem.h (leaving X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00dcaddfbf4fd19d9194e879a967cdf7262fcd03;p=thirdparty%2Fntp.git stub out isc/mem.c using NTP-local /include/isc/mem.h (leaving /lib/isc/include/isc/mem.h untouched). bk: 4ae76bf7uTw-L8b_x0cill-jemIRHg --- diff --git a/configure.ac b/configure.ac index 04beef61f8..02a1bb2947 100644 --- a/configure.ac +++ b/configure.ac @@ -4844,6 +4844,7 @@ AC_CONFIG_FILES(ElectricFence/Makefile) AC_CONFIG_FILES(adjtimed/Makefile) AC_CONFIG_FILES(clockstuff/Makefile) AC_CONFIG_FILES(include/Makefile) +AC_CONFIG_FILES(include/isc/Makefile) AC_CONFIG_FILES(kernel/Makefile) AC_CONFIG_FILES(kernel/sys/Makefile) AC_CONFIG_FILES(libntp/Makefile) diff --git a/include/Makefile.am b/include/Makefile.am index 289427962b..f563ba96dd 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,9 +1,10 @@ -#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies +NULL = AUTOMAKE_OPTIONS = ETAGS_ARGS = $(srcdir)/Makefile.am EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version.def -NULL= +SUBDIRS = isc + noinst_HEADERS = \ adjtime.h \ audio.h \ diff --git a/include/isc/Makefile.am b/include/isc/Makefile.am new file mode 100644 index 0000000000..14aa70813e --- /dev/null +++ b/include/isc/Makefile.am @@ -0,0 +1,7 @@ +NULL = +AUTOMAKE_OPTIONS = +ETAGS_ARGS = $(srcdir)/Makefile.am + +noinst_HEADERS = \ + mem.h \ + $(NULL) diff --git a/include/isc/mem.h b/include/isc/mem.h new file mode 100644 index 0000000000..21cbda1cee --- /dev/null +++ b/include/isc/mem.h @@ -0,0 +1,54 @@ +/* + * libntp local override of isc/mem.h to stub it out. + * + * include/isc is searched before any of the lib/isc include + * directories and should be used only for replacement NTP headers + * overriding headers of the same name under lib/isc. + * + * NOTE: this assumes the system malloc is thread-safe and does + * not use any normal lib/isc locking. + */ + +/* + * Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1997-2001 Internet Software Consortium. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: mem.h,v 1.78.120.3 2009/02/11 03:07:01 jinmei Exp $ */ + +#ifndef ISC_MEM_H +#define ISC_MEM_H 1 + +#include + +#include +#include +#include +#include +#include + +#include + + +#define isc_mem_get(c, cnt) emalloc((cnt)) +#define isc_mem_allocate(c, cnt) emalloc((cnt)) +#define isc_mem_reallocate(c, mem, cnt) erealloc((mem), (cnt)) +#define isc_mem_put(c, mem, cnt) free((mem)) +#define isc_mem_free(c, mem) free((mem)) +#define isc_mem_strdup(c, str) estrdup((str)) +#define isc_mem_attach(src, ptgt) do { *(ptgt) = (src); } while (0) +#define isc_mem_detach(c) ((void)(c)) + +#endif /* ISC_MEM_H */ diff --git a/libntp/Makefile.am b/libntp/Makefile.am index 5ec437791a..50f40c5fa9 100644 --- a/libntp/Makefile.am +++ b/libntp/Makefile.am @@ -30,7 +30,6 @@ libntp_a_SRCS = a_md5encrypt.c adjtime.c atoint.c atolfp.c atouint.c \ $(srcdir)/../lib/isc/lib.c \ $(srcdir)/../lib/isc/log.c \ $(srcdir)/../lib/isc/md5.c \ - $(srcdir)/../lib/isc/mem.c \ $(srcdir)/../lib/isc/nls/msgcat.c \ $(srcdir)/../lib/isc/unix/net.c \ $(srcdir)/../lib/isc/netaddr.c \ diff --git a/libntp/emalloc.c b/libntp/emalloc.c index 8798a31934..5c40f4ee04 100644 --- a/libntp/emalloc.c +++ b/libntp/emalloc.c @@ -19,7 +19,7 @@ erealloc( { void * mem; - mem = realloc(prev, size); + mem = realloc(prev, size ? size : 1); if (NULL == mem) { msyslog(LOG_ERR, @@ -86,7 +86,8 @@ debug_erealloc( { void * mem; - mem = _realloc_dbg(prev, size, _NORMAL_BLOCK, file, line); + mem = _realloc_dbg(prev, size ? size : 1, + _NORMAL_BLOCK, file, line); if (NULL == mem) { msyslog(LOG_ERR, diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 8f0c220a43..af46281aea 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -283,12 +283,6 @@ struct interface * inter_list; static struct interface *wildipv4 = NULL; static struct interface *wildipv6 = NULL; -/* - * allocate/free in libisc form, using emalloc/free. - */ -void * ntp_memalloc (void *, size_t); -void ntp_memfree (void *, void *); - static void add_fd_to_list (SOCKET, enum desc_type); static struct interface *find_addr_in_list (sockaddr_u *); @@ -321,30 +315,6 @@ static inline int read_refclock_packet (SOCKET, struct refclockio *, l_fp); #endif -void * -ntp_memalloc( - void * ntpcontext, - size_t octets - ) -{ - UNUSED_ARG(ntpcontext); - - return emalloc(octets); -} - - -void -ntp_memfree( - void * ntpcontext, - void * p - ) -{ - UNUSED_ARG(ntpcontext); - - free(p); -} - - #ifdef SYS_WINNT /* * Windows 2000 systems incorrectly cause UDP sockets using WASRecvFrom @@ -1546,7 +1516,7 @@ update_interfaces( void * data ) { - static isc_mem_t * mctx; + isc_mem_t * mctx = (void *)-1; interface_info_t ifi; isc_interfaceiter_t * iter; isc_result_t result; @@ -1559,12 +1529,6 @@ update_interfaces( DPRINTF(3, ("update_interfaces(%d)\n", port)); - if (NULL == mctx) { - result = isc_mem_createx(0, 0, &ntp_memalloc, - &ntp_memfree, NULL, &mctx); - NTP_INSIST(ISC_R_SUCCESS == result); - } - /* * phase one - scan interfaces * - create those that are not found diff --git a/ports/winnt/vc6/libntp.dsp b/ports/winnt/vc6/libntp.dsp index 87c1e7c266..9f1a15f008 100644 --- a/ports/winnt/vc6/libntp.dsp +++ b/ports/winnt/vc6/libntp.dsp @@ -266,10 +266,6 @@ SOURCE=..\..\..\lib\isc\md5.c # End Source File # Begin Source File -SOURCE=..\..\..\lib\isc\mem.c -# End Source File -# Begin Source File - SOURCE=..\..\..\libntp\memmove.c # End Source File # Begin Source File diff --git a/ports/winnt/vs2003/libntp.vcproj b/ports/winnt/vs2003/libntp.vcproj index d6a5e70606..e96127e1df 100644 --- a/ports/winnt/vs2003/libntp.vcproj +++ b/ports/winnt/vs2003/libntp.vcproj @@ -950,9 +950,6 @@ PreprocessorDefinitions=""/> - - + RelativePath="..\..\..\include\isc\mem.h"> diff --git a/ports/winnt/vs2005/libntp.vcproj b/ports/winnt/vs2005/libntp.vcproj index 02d3b68742..69e39edd85 100644 --- a/ports/winnt/vs2005/libntp.vcproj +++ b/ports/winnt/vs2005/libntp.vcproj @@ -1046,10 +1046,6 @@ /> - - @@ -2084,7 +2080,7 @@ > - - @@ -637,7 +633,7 @@ >