mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
tie in static memory debug callback
This commit is contained in:
@ -8077,6 +8077,10 @@ do
|
|||||||
ENABLED_STATICMEMORY=yes
|
ENABLED_STATICMEMORY=yes
|
||||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LEAN_STATIC_MEMORY"
|
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LEAN_STATIC_MEMORY"
|
||||||
;;
|
;;
|
||||||
|
debug)
|
||||||
|
ENABLED_STATICMEMORY=yes
|
||||||
|
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DEBUG_MEMORY_CALLBACK"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
AC_MSG_ERROR([Invalid choice for staticmemory.])
|
AC_MSG_ERROR([Invalid choice for staticmemory.])
|
||||||
break;;
|
break;;
|
||||||
|
@ -1865,6 +1865,38 @@ static int client_srtp_test(WOLFSSL *ssl, func_args *args)
|
|||||||
}
|
}
|
||||||
#endif /* WOLFSSL_SRTP */
|
#endif /* WOLFSSL_SRTP */
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_DEBUG_MEMORY_CALLBACK
|
||||||
|
static void ExampleDebugMemoryCb(size_t sz, int bucketSz, byte st, int type) {
|
||||||
|
switch (st) {
|
||||||
|
case WOLFSSL_DEBUG_MEMORY_ALLOC:
|
||||||
|
if (type == DYNAMIC_TYPE_IN_BUFFER) {
|
||||||
|
printf("IN BUFFER: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == DYNAMIC_TYPE_OUT_BUFFER) {
|
||||||
|
printf("OUT BUFFER: ");
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Alloc'd %d bytes using bucket size %d\n", (int)sz,
|
||||||
|
bucketSz);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WOLFSSL_DEBUG_MEMORY_FAIL:
|
||||||
|
printf("Failed when trying to allocate %d bytes\n", (int)sz);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WOLFSSL_DEBUG_MEMORY_FREE:
|
||||||
|
printf("Free'ing : %d\n", (int)sz);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WOLFSSL_DEBUG_MEMORY_INIT:
|
||||||
|
printf("Creating memory bucket of size : %d\n", bucketSz);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
||||||
{
|
{
|
||||||
@ -3045,6 +3077,9 @@ THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
|
|||||||
err_sys("unable to load static memory");
|
err_sys("unable to load static memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_DEBUG_MEMORY_CALLBACK
|
||||||
|
wolfSSL_SetDebugMemoryCb(ExampleDebugMemoryCb);
|
||||||
|
#endif
|
||||||
ctx = wolfSSL_CTX_new_ex(method(heap), heap);
|
ctx = wolfSSL_CTX_new_ex(method(heap), heap);
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
err_sys("unable to get ctx");
|
err_sys("unable to get ctx");
|
||||||
|
@ -531,9 +531,9 @@ static DebugMemoryCb DebugCb = NULL;
|
|||||||
|
|
||||||
/* Used to set a debug memory callback. Helpful in cases where
|
/* Used to set a debug memory callback. Helpful in cases where
|
||||||
* printf is not available. */
|
* printf is not available. */
|
||||||
void wolfSSL_SetDebugCallback(DebugMemoryCb in)
|
void wolfSSL_SetDebugMemoryCb(DebugMemoryCb cb)
|
||||||
{
|
{
|
||||||
DebugCb = in;
|
DebugCb = cb;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user