Cryptography Reference
In-Depth Information
with zeros. Then each individual register is returned by means of free() . Finally,
memory pointed to by registers.reg_l is released.
static void
destroy_reg_l (void)
{
unsigned i;
for (i = 0; i < registers.noofregs; i++)
{
memset (registers.reg_l[i], 0, CLINTMAXBYTE);
free (registers.reg_l[i]);
}
free (registers.reg_l);
}
Now come the public functions for register management. With the function
create_reg_l() we create a set of registers consisting of the number of individual
registers determined in NoofRegs . This takes place via a call to the private function
allocate_reg_l( ).
Allocation of a set of registers of type CLINT
Function:
int create_reg_l (void);
Syntax:
E_CLINT_OK if allocation is ok
E_CLINT_MAL if error with malloc()
Return:
int
create_reg_l (void)
{
int error = E_CLINT_OK;
if (registers.created == 0)
{
error = allocate_reg_l ();
registers.noofregs = NoofRegs;
}
if (!error)
{
++registers.created;
}
return error;
}
 
Search WWH ::




Custom Search