Allow FIPS malloc callback setting. Automatically set some callbacks
[openssl.git] / fips / utl / fips_mem.c
index 3d5c907..ff6e727 100644 (file)
@@ -72,7 +72,7 @@ static void fips_free_def(void *x)
 
 static void *(*fips_malloc_cb)(int num, const char *file, int line) =
                fips_malloc_def;
-void (*fips_free_cb)(void *) =
+static void (*fips_free_cb)(void *) =
                fips_free_def;
 
 void *FIPS_malloc(int num, const char *file, int line)
@@ -84,3 +84,11 @@ void FIPS_free(void *x)
        {
        fips_free_cb(x);
        }
+
+void FIPS_set_malloc_callbacks(
+               void *(*malloc_cb)(int num, const char *file, int line),
+               void (*free_cb)(void *))
+       {
+       fips_malloc_cb = malloc_cb;
+       fips_free_cb = free_cb;
+       }