[trunk] improve memory management (fixes issue 359)
This commit is contained in:
parent
b0072bf658
commit
50a205d20f
|
@ -2988,10 +2988,13 @@ static opj_image_t* rawtoimage_common(const char *filename, opj_cparameters_t *p
|
|||
}
|
||||
w = raw_cp->rawWidth;
|
||||
h = raw_cp->rawHeight;
|
||||
cmptparm = (opj_image_cmptparm_t*) malloc((size_t)numcomps * sizeof(opj_image_cmptparm_t));
|
||||
|
||||
cmptparm = (opj_image_cmptparm_t*) calloc(numcomps,sizeof(opj_image_cmptparm_t));
|
||||
if (!cmptparm) {
|
||||
fprintf(stderr, "Failed to allocate image components parameters !!\n");
|
||||
fprintf(stderr,"Aborting\n");
|
||||
return NULL;
|
||||
}
|
||||
/* initialize image components */
|
||||
memset(&cmptparm[0], 0, (size_t)numcomps * sizeof(opj_image_cmptparm_t));
|
||||
for(i = 0; i < numcomps; i++) {
|
||||
cmptparm[i].prec = (OPJ_UINT32)raw_cp->rawBitDepth;
|
||||
cmptparm[i].bpp = (OPJ_UINT32)raw_cp->rawBitDepth;
|
||||
|
|
|
@ -1786,8 +1786,7 @@ int main(int argc, char **argv) {
|
|||
if( bSuccess && bUseTiles ) {
|
||||
OPJ_BYTE *l_data;
|
||||
OPJ_UINT32 l_data_size = 512*512*3;
|
||||
l_data = (OPJ_BYTE*) malloc( l_data_size * sizeof(OPJ_BYTE));
|
||||
memset(l_data, 0, l_data_size );
|
||||
l_data = (OPJ_BYTE*) calloc( 1,l_data_size);
|
||||
assert( l_data );
|
||||
for (i=0;i<l_nb_tiles;++i) {
|
||||
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
|
||||
|
|
|
@ -151,12 +151,11 @@ void opj_read_float_LE(const OPJ_BYTE * p_buffer, OPJ_FLOAT32 * p_value)
|
|||
opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,OPJ_BOOL l_is_input)
|
||||
{
|
||||
opj_stream_private_t * l_stream = 00;
|
||||
l_stream = (opj_stream_private_t*) opj_malloc(sizeof(opj_stream_private_t));
|
||||
l_stream = (opj_stream_private_t*) opj_calloc(1,sizeof(opj_stream_private_t));
|
||||
if (! l_stream) {
|
||||
return 00;
|
||||
}
|
||||
|
||||
memset(l_stream,0,sizeof(opj_stream_private_t));
|
||||
l_stream->m_buffer_size = p_buffer_size;
|
||||
l_stream->m_stored_data = (OPJ_BYTE *) opj_malloc(p_buffer_size);
|
||||
if (! l_stream->m_stored_data) {
|
||||
|
|
|
@ -39,22 +39,19 @@
|
|||
opj_procedure_list_t * opj_procedure_list_create()
|
||||
{
|
||||
/* memory allocation */
|
||||
opj_procedure_list_t * l_validation = (opj_procedure_list_t *) opj_malloc(sizeof(opj_procedure_list_t));
|
||||
opj_procedure_list_t * l_validation = (opj_procedure_list_t *) opj_calloc(1,sizeof(opj_procedure_list_t));
|
||||
if (! l_validation)
|
||||
{
|
||||
return 00;
|
||||
}
|
||||
/* initialization */
|
||||
memset(l_validation,0,sizeof(opj_procedure_list_t));
|
||||
l_validation->m_nb_max_procedures = OPJ_VALIDATION_SIZE;
|
||||
l_validation->m_procedures = (opj_procedure*)opj_malloc(
|
||||
OPJ_VALIDATION_SIZE * sizeof(opj_procedure));
|
||||
l_validation->m_procedures = (opj_procedure*)opj_calloc(OPJ_VALIDATION_SIZE, sizeof(opj_procedure));
|
||||
if (! l_validation->m_procedures)
|
||||
{
|
||||
opj_free(l_validation);
|
||||
return 00;
|
||||
}
|
||||
memset(l_validation->m_procedures,0,OPJ_VALIDATION_SIZE * sizeof(opj_procedure));
|
||||
return l_validation;
|
||||
}
|
||||
|
||||
|
|
|
@ -205,21 +205,19 @@ opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, opj_image_c
|
|||
OPJ_UINT32 compno;
|
||||
opj_image_t *image = 00;
|
||||
|
||||
image = (opj_image_t*) opj_malloc(sizeof(opj_image_t));
|
||||
image = (opj_image_t*) opj_calloc(1,sizeof(opj_image_t));
|
||||
if (image)
|
||||
{
|
||||
memset(image,0,sizeof(opj_image_t));
|
||||
|
||||
image->color_space = clrspc;
|
||||
image->numcomps = numcmpts;
|
||||
|
||||
/* allocate memory for the per-component information */
|
||||
image->comps = (opj_image_comp_t*)opj_malloc(image->numcomps * sizeof(opj_image_comp_t));
|
||||
image->comps = (opj_image_comp_t*)opj_calloc(image->numcomps, sizeof(opj_image_comp_t));
|
||||
if (!image->comps) {
|
||||
opj_image_destroy(image);
|
||||
return 00;
|
||||
}
|
||||
memset(image->comps,0,image->numcomps * sizeof(opj_image_comp_t));
|
||||
|
||||
/* create the individual image components */
|
||||
for(compno = 0; compno < numcmpts; compno++) {
|
||||
|
|
|
@ -1499,7 +1499,6 @@ OPJ_BOOL opj_j2k_check_poc_val( const opj_poc_t *p_pocs,
|
|||
opj_event_msg(p_manager , EVT_ERROR, "Not enough memory for checking the poc values.\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(packet_array,0,step_l * p_num_layers* sizeof(OPJ_UINT32));
|
||||
|
||||
if (p_nb_pocs == 0) {
|
||||
opj_free(packet_array);
|
||||
|
@ -2038,7 +2037,6 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
|||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
memset(l_image->comps,0,l_image->numcomps * sizeof(opj_image_comp_t));
|
||||
l_img_comp = l_image->comps;
|
||||
|
||||
/* Read the component information */
|
||||
|
@ -2167,7 +2165,6 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
|||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(l_cp->tcps,0,l_nb_tiles*sizeof(opj_tcp_t));
|
||||
|
||||
#ifdef USE_JPWL
|
||||
if (l_cp->correct) {
|
||||
|
@ -2188,27 +2185,24 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
|||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps ,0,l_image->numcomps*sizeof(opj_tccp_t));
|
||||
|
||||
p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records =
|
||||
(opj_mct_data_t*)opj_malloc(OPJ_J2K_MCT_DEFAULT_NB_RECORDS * sizeof(opj_mct_data_t));
|
||||
(opj_mct_data_t*)opj_calloc(OPJ_J2K_MCT_DEFAULT_NB_RECORDS ,sizeof(opj_mct_data_t));
|
||||
|
||||
if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records,0,OPJ_J2K_MCT_DEFAULT_NB_RECORDS * sizeof(opj_mct_data_t));
|
||||
p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mct_records = OPJ_J2K_MCT_DEFAULT_NB_RECORDS;
|
||||
|
||||
p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records =
|
||||
(opj_simple_mcc_decorrelation_data_t*)
|
||||
opj_malloc(OPJ_J2K_MCC_DEFAULT_NB_RECORDS * sizeof(opj_simple_mcc_decorrelation_data_t));
|
||||
opj_calloc(OPJ_J2K_MCC_DEFAULT_NB_RECORDS, sizeof(opj_simple_mcc_decorrelation_data_t));
|
||||
|
||||
if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records,0,OPJ_J2K_MCC_DEFAULT_NB_RECORDS * sizeof(opj_simple_mcc_decorrelation_data_t));
|
||||
p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mcc_records = OPJ_J2K_MCC_DEFAULT_NB_RECORDS;
|
||||
|
||||
/* set up default dc level shift */
|
||||
|
@ -2220,12 +2214,11 @@ static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
|
|||
|
||||
l_current_tile_param = l_cp->tcps;
|
||||
for (i = 0; i < l_nb_tiles; ++i) {
|
||||
l_current_tile_param->tccps = (opj_tccp_t*) opj_malloc(l_image->numcomps * sizeof(opj_tccp_t));
|
||||
l_current_tile_param->tccps = (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_tccp_t));
|
||||
if (l_current_tile_param->tccps == 00) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take in charge SIZ marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(l_current_tile_param->tccps,0,l_image->numcomps * sizeof(opj_tccp_t));
|
||||
|
||||
++l_current_tile_param;
|
||||
}
|
||||
|
@ -3576,13 +3569,12 @@ OPJ_BOOL j2k_read_ppm_v3 (
|
|||
l_cp->ppm_len = l_N_ppm;
|
||||
l_cp->ppm_data_read = 0;
|
||||
|
||||
l_cp->ppm_data = (OPJ_BYTE *) opj_malloc(l_cp->ppm_len);
|
||||
l_cp->ppm_data = (OPJ_BYTE *) opj_calloc(1,l_cp->ppm_len);
|
||||
l_cp->ppm_buffer = l_cp->ppm_data;
|
||||
if (l_cp->ppm_data == 00) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to read ppm marker\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(l_cp->ppm_data,0,l_cp->ppm_len);
|
||||
|
||||
l_cp->ppm_data_current = l_cp->ppm_data;
|
||||
|
||||
|
@ -5853,12 +5845,11 @@ void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
|
|||
|
||||
opj_j2k_t* opj_j2k_create_compress(void)
|
||||
{
|
||||
opj_j2k_t *l_j2k = (opj_j2k_t*) opj_malloc(sizeof(opj_j2k_t));
|
||||
opj_j2k_t *l_j2k = (opj_j2k_t*) opj_calloc(1,sizeof(opj_j2k_t));
|
||||
if (!l_j2k) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(l_j2k,0,sizeof(opj_j2k_t));
|
||||
|
||||
l_j2k->m_is_decoder = 0;
|
||||
l_j2k->m_cp.m_is_decoder = 0;
|
||||
|
@ -8217,23 +8208,21 @@ OPJ_BOOL opj_j2k_set_decode_area( opj_j2k_t *p_j2k,
|
|||
|
||||
opj_j2k_t* opj_j2k_create_decompress(void)
|
||||
{
|
||||
opj_j2k_t *l_j2k = (opj_j2k_t*) opj_malloc(sizeof(opj_j2k_t));
|
||||
opj_j2k_t *l_j2k = (opj_j2k_t*) opj_calloc(1,sizeof(opj_j2k_t));
|
||||
if (!l_j2k) {
|
||||
return 00;
|
||||
}
|
||||
memset(l_j2k,0,sizeof(opj_j2k_t));
|
||||
|
||||
l_j2k->m_is_decoder = 1;
|
||||
l_j2k->m_cp.m_is_decoder = 1;
|
||||
|
||||
l_j2k->m_specific_param.m_decoder.m_default_tcp = (opj_tcp_t*) opj_malloc(sizeof(opj_tcp_t));
|
||||
l_j2k->m_specific_param.m_decoder.m_default_tcp = (opj_tcp_t*) opj_calloc(1,sizeof(opj_tcp_t));
|
||||
if (!l_j2k->m_specific_param.m_decoder.m_default_tcp) {
|
||||
opj_j2k_destroy(l_j2k);
|
||||
return 00;
|
||||
}
|
||||
memset(l_j2k->m_specific_param.m_decoder.m_default_tcp,0,sizeof(opj_tcp_t));
|
||||
|
||||
l_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE *) opj_malloc(OPJ_J2K_DEFAULT_HEADER_SIZE);
|
||||
l_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE *) opj_calloc(1,OPJ_J2K_DEFAULT_HEADER_SIZE);
|
||||
if (! l_j2k->m_specific_param.m_decoder.m_header_data) {
|
||||
opj_j2k_destroy(l_j2k);
|
||||
return 00;
|
||||
|
|
|
@ -537,12 +537,11 @@ OPJ_BOOL opj_jp2_read_ihdr( opj_jp2_t *jp2,
|
|||
p_image_header_data += 2;
|
||||
|
||||
/* allocate memory for components */
|
||||
jp2->comps = (opj_jp2_comps_t*) opj_malloc(jp2->numcomps * sizeof(opj_jp2_comps_t));
|
||||
jp2->comps = (opj_jp2_comps_t*) opj_calloc(jp2->numcomps, sizeof(opj_jp2_comps_t));
|
||||
if (jp2->comps == 0) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle image header (ihdr)\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(jp2->comps,0,jp2->numcomps * sizeof(opj_jp2_comps_t));
|
||||
|
||||
opj_read_bytes(p_image_header_data,&(jp2->bpc),1); /* BPC */
|
||||
++ p_image_header_data;
|
||||
|
@ -574,11 +573,10 @@ OPJ_BYTE * opj_jp2_write_ihdr(opj_jp2_t *jp2,
|
|||
assert(p_nb_bytes_written != 00);
|
||||
|
||||
/* default image header is 22 bytes wide */
|
||||
l_ihdr_data = (OPJ_BYTE *) opj_malloc(22);
|
||||
l_ihdr_data = (OPJ_BYTE *) opj_calloc(1,22);
|
||||
if (l_ihdr_data == 00) {
|
||||
return 00;
|
||||
}
|
||||
memset(l_ihdr_data,0,22);
|
||||
|
||||
l_current_ihdr_ptr = l_ihdr_data;
|
||||
|
||||
|
@ -627,11 +625,10 @@ OPJ_BYTE * opj_jp2_write_bpcc( opj_jp2_t *jp2,
|
|||
assert(jp2 != 00);
|
||||
assert(p_nb_bytes_written != 00);
|
||||
|
||||
l_bpcc_data = (OPJ_BYTE *) opj_malloc(l_bpcc_size);
|
||||
l_bpcc_data = (OPJ_BYTE *) opj_calloc(1,l_bpcc_size);
|
||||
if (l_bpcc_data == 00) {
|
||||
return 00;
|
||||
}
|
||||
memset(l_bpcc_data,0,l_bpcc_size);
|
||||
|
||||
l_current_bpcc_ptr = l_bpcc_data;
|
||||
|
||||
|
@ -709,11 +706,10 @@ OPJ_BYTE * opj_jp2_write_colr( opj_jp2_t *jp2,
|
|||
return 00;
|
||||
}
|
||||
|
||||
l_colr_data = (OPJ_BYTE *) opj_malloc(l_colr_size);
|
||||
l_colr_data = (OPJ_BYTE *) opj_calloc(1,l_colr_size);
|
||||
if (l_colr_data == 00) {
|
||||
return 00;
|
||||
}
|
||||
memset(l_colr_data,0,l_colr_size);
|
||||
|
||||
l_current_colr_ptr = l_colr_data;
|
||||
|
||||
|
@ -1255,13 +1251,12 @@ OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
|
|||
OPJ_INT32 icc_len = (OPJ_INT32)p_colr_header_size - 3;
|
||||
|
||||
jp2->color.icc_profile_len = (OPJ_UINT32)icc_len;
|
||||
jp2->color.icc_profile_buf = (OPJ_BYTE*) opj_malloc((size_t)icc_len);
|
||||
jp2->color.icc_profile_buf = (OPJ_BYTE*) opj_calloc(1,(size_t)icc_len);
|
||||
if (!jp2->color.icc_profile_buf)
|
||||
{
|
||||
jp2->color.icc_profile_len = 0;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(jp2->color.icc_profile_buf, 0, (size_t)icc_len * sizeof(OPJ_BYTE));
|
||||
|
||||
for (it_icc_value = 0; it_icc_value < icc_len; ++it_icc_value)
|
||||
{
|
||||
|
@ -1448,15 +1443,13 @@ OPJ_BOOL opj_jp2_write_ftyp(opj_jp2_t *jp2,
|
|||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
l_ftyp_data = (OPJ_BYTE *) opj_malloc(l_ftyp_size);
|
||||
l_ftyp_data = (OPJ_BYTE *) opj_calloc(1,l_ftyp_size);
|
||||
|
||||
if (l_ftyp_data == 00) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle ftyp data\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
memset(l_ftyp_data,0,l_ftyp_size);
|
||||
|
||||
l_current_data_ptr = l_ftyp_data;
|
||||
|
||||
opj_write_bytes(l_current_data_ptr, l_ftyp_size,4); /* box size */
|
||||
|
@ -1807,13 +1800,12 @@ OPJ_BOOL opj_jp2_read_header_procedure( opj_jp2_t *jp2,
|
|||
assert(jp2 != 00);
|
||||
assert(p_manager != 00);
|
||||
|
||||
l_current_data = (OPJ_BYTE*)opj_malloc(l_last_data_size);
|
||||
l_current_data = (OPJ_BYTE*)opj_calloc(1,l_last_data_size);
|
||||
|
||||
if (l_current_data == 00) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle jpeg2000 file header\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(l_current_data, 0 , l_last_data_size);
|
||||
|
||||
while (opj_jp2_read_boxhdr(&box,&l_nb_bytes_read,stream,p_manager)) {
|
||||
/* is it the codestream box ? */
|
||||
|
@ -2083,12 +2075,11 @@ static OPJ_BOOL opj_jp2_read_ftyp( opj_jp2_t *jp2,
|
|||
/* div by 4 */
|
||||
jp2->numcl = l_remaining_bytes >> 2;
|
||||
if (jp2->numcl) {
|
||||
jp2->cl = (OPJ_UINT32 *) opj_malloc(jp2->numcl * sizeof(OPJ_UINT32));
|
||||
jp2->cl = (OPJ_UINT32 *) opj_calloc(jp2->numcl, sizeof(OPJ_UINT32));
|
||||
if (jp2->cl == 00) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory with FTYP Box\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(jp2->cl,0,jp2->numcl * sizeof(OPJ_UINT32));
|
||||
}
|
||||
|
||||
for (i = 0; i < jp2->numcl; ++i)
|
||||
|
@ -2531,9 +2522,8 @@ OPJ_BOOL opj_jp2_get_tile( opj_jp2_t *p_jp2,
|
|||
|
||||
opj_jp2_t* opj_jp2_create(OPJ_BOOL p_is_decoder)
|
||||
{
|
||||
opj_jp2_t *jp2 = (opj_jp2_t*)opj_malloc(sizeof(opj_jp2_t));
|
||||
opj_jp2_t *jp2 = (opj_jp2_t*)opj_calloc(1,sizeof(opj_jp2_t));
|
||||
if (jp2) {
|
||||
memset(jp2,0,sizeof(opj_jp2_t));
|
||||
|
||||
/* create the J2K codec */
|
||||
if (! p_is_decoder) {
|
||||
|
|
|
@ -169,7 +169,6 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
|
|||
if (!l_codec){
|
||||
return 00;
|
||||
}
|
||||
memset(l_codec, 0, sizeof(opj_codec_private_t));
|
||||
|
||||
l_codec->is_decompressor = 1;
|
||||
|
||||
|
@ -546,7 +545,6 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
|
|||
if (!l_codec) {
|
||||
return 00;
|
||||
}
|
||||
memset(l_codec, 0, sizeof(opj_codec_private_t));
|
||||
|
||||
l_codec->is_decompressor = 0;
|
||||
|
||||
|
|
|
@ -815,7 +815,6 @@ opj_pi_iterator_t * opj_pi_create( const opj_image_t *image,
|
|||
if (!l_pi) {
|
||||
return NULL;
|
||||
}
|
||||
memset(l_pi,0,l_poc_bound * sizeof(opj_pi_iterator_t));
|
||||
|
||||
l_current_pi = l_pi;
|
||||
for (pino = 0; pino < l_poc_bound ; ++pino) {
|
||||
|
@ -827,21 +826,19 @@ opj_pi_iterator_t * opj_pi_create( const opj_image_t *image,
|
|||
}
|
||||
|
||||
l_current_pi->numcomps = image->numcomps;
|
||||
memset(l_current_pi->comps,0,image->numcomps * sizeof(opj_pi_comp_t));
|
||||
|
||||
for (compno = 0; compno < image->numcomps; ++compno) {
|
||||
opj_pi_comp_t *comp = &l_current_pi->comps[compno];
|
||||
|
||||
tccp = &tcp->tccps[compno];
|
||||
|
||||
comp->resolutions = (opj_pi_resolution_t*) opj_malloc(tccp->numresolutions * sizeof(opj_pi_resolution_t));
|
||||
comp->resolutions = (opj_pi_resolution_t*) opj_calloc(tccp->numresolutions, sizeof(opj_pi_resolution_t));
|
||||
if (!comp->resolutions) {
|
||||
opj_pi_destroy(l_pi, l_poc_bound);
|
||||
return 00;
|
||||
}
|
||||
|
||||
comp->numresolutions = tccp->numresolutions;
|
||||
memset(comp->resolutions,0,tccp->numresolutions * sizeof(opj_pi_resolution_t));
|
||||
}
|
||||
++l_current_pi;
|
||||
}
|
||||
|
@ -1242,7 +1239,6 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
|
|||
opj_pi_destroy(l_pi, l_bound);
|
||||
return 00;
|
||||
}
|
||||
memset(l_current_pi->include,0, (l_tcp->numlayers + 1) * l_step_l* sizeof(OPJ_INT16));
|
||||
|
||||
/* special treatment for the first packet iterator */
|
||||
l_current_comp = l_current_pi->comps;
|
||||
|
@ -1439,7 +1435,6 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
|
|||
opj_pi_destroy(l_pi, l_bound);
|
||||
return 00;
|
||||
}
|
||||
memset(l_current_pi->include,0,l_tcp->numlayers * l_step_l* sizeof(OPJ_INT16));
|
||||
|
||||
/* special treatment for the first packet iterator*/
|
||||
l_current_comp = l_current_pi->comps;
|
||||
|
|
|
@ -1207,11 +1207,10 @@ opj_t1_t* opj_t1_create()
|
|||
{
|
||||
opj_t1_t *l_t1 = 00;
|
||||
|
||||
l_t1 = (opj_t1_t*) opj_malloc(sizeof(opj_t1_t));
|
||||
l_t1 = (opj_t1_t*) opj_calloc(1,sizeof(opj_t1_t));
|
||||
if (!l_t1) {
|
||||
return 00;
|
||||
}
|
||||
memset(l_t1,0,sizeof(opj_t1_t));
|
||||
|
||||
/* create MQC and RAW handles */
|
||||
l_t1->mqc = opj_mqc_create();
|
||||
|
|
|
@ -477,11 +477,10 @@ OPJ_BOOL opj_t2_decode_packets( opj_t2_t *p_t2,
|
|||
opj_t2_t* opj_t2_create(opj_image_t *p_image, opj_cp_t *p_cp)
|
||||
{
|
||||
/* create the t2 structure */
|
||||
opj_t2_t *l_t2 = (opj_t2_t*)opj_malloc(sizeof(opj_t2_t));
|
||||
opj_t2_t *l_t2 = (opj_t2_t*)opj_calloc(1,sizeof(opj_t2_t));
|
||||
if (!l_t2) {
|
||||
return NULL;
|
||||
}
|
||||
memset(l_t2,0,sizeof(opj_t2_t));
|
||||
|
||||
l_t2->image = p_image;
|
||||
l_t2->cp = p_cp;
|
||||
|
|
|
@ -175,20 +175,18 @@ opj_tcd_t* opj_tcd_create(OPJ_BOOL p_is_decoder)
|
|||
opj_tcd_t *l_tcd = 00;
|
||||
|
||||
/* create the tcd structure */
|
||||
l_tcd = (opj_tcd_t*) opj_malloc(sizeof(opj_tcd_t));
|
||||
l_tcd = (opj_tcd_t*) opj_calloc(1,sizeof(opj_tcd_t));
|
||||
if (!l_tcd) {
|
||||
return 00;
|
||||
}
|
||||
memset(l_tcd,0,sizeof(opj_tcd_t));
|
||||
|
||||
l_tcd->m_is_decoder = p_is_decoder ? 1 : 0;
|
||||
|
||||
l_tcd->tcd_image = (opj_tcd_image_t*)opj_malloc(sizeof(opj_tcd_image_t));
|
||||
l_tcd->tcd_image = (opj_tcd_image_t*)opj_calloc(1,sizeof(opj_tcd_image_t));
|
||||
if (!l_tcd->tcd_image) {
|
||||
opj_free(l_tcd);
|
||||
return 00;
|
||||
}
|
||||
memset(l_tcd->tcd_image,0,sizeof(opj_tcd_image_t));
|
||||
|
||||
return l_tcd;
|
||||
}
|
||||
|
@ -575,23 +573,18 @@ OPJ_BOOL opj_tcd_init( opj_tcd_t *p_tcd,
|
|||
opj_image_t * p_image,
|
||||
opj_cp_t * p_cp )
|
||||
{
|
||||
OPJ_UINT32 l_tile_comp_size;
|
||||
|
||||
p_tcd->image = p_image;
|
||||
p_tcd->cp = p_cp;
|
||||
|
||||
p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_malloc(sizeof(opj_tcd_tile_t));
|
||||
p_tcd->tcd_image->tiles = (opj_tcd_tile_t *) opj_calloc(1,sizeof(opj_tcd_tile_t));
|
||||
if (! p_tcd->tcd_image->tiles) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(p_tcd->tcd_image->tiles,0, sizeof(opj_tcd_tile_t));
|
||||
|
||||
l_tile_comp_size = p_image->numcomps * (OPJ_UINT32)sizeof(opj_tcd_tilecomp_t);
|
||||
p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_malloc(l_tile_comp_size);
|
||||
p_tcd->tcd_image->tiles->comps = (opj_tcd_tilecomp_t *) opj_calloc(p_image->numcomps,sizeof(opj_tcd_tilecomp_t));
|
||||
if (! p_tcd->tcd_image->tiles->comps ) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset( p_tcd->tcd_image->tiles->comps , 0 , l_tile_comp_size);
|
||||
|
||||
p_tcd->tcd_image->tiles->numcomps = p_image->numcomps;
|
||||
p_tcd->tp_pos = p_cp->m_specific_param.m_enc.m_tp_pos;
|
||||
|
@ -1021,20 +1014,17 @@ OPJ_BOOL opj_tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_block)
|
|||
p_code_block->data+=1;
|
||||
|
||||
/* no memset since data */
|
||||
p_code_block->layers = (opj_tcd_layer_t*) opj_malloc(100 * sizeof(opj_tcd_layer_t));
|
||||
p_code_block->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
|
||||
if (! p_code_block->layers) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
p_code_block->passes = (opj_tcd_pass_t*) opj_malloc(100 * sizeof(opj_tcd_pass_t));
|
||||
p_code_block->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
|
||||
if (! p_code_block->passes) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
memset(p_code_block->layers,0,100 * sizeof(opj_tcd_layer_t));
|
||||
memset(p_code_block->passes,0,100 * sizeof(opj_tcd_pass_t));
|
||||
|
||||
return OPJ_TRUE;
|
||||
}
|
||||
|
||||
|
@ -1043,8 +1033,6 @@ OPJ_BOOL opj_tcd_code_block_enc_allocate (opj_tcd_cblk_enc_t * p_code_block)
|
|||
*/
|
||||
OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block)
|
||||
{
|
||||
OPJ_UINT32 l_seg_size;
|
||||
|
||||
if (! p_code_block->data) {
|
||||
|
||||
p_code_block->data = (OPJ_BYTE*) opj_malloc(OPJ_J2K_DEFAULT_CBLK_DATA_SIZE);
|
||||
|
@ -1054,12 +1042,10 @@ OPJ_BOOL opj_tcd_code_block_dec_allocate (opj_tcd_cblk_dec_t * p_code_block)
|
|||
p_code_block->data_max_size = OPJ_J2K_DEFAULT_CBLK_DATA_SIZE;
|
||||
/*fprintf(stderr, "Allocate 8192 elements of code_block->data\n");*/
|
||||
|
||||
l_seg_size = OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t);
|
||||
p_code_block->segs = (opj_tcd_seg_t *) opj_malloc(l_seg_size);
|
||||
p_code_block->segs = (opj_tcd_seg_t *) opj_calloc(OPJ_J2K_DEFAULT_NB_SEGS,sizeof(opj_tcd_seg_t));
|
||||
if (! p_code_block->segs) {
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
memset(p_code_block->segs,0,l_seg_size);
|
||||
/*fprintf(stderr, "Allocate %d elements of code_block->data\n", OPJ_J2K_DEFAULT_NB_SEGS * sizeof(opj_tcd_seg_t));*/
|
||||
|
||||
p_code_block->m_current_max_segs = OPJ_J2K_DEFAULT_NB_SEGS;
|
||||
|
|
|
@ -57,12 +57,11 @@ opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
|
|||
OPJ_UINT32 numlvls;
|
||||
OPJ_UINT32 n;
|
||||
|
||||
tree = (opj_tgt_tree_t *) opj_malloc(sizeof(opj_tgt_tree_t));
|
||||
tree = (opj_tgt_tree_t *) opj_calloc(1,sizeof(opj_tgt_tree_t));
|
||||
if(!tree) {
|
||||
fprintf(stderr, "ERROR in tgt_create while allocating tree\n");
|
||||
return 00;
|
||||
}
|
||||
memset(tree,0,sizeof(opj_tgt_tree_t));
|
||||
|
||||
tree->numleafsh = numleafsh;
|
||||
tree->numleafsv = numleafsv;
|
||||
|
@ -92,7 +91,6 @@ opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) {
|
|||
opj_free(tree);
|
||||
return 00;
|
||||
}
|
||||
memset(tree->nodes,0,tree->numnodes * sizeof(opj_tgt_node_t));
|
||||
tree->nodes_size = tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node_t);
|
||||
|
||||
node = tree->nodes;
|
||||
|
|
Loading…
Reference in New Issue