vendor/libmcrypt/libmcrypt-2.5.8/modules/modes/ctr.c
int _init_mcrypt( CTR_BUFFER* buf, void *key, int lenofkey, void *IV, int size)
{
    buf->c_counter = buf->enc_counter = NULL;
    
/* For ctr */
    buf->c_counter_pos = 0;
    buf->blocksize = size;

	buf->c_counter=calloc( 1, size);
    if (buf->c_counter==NULL) goto freeall;

	buf->enc_counter=calloc( 1, size);
    if (buf->enc_counter==NULL) goto freeall;
    
    if (IV!=NULL) {
	memcpy(buf->enc_counter, IV, size);
	memcpy(buf->c_counter, IV, size);
    }

/* End ctr */

	return 0;
	freeall:
		free(buf->c_counter);
		free(buf->enc_counter);
		return -1;
}
/* size holds the size of the IV (counter in this mode).
 * This is the block size.
 */
size holds the size of the IV (counter in this mode).
This is the block size.
size holds the size of the IV ( counter in this mode ) . This is the block size .
int _init_mcrypt( CTR_BUFFER* buf, void *key, int lenofkey, void *IV, int size)
{
    buf->c_counter = buf->enc_counter = NULL;
    buf->c_counter_pos = 0;
    buf->blocksize = size;
	buf->c_counter=calloc( 1, size);
    if (buf->c_counter==NULL) goto freeall;
	buf->enc_counter=calloc( 1, size);
    if (buf->enc_counter==NULL) goto freeall;
    if (IV!=NULL) {
	memcpy(buf->enc_counter, IV, size);
	memcpy(buf->c_counter, IV, size);
    }
	return 0;
	freeall:
		free(buf->c_counter);
		free(buf->enc_counter);
		return -1;
}
int _init_mcrypt ( CTR_BUFFER * buf , void * key , int lenofkey , void * IV , int size ) { buf -> c_counter = buf -> enc_counter = NULL ; buf -> c_counter_pos = 0 ; buf -> blocksize = size ; buf -> c_counter = calloc ( 1 , size ) ; if ( buf -> c_counter == NULL ) goto freeall ; buf -> enc_counter = calloc ( 1 , size ) ; if ( buf -> enc_counter == NULL ) goto freeall ; if ( IV != NULL ) { memcpy ( buf -> enc_counter , IV , size ) ; memcpy ( buf -> c_counter , IV , size ) ; } return 0 ; freeall : free ( buf -> c_counter ) ; free ( buf -> enc_counter ) ; return -1 ; }
size holds the size of the IV (counter in this mode).
size holds the size of the IV ( counter in this mode ) .
/* For ctr */ /* End ctr */