summaryrefslogtreecommitdiff
path: root/source3/lib/snprintf.c
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2003-04-14 05:16:47 +0000
committerMartin Pool <mbp@samba.org>2003-04-14 05:16:47 +0000
commit9a5a49e5dd84003dbffb905078ff7a7b1c8f2d06 (patch)
tree1134a53b62b71118af96b07360bfce3a51c4a7bc /source3/lib/snprintf.c
parent4e56dea50c5b99655b58288e8fc570a00b7d1b2d (diff)
downloadsamba-9a5a49e5dd84003dbffb905078ff7a7b1c8f2d06.tar.gz
samba-9a5a49e5dd84003dbffb905078ff7a7b1c8f2d06.tar.bz2
samba-9a5a49e5dd84003dbffb905078ff7a7b1c8f2d06.zip
Remove SAFE_FREE() definition, which is not needed in this file.
In TEST_SNPRINTF mode, always compile all the functions in this file even if they're normally available on this system. Fix typo in comment. (This used to be commit 95f4b5828862155407069fc4dc1b879b45588ded)
Diffstat (limited to 'source3/lib/snprintf.c')
-rw-r--r--source3/lib/snprintf.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/source3/lib/snprintf.c b/source3/lib/snprintf.c
index 8bdf014faa..588e9cf6cb 100644
--- a/source3/lib/snprintf.c
+++ b/source3/lib/snprintf.c
@@ -78,20 +78,30 @@
* Thanks to Ollie Oldham <ollie.oldham@metro-optix.com> for spotting it.
* few mods to make it easier to compile the tests.
* addedd the "Ollie" test to the floating point ones.
+ *
+ * Martin Pool (mbp@samba.org) April 2003
+ * Remove NO_CONFIG_H so that the test case can be built within a source
+ * tree with less trouble.
+ * Remove unnecessary SAFE_FREE() definition.
**************************************************************/
-#ifndef NO_CONFIG_H /* for some tests */
+#ifndef NO_CONFIG_H
#include "config.h"
#else
#define NULL 0
-#endif
-
-/* TODO: Perhaps always include config.h, but strip out the macros for
- * snprintf() etc when in test mode? */
+#endif
#ifdef TEST_SNPRINTF /* need math library headers for testing */
-#include <math.h>
-#endif
+
+/* In test mode, we pretend that this system doesn't have any snprintf
+ * functions, regardless of what config.h says. */
+# undef HAVE_SNPRINTF
+# undef HAVE_VSNPRINTF
+# undef HAVE_C99_VSNPRINTF
+# undef HAVE_ASPRINTF
+# undef HAVE_VASPRINTF
+# include <math.h>
+#endif /* TEST_SNPRINTF */
#ifdef HAVE_STRING_H
#include <string.h>
@@ -128,11 +138,6 @@
#define LLONG long
#endif
-/* free memory if the pointer is valid and zero the pointer */
-#ifndef SAFE_FREE
-#define SAFE_FREE(x) do { if ((x) != NULL) {free((x)); (x)=NULL;} } while(0)
-#endif
-
#ifndef VA_COPY
#ifdef HAVE_VA_COPY
#define VA_COPY(dest, src) __va_copy(dest, src)
@@ -1004,4 +1009,4 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
return 0;
}
-#endif /* SNPRINTF_TEST */
+#endif /* TEST_SNPRINTF */