/* * my_hsm_alloc.c */ #include #include #include #include #include #include #ifdef USE_HSM #include "nfastapp.h" #include "nfutil.h" #include "cr_hsm_alloc.h" /* --------------------- */ static int alloc_counter = 0; /* --------------------- */ const NFast_MallocUpcalls my_hsm_malloc_upcalls = { my_hsm_malloc, my_hsm_realloc, my_hsm_free }; /* --------------------- */ void *my_hsm_malloc( size_t nbytes, struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ) { alloc_counter++; return malloc( nbytes ); } /* --------------------- */ void *my_hsm_realloc( void *ptr, size_t nbytes, struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ) { return realloc( ptr, nbytes ); } /* --------------------- */ void my_hsm_free( void *ptr, struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx ) { free( ptr ); alloc_counter--; } /* --------------------- */ int my_hsm_get_alloc_counter( void ) { return alloc_counter; } #endif // HSM