Skip to content

Commit

Permalink
Fix warnings and errors when compiling with a c++ compiler (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 19, 2017
1 parent 18f6696 commit fdef69b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/lib/openjp2/bench_dwt.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ void init_tilec(opj_tcd_tilecomp_t * l_tilec,
l_tilec->y1 = y1;
nValues = (size_t)(l_tilec->x1 - l_tilec->x0) *
(size_t)(l_tilec->y1 - l_tilec->y0);
l_tilec->data = opj_malloc(sizeof(OPJ_INT32) * nValues);
l_tilec->data = (OPJ_INT32*) opj_malloc(sizeof(OPJ_INT32) * nValues);
for (i = 0; i < nValues; i++) {
l_tilec->data[i] = getValue((OPJ_UINT32)i);
}
l_tilec->numresolutions = numresolutions;
l_tilec->resolutions = opj_calloc(l_tilec->numresolutions,
sizeof(opj_tcd_resolution_t));
l_tilec->resolutions = (opj_tcd_resolution_t*) opj_calloc(
l_tilec->numresolutions,
sizeof(opj_tcd_resolution_t));

l_level_no = l_tilec->numresolutions;
l_res = l_tilec->resolutions;
Expand Down
11 changes: 6 additions & 5 deletions src/lib/openjp2/sparse_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
return NULL;
}

sa = opj_calloc(1, sizeof(opj_sparse_array_int32_t));
sa = (opj_sparse_array_int32_t*) opj_calloc(1,
sizeof(opj_sparse_array_int32_t));
sa->width = width;
sa->height = height;
sa->block_width = block_width;
Expand All @@ -67,8 +68,8 @@ opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
opj_free(sa);
return NULL;
}
sa->data_blocks = opj_calloc(sizeof(OPJ_INT32*),
sa->block_count_hor * sa->block_count_ver);
sa->data_blocks = (OPJ_INT32**) opj_calloc(sizeof(OPJ_INT32*),
sa->block_count_hor * sa->block_count_ver);
if (sa->data_blocks == NULL) {
opj_free(sa);
return NULL;
Expand Down Expand Up @@ -232,8 +233,8 @@ static OPJ_BOOL opj_sparse_array_int32_read_or_write(
}
} else {
if (src_block == NULL) {
src_block = opj_calloc(1,
sa->block_width * sa->block_height * sizeof(OPJ_INT32));
src_block = (OPJ_INT32*) opj_calloc(1,
sa->block_width * sa->block_height * sizeof(OPJ_INT32));
if (src_block == NULL) {
return OPJ_FALSE;
}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/openjp2/t1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ static void opj_t1_enc_clnpass_step(
for (ci = runlen; ci < lim; ++ci) {
OPJ_UINT32 vsc;
opj_flag_t flags;
OPJ_UINT32 ctxt1;

flags = *flagsp;

Expand All @@ -1073,7 +1074,7 @@ static void opj_t1_enc_clnpass_step(
}

if (!(flags & ((T1_SIGMA_THIS | T1_PI_THIS) << (ci * 3U)))) {
OPJ_UINT32 ctxt1 = opj_t1_getctxno_zc(mqc, flags >> (ci * 3U));
ctxt1 = opj_t1_getctxno_zc(mqc, flags >> (ci * 3U));
#ifdef DEBUG_ENC_CLN
printf(" ctxt1=%d\n", ctxt1);
#endif
Expand Down Expand Up @@ -1617,7 +1618,8 @@ static void opj_t1_clbl_decode_processor(void* user_data, opj_tls_t* tls)
cblk_w = (OPJ_UINT32)(cblk->x1 - cblk->x0);
cblk_h = (OPJ_UINT32)(cblk->y1 - cblk->y0);

cblk->decoded_data = opj_aligned_malloc(cblk_w * cblk_h * sizeof(OPJ_INT32));
cblk->decoded_data = (OPJ_INT32*)opj_aligned_malloc(cblk_w * cblk_h * sizeof(
OPJ_INT32));
if (cblk->decoded_data == NULL) {
if (job->p_manager_mutex) {
opj_mutex_lock(job->p_manager_mutex);
Expand Down
14 changes: 9 additions & 5 deletions src/lib/openjp2/tcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,7 @@ OPJ_BOOL opj_tcd_decode_tile(opj_tcd_t *p_tcd,
}
l_data_size *= sizeof(OPJ_INT32);

tilec->data_win = opj_image_data_alloc(l_data_size);
tilec->data_win = (OPJ_INT32*) opj_image_data_alloc(l_data_size);
if (tilec->data_win == NULL) {
opj_event_msg(p_manager, EVT_ERROR,
"Size of tile data exceeds system limits\n");
Expand Down Expand Up @@ -1812,14 +1812,16 @@ static void opj_tcd_free_tile(opj_tcd_t *p_tcd)
l_res = l_tile_comp->resolutions;
if (l_res) {

l_nb_resolutions = l_tile_comp->resolutions_size / sizeof(opj_tcd_resolution_t);
l_nb_resolutions = l_tile_comp->resolutions_size / (OPJ_UINT32)sizeof(
opj_tcd_resolution_t);
for (resno = 0; resno < l_nb_resolutions; ++resno) {
l_band = l_res->bands;
for (bandno = 0; bandno < 3; ++bandno) {
l_precinct = l_band->precincts;
if (l_precinct) {

l_nb_precincts = l_band->precincts_data_size / sizeof(opj_tcd_precinct_t);
l_nb_precincts = l_band->precincts_data_size / (OPJ_UINT32)sizeof(
opj_tcd_precinct_t);
for (precno = 0; precno < l_nb_precincts; ++precno) {
opj_tgt_destroy(l_precinct->incltree);
l_precinct->incltree = 00;
Expand Down Expand Up @@ -2215,7 +2217,8 @@ static void opj_tcd_code_block_dec_deallocate(opj_tcd_precinct_t * p_precinct)
l_code_block->numbps, l_code_block->numlenbits, l_code_block->len, l_code_block->numnewpasses, l_code_block->real_num_segs, l_code_block->m_current_max_segs );*/


l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_dec_t);
l_nb_code_blocks = p_precinct->block_size / (OPJ_UINT32)sizeof(
opj_tcd_cblk_dec_t);
/*fprintf(stderr,"nb_code_blocks =%d\t}\n", l_nb_code_blocks);*/

for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
Expand Down Expand Up @@ -2250,7 +2253,8 @@ static void opj_tcd_code_block_enc_deallocate(opj_tcd_precinct_t * p_precinct)

opj_tcd_cblk_enc_t * l_code_block = p_precinct->cblks.enc;
if (l_code_block) {
l_nb_code_blocks = p_precinct->block_size / sizeof(opj_tcd_cblk_enc_t);
l_nb_code_blocks = p_precinct->block_size / (OPJ_UINT32)sizeof(
opj_tcd_cblk_enc_t);

for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
if (l_code_block->data) {
Expand Down

0 comments on commit fdef69b

Please sign in to comment.