aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/test5095
-rw-r--r--tests/libtest/lib509.c63
2 files changed, 16 insertions, 52 deletions
diff --git a/tests/data/test509 b/tests/data/test509
index 5de1599e1..0e0dd212b 100644
--- a/tests/data/test509
+++ b/tests/data/test509
@@ -34,10 +34,7 @@ nothing
# Verify data after the test has been "shot"
<verify>
<stdout>
-seen custom_calloc()
-seen custom_malloc()
-seen custom_realloc()
-seen custom_free()
+Callbacks were invoked!
</stdout>
</verify>
diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c
index e8e803ffc..1fb2d3445 100644
--- a/tests/libtest/lib509.c
+++ b/tests/libtest/lib509.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -34,70 +34,35 @@
* memory callbacks which should be calling 'the real thing'.
*/
-/*
-#include "memdebug.h"
-*/
-
-static int seen_malloc = 0;
-static int seen_free = 0;
-static int seen_realloc = 0;
-static int seen_strdup = 0;
-static int seen_calloc = 0;
-
-void *custom_malloc(size_t size);
-void custom_free(void *ptr);
-void *custom_realloc(void *ptr, size_t size);
-char *custom_strdup(const char *ptr);
-void *custom_calloc(size_t nmemb, size_t size);
+static int seen;
-
-void *custom_calloc(size_t nmemb, size_t size)
+static void *custom_calloc(size_t nmemb, size_t size)
{
- if(!seen_calloc) {
- printf("seen custom_calloc()\n");
- seen_calloc = 1;
- }
+ seen++;
return (calloc)(nmemb, size);
}
-void *custom_malloc(size_t size)
+static void *custom_malloc(size_t size)
{
- if(!seen_malloc && seen_calloc) {
- printf("seen custom_malloc()\n");
- seen_malloc = 1;
- }
+ seen++;
return (malloc)(size);
}
-char *custom_strdup(const char *ptr)
+static char *custom_strdup(const char *ptr)
{
- if(!seen_strdup && seen_malloc) {
- /* currently (2013.03.13), memory tracking enabled builds do not call
- the strdup callback, in this case malloc callback and memcpy are used
- instead. If some day this is changed the following printf() should be
- uncommented, and a line added to test definition.
- printf("seen custom_strdup()\n");
- */
- seen_strdup = 1;
- }
+ seen++;
return (strdup)(ptr);
}
-void *custom_realloc(void *ptr, size_t size)
+static void *custom_realloc(void *ptr, size_t size)
{
- if(!seen_realloc && seen_malloc) {
- printf("seen custom_realloc()\n");
- seen_realloc = 1;
- }
+ seen++;
return (realloc)(ptr, size);
}
-void custom_free(void *ptr)
+static void custom_free(void *ptr)
{
- if(!seen_free && seen_realloc) {
- printf("seen custom_free()\n");
- seen_free = 1;
- }
+ seen++;
(free)(ptr);
}
@@ -110,7 +75,6 @@ int test(char *URL)
CURL *curl;
int asize;
char *str = NULL;
-
(void)URL;
res = curl_global_init_mem(CURL_GLOBAL_ALL,
@@ -136,6 +100,9 @@ int test(char *URL)
asize = (int)sizeof(a);
str = curl_easy_escape(curl, (char *)a, asize); /* uses realloc() */
+ if(seen)
+ printf("Callbacks were invoked!\n");
+
test_cleanup:
if(str)