ctr_eFuse/trunk/cr_hsm_alloc.c
(no author) 577c5fc792 ツリー全体をtrunkフォルダに移動。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@176 ff987cc8-cf2f-4642-8568-d52cce064691
2010-01-12 08:55:42 +00:00

63 lines
1.1 KiB
C

/*
* my_hsm_alloc.c
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#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