mirror of
https://github.com/rvtr/ctr_eFuse.git
synced 2025-11-02 00:11:04 -04:00
メモリリーク対策、HSM関連のアロケータを自前で用意
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_eFuse@138 ff987cc8-cf2f-4642-8568-d52cce064691
This commit is contained in:
parent
b6844a8b69
commit
5a1ea7706f
@ -17,6 +17,10 @@
|
|||||||
|
|
||||||
/* --------------------- */
|
/* --------------------- */
|
||||||
|
|
||||||
|
static int alloc_counter = 0;
|
||||||
|
|
||||||
|
/* --------------------- */
|
||||||
|
|
||||||
const NFast_MallocUpcalls my_hsm_malloc_upcalls =
|
const NFast_MallocUpcalls my_hsm_malloc_upcalls =
|
||||||
{
|
{
|
||||||
my_hsm_malloc, my_hsm_realloc, my_hsm_free
|
my_hsm_malloc, my_hsm_realloc, my_hsm_free
|
||||||
@ -27,6 +31,7 @@ const NFast_MallocUpcalls my_hsm_malloc_upcalls =
|
|||||||
void *my_hsm_malloc( size_t nbytes,
|
void *my_hsm_malloc( size_t nbytes,
|
||||||
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx )
|
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx )
|
||||||
{
|
{
|
||||||
|
alloc_counter++;
|
||||||
return malloc( nbytes );
|
return malloc( nbytes );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,6 +49,14 @@ void my_hsm_free( void *ptr,
|
|||||||
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx )
|
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx )
|
||||||
{
|
{
|
||||||
free( ptr );
|
free( ptr );
|
||||||
|
alloc_counter--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------- */
|
||||||
|
|
||||||
|
int my_hsm_get_alloc_counter( void )
|
||||||
|
{
|
||||||
|
return alloc_counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HSM
|
#endif // HSM
|
||||||
|
|||||||
@ -22,6 +22,8 @@ void *my_hsm_realloc( void *ptr, size_t nbytes,
|
|||||||
void my_hsm_free( void *ptr,
|
void my_hsm_free( void *ptr,
|
||||||
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx );
|
struct NFast_Call_Context *cctx, struct NFast_Transaction_Context *tctx );
|
||||||
|
|
||||||
|
int my_hsm_get_alloc_counter( void );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -119,6 +119,7 @@
|
|||||||
|
|
||||||
#ifdef USE_HSM
|
#ifdef USE_HSM
|
||||||
#include "cr_hsm_code.h"
|
#include "cr_hsm_code.h"
|
||||||
|
#include "cr_hsm_alloc.h"
|
||||||
#include "cr_hsm_bignum.h"
|
#include "cr_hsm_bignum.h"
|
||||||
#include "cr_generate_id.h"
|
#include "cr_generate_id.h"
|
||||||
#include "cr_generate_id_private.h"
|
#include "cr_generate_id_private.h"
|
||||||
@ -179,7 +180,8 @@ int hsm_initialize( void )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// init HSM
|
// init HSM
|
||||||
ret_code = NFastApp_InitEx( &hsmHandle, NULL, NULL );
|
ret_code = NFastApp_Init( &hsmHandle, my_hsm_alloc, my_hsm_realloc, my_hsm_free, NULL );
|
||||||
|
//ret_code = NFastApp_InitEx( &hsmHandle, NULL, NULL );
|
||||||
if ( ret_code != CR_GENID_SUCCESS )
|
if ( ret_code != CR_GENID_SUCCESS )
|
||||||
{
|
{
|
||||||
SetErrorInfo( __FUNCTION__, __LINE__ );
|
SetErrorInfo( __FUNCTION__, __LINE__ );
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user