Cryptography Reference
In-Depth Information
registers.created in the structure registers must have been set to 1 before the
allocated memory is actually released:
void
free_reg_l (void)
{
if (registers.created == 1)
{
destroy_reg_l ();
}
if (registers.created)
{
--registers.created;
}
}
We now present three functions that create, clear, and again free individual
CLINT registers, in analogy to the management of the complete set of registers.
Function:
allocation of a register of type CLINT
clint * create_l (void);
Syntax:
Return:
pointer to allocated registers, if allocation ok
NULL if error with malloc()
clint *
create_l (void)
{
return (clint *) malloc (CLINTMAXBYTE);
}
It is important to treat the pointer returned by create_l() in such a way that
it does not “become lost,” since otherwise, it is impossible to access the created
registers. The sequence
clint * do_not_overwrite_l;
clint * lost_l;
/* ... */
do_not_overwrite _l = create_l();
/* ... */
do_not_overwrite _l = lost_l;
 
Search WWH ::




Custom Search