Fix warnings and errors when compiling with a c++ compiler (#1021)
[openjpeg.git] / src / lib / openjp2 / sparse_array.c
index 6a2d8d4349767a0fba2662f9afff4b30f7980b6c..67212d28b9223b06b3a7bd1590de0efcb7ce16b9 100644 (file)
@@ -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;
@@ -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;
@@ -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;
                     }