diff --git a/src/json_parser.cpp b/src/json_parser.cpp index 8c5a2752940fd19003585b5cd2b9f2733bf81d83..edd445f8d8cce610e260d0874f8cf91d51b673a9 100644 --- a/src/json_parser.cpp +++ b/src/json_parser.cpp @@ -171,7 +171,7 @@ int read_objects_from_intputfile(const char *input_file, char **varname_list, ch //in this case a new object is allocated which is already there... //varname_list = malloc(sizeof(*varname_list)); //value_list = malloc(sizeof(*value_list)); - varname_list[number_readobject] = malloc(STRING_SIZE * sizeof(char *)); + varname_list[number_readobject] = (char *)malloc(STRING_SIZE * sizeof(char *)); //varname_list[number_readobject] = (char**)malloc(STRING_SIZE*sizeof(char*)); //value_list[number_readobject] = (char**)malloc(STRING_SIZE*sizeof(char*)); break; @@ -391,8 +391,8 @@ void add_object_tolist(char string_name[STRING_SIZE], char string_value[STRING_S remove_blankspaces_around_string(string_value); //allocate memory for a new object - varname_list[*number_readobject] = malloc(STRING_SIZE * sizeof(char *)); - value_list[*number_readobject] = malloc(STRING_SIZE * sizeof(char *)); + varname_list[*number_readobject] = (char *)malloc(STRING_SIZE * sizeof(char *)); + value_list[*number_readobject] = (char *)malloc(STRING_SIZE * sizeof(char *)); // varname_list[*number_readobject] = (char**)malloc(STRING_SIZE*sizeof(char*)); // value_list[*number_readobject] = (char**)malloc(STRING_SIZE*sizeof(char*)); diff --git a/src/read_par_json.cpp b/src/read_par_json.cpp index 7b23e790afdc28220994cdd0bce93b8f0e0df87e..13d5f708c269083f72abe9331eaaba72b5e6bf54 100644 --- a/src/read_par_json.cpp +++ b/src/read_par_json.cpp @@ -35,15 +35,15 @@ void read_par_json(GlobVar *gv) bool header_printed = false; /* allocate first object in list */ - char **varname_list = malloc(STRING_SIZE * sizeof(char *)); - char **value_list = malloc(STRING_SIZE * sizeof(char *)); + char **varname_list = (char **)malloc(STRING_SIZE * sizeof(char *)); + char **value_list = (char **)malloc(STRING_SIZE * sizeof(char *)); /* read in objects from file */ log_info("Parameter file: %s\n", gv->FILEINP); number_readobjects = read_objects_from_intputfile(gv->FILEINP, varname_list, value_list); log_info("Read %d parameters from parameter file.\n", number_readobjects); - used_list = (int *)calloc(sizeof(int), number_readobjects); + used_list = (int *)calloc(number_readobjects, sizeof(int)); if (get_string_from_objectlist("LOG_VERBOSITY", number_readobjects, gv->LOG_VERBOSITY, varname_list, value_list, used_list)) { diff --git a/src/util.cpp b/src/util.cpp index fe4be292679f75b86a31fe12af31286b546cff6c..c67bc9f6650f10b921c14c996908012202a54690 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -761,7 +761,7 @@ void **malloc2d(size_t n1, size_t n2, size_t typesize) * allocation is handled as single malloc to avoid memory fragmentation */ size_t stride = n2 * typesize; - void **buffer = malloc(n1 * sizeof(void *) + n1 * stride); + void **buffer = (void **)malloc(n1 * sizeof(void *) + n1 * stride); if (!buffer) { log_fatal("malloc of size %zu failed in malloc2d().\n", n1 * sizeof(void *) + n1 * stride); @@ -780,7 +780,7 @@ void **calloc2d(size_t n1, size_t n2, size_t typesize) { size_t stride = n2 * typesize; - void **buffer = calloc(n1, sizeof(void *) + stride); + void **buffer = (void **)calloc(n1, sizeof(void *) + stride); if (!buffer) { log_fatal("calloc of size %zu failed in calloc2d().\n", n1 * (sizeof(void *) + stride)); @@ -802,7 +802,7 @@ void ***malloc3d(size_t n1, size_t n2, size_t n3, size_t typesize) size_t stride1 = n2 * n3 * typesize; size_t stride2 = n3 * typesize; - void ***buffer = malloc(n1 * sizeof(void **) + n1 * n2 * sizeof(void *) + n1 * stride1); + void ***buffer = (void ***)malloc(n1 * sizeof(void **) + n1 * n2 * sizeof(void *) + n1 * stride1); if (!buffer) { log_fatal("malloc of size %zu failed in malloc3d().\n", n1 * (sizeof(void **) + n2 * sizeof(void *) + stride1)); @@ -827,7 +827,7 @@ void ***calloc3d(size_t n1, size_t n2, size_t n3, size_t typesize) { size_t stride1 = n2 * n3 * typesize; size_t stride2 = n3 * typesize; - void ***buffer = calloc1d(n1, sizeof(void **) + n2 * sizeof(void *) + stride1); + void ***buffer = (void ***)calloc1d(n1, sizeof(void **) + n2 * sizeof(void *) + stride1); if (!buffer) { log_fatal("calloc of size %zu failed in calloc3d().\n", n1 * (sizeof(void **) + n2 * sizeof(void *) + stride1));