Commit 8c45343b authored by David Gobbi's avatar David Gobbi

Remove some unecessary casts.

These casts were necessary for really old compilers that didn't
keep track of which level of indirection the "constness" applied
to.  For modern compilers, they should be unecessary.

Change-Id: Ia23cebae43fd6f1705016a11f2df4801e9830d24
parent 7eb427d2
......@@ -316,7 +316,7 @@ void vtkParse_FreeValue(ValueInfo *value_info)
{
if (value_info->NumberOfDimensions)
{
free((char **)value_info->Dimensions);
free(value_info->Dimensions);
}
if (value_info->Function)
{
......@@ -560,7 +560,7 @@ void vtkParse_FreeClass(ClassInfo *class_info)
if (class_info->Template) { vtkParse_FreeTemplate(class_info->Template); }
m = class_info->NumberOfSuperClasses;
if (m > 0) { free((char **)class_info->SuperClasses); }
if (m > 0) { free(class_info->SuperClasses); }
m = class_info->NumberOfClasses;
for (j = 0; j < m; j++) { vtkParse_FreeClass(class_info->Classes[j]); }
......@@ -663,7 +663,7 @@ void vtkParse_AddStringToArray(
const char ***valueArray, int *count, const char *value)
{
*valueArray = (const char **)array_size_check(
(char **)*valueArray, sizeof(const char *), *count);
*valueArray, sizeof(const char *), *count);
(*valueArray)[(*count)++] = value;
}
......
......@@ -1221,7 +1221,7 @@ void vtkParse_FreeTemplateDecomposition(
free((char *)args[i]);
}
free((char **)args);
free(args);
}
}
......@@ -1331,8 +1331,8 @@ void vtkParse_InstantiateClassTemplate(
class_substitution(data, cache, m, arg_names, args, arg_types);
/* free all allocated arrays */
free((char **)new_args);
free((char **)arg_names);
free(new_args);
free(arg_names);
for (i = 0; i < m; i++)
{
......
......@@ -256,9 +256,9 @@ HierarchyInfo *vtkParseHierarchy_ReadFile(const char *filename)
else
{
entry->TemplateParameters = (const char **)realloc(
(char **)entry->TemplateParameters, (j+1)*sizeof(char *));
entry->TemplateParameters, (j+1)*sizeof(char *));
entry->TemplateDefaults = (const char **)realloc(
(char **)entry->TemplateDefaults, (j+1)*sizeof(char *));
entry->TemplateDefaults, (j+1)*sizeof(char *));
}
entry->NumberOfTemplateParameters++;
entry->TemplateDefaults[j] = NULL;
......@@ -344,7 +344,7 @@ HierarchyInfo *vtkParseHierarchy_ReadFile(const char *filename)
else
{
entry->SuperClasses = (const char **)realloc(
(char **)entry->SuperClasses, (j+1)*sizeof(char *));
entry->SuperClasses, (j+1)*sizeof(char *));
entry->SuperClassIndex = (int *)realloc(
entry->SuperClassIndex, (j+1)*sizeof(int));
}
......@@ -503,7 +503,7 @@ HierarchyInfo *vtkParseHierarchy_ReadFile(const char *filename)
else
{
entry->Properties = (const char **)realloc(
(char **)entry->Properties,
entry->Properties,
(entry->NumberOfProperties+1)*sizeof(char **));
}
n = 0;
......@@ -545,17 +545,17 @@ void vtkParseHierarchy_Free(HierarchyInfo *info)
entry = &info->Entries[i];
if (entry->NumberOfTemplateParameters)
{
free((char **)entry->TemplateParameters);
free((char **)entry->TemplateDefaults);
free(entry->TemplateParameters);
free(entry->TemplateDefaults);
}
if (entry->NumberOfSuperClasses)
{
free((char **)entry->SuperClasses);
free(entry->SuperClasses);
free(entry->SuperClassIndex);
}
if (entry->NumberOfProperties)
{
free((char **)entry->Properties);
free(entry->Properties);
}
}
......@@ -773,7 +773,7 @@ void vtkParseHierarchy_FreeTemplateArgs(int n, const char *args[])
free((char *)args[i]);
}
free((char **)args);
free(args);
}
/* Given a classname with template parameters, get the superclass name
......
......@@ -584,7 +584,6 @@ static int preproc_evaluate_single(
expansion = vtkParsePreprocess_ExpandMacro(info, macro, args);
if (expansion == NULL)
{
free((char *)args);
#if PREPROC_DEBUG
fprintf(stderr, "syntax error %d\n", __LINE__);
#endif
......@@ -1402,7 +1401,7 @@ static int preproc_evaluate_define(
{
if (tokens->tok != TOK_ID && tokens->tok != TOK_ELLIPSIS)
{
free((char **)params);
free(params);
#if PREPROC_DEBUG
fprintf(stderr, "syntax error %d\n", __LINE__);
#endif
......@@ -1421,7 +1420,7 @@ static int preproc_evaluate_define(
/* add to the arg list */
params = (const char **)preproc_array_check(
(char **)params, sizeof(char *), n);
params, sizeof(char *), n);
params[n++] = vtkParse_CacheString(info->Strings, param, l);
vtkParse_NextToken(tokens);
......@@ -1439,7 +1438,7 @@ static int preproc_evaluate_define(
}
else if (tokens->tok != ')')
{
free((char **)params);
free(params);
#if PREPROC_DEBUG
fprintf(stderr, "syntax error %d\n", __LINE__);
#endif
......@@ -1457,7 +1456,7 @@ static int preproc_evaluate_define(
macro = *macro_p;
if (macro)
{
free((char **)params);
free(params);
if (preproc_identical(macro->Definition, definition))
{
return VTK_PARSE_OK;
......@@ -1511,7 +1510,7 @@ static int preproc_add_include_file(PreprocessInfo *info, const char *name)
}
info->IncludeFiles = (const char **)preproc_array_check(
(char **)info->IncludeFiles, sizeof(char *), info->NumberOfIncludeFiles);
info->IncludeFiles, sizeof(char *), info->NumberOfIncludeFiles);
info->IncludeFiles[info->NumberOfIncludeFiles++] =
vtkParse_CacheString(info->Strings, name, strlen(name));
......@@ -1589,8 +1588,7 @@ const char *preproc_find_include_file(
}
info->IncludeFiles = (const char **)preproc_array_check(
(char **)info->IncludeFiles, sizeof(char *),
info->NumberOfIncludeFiles);
info->IncludeFiles, sizeof(char *), info->NumberOfIncludeFiles);
info->IncludeFiles[info->NumberOfIncludeFiles++] = output;
return output;
......@@ -1699,7 +1697,7 @@ const char *preproc_find_include_file(
{
nn = info->NumberOfIncludeFiles;
info->IncludeFiles = (const char **)preproc_array_check(
(char **)info->IncludeFiles, sizeof(char *), nn);
info->IncludeFiles, sizeof(char *), nn);
info->IncludeFiles[info->NumberOfIncludeFiles++] =
vtkParse_CacheString(info->Strings, output, strlen(output));
free(output);
......@@ -2516,12 +2514,12 @@ const char *vtkParsePreprocess_ExpandMacro(
if (values != stack_values)
{
values = (const char **)realloc(
(char **)values, 2*n*sizeof(const char **));
values, 2*n*sizeof(const char **));
}
else
{
values = (const char **)malloc(2*n*sizeof(const char **));
memcpy((char **)values, stack_values, 8*sizeof(const char **));
memcpy(values, stack_values, 8*sizeof(const char **));
}
}
......@@ -2560,7 +2558,7 @@ const char *vtkParsePreprocess_ExpandMacro(
if (n < (macro->NumberOfParameters - empty_variadic) ||
(n > macro->NumberOfParameters && !macro->IsVariadic))
{
if (values != stack_values) { free((char **)values); }
if (values != stack_values) { free(values); }
#if PREPROC_DEBUG
fprintf(stderr, "wrong number of macro args to %s, %lu != %lu\n",
macro->Name, n, macro->NumberOfParameters);
......@@ -2806,7 +2804,7 @@ const char *vtkParsePreprocess_ExpandMacro(
}
}
if (values != stack_values) { free((char **)values); }
if (values != stack_values) { free(values); }
if (!macro->IsFunction && macro->Definition &&
strcmp(rp, macro->Definition) == 0)
......@@ -3058,7 +3056,7 @@ void vtkParsePreprocess_IncludeDirectory(
}
info->IncludeDirectories = (const char **)preproc_array_check(
(char **)info->IncludeDirectories, sizeof(char *),
info->IncludeDirectories, sizeof(char *),
info->NumberOfIncludeDirectories);
info->IncludeDirectories[info->NumberOfIncludeDirectories++] =
vtkParse_CacheString(info->Strings, name, strlen(name));
......@@ -3105,7 +3103,7 @@ void vtkParsePreprocess_InitMacro(MacroInfo *macro)
*/
void vtkParsePreprocess_FreeMacro(MacroInfo *macro)
{
free((char **)macro->Parameters);
free(macro->Parameters);
free(macro);
}
......@@ -3163,8 +3161,8 @@ void vtkParsePreprocess_Free(PreprocessInfo *info)
free(info->MacroHashTable);
}
free((char **)info->IncludeDirectories);
free((char **)info->IncludeFiles);
free(info->IncludeDirectories);
free(info->IncludeFiles);
free(info);
}
......@@ -919,7 +919,7 @@ static int vtkWrapHierarchy_TryWriteHierarchyFile(
static int string_compare(const void *vp1, const void *vp2)
{
return strcmp(*(const char **)vp1, *(const char **)vp2);
return strcmp(*(const char *const *)vp1, *(const char *const *)vp2);
}
int main(int argc, char *argv[])
......
......@@ -229,7 +229,7 @@ static void vtkWrapPython_GenerateSpecialHeaders(
{
if (numTypes > 0 && (numTypes % 1000) == 0)
{
types = (const char **)realloc((char **)types,
types = realloc((char **)types,
(numTypes + 1000)*sizeof(const char *));
}
types[numTypes++] = classname;
......@@ -270,7 +270,7 @@ static void vtkWrapPython_GenerateSpecialHeaders(
}
}
free((char **)types);
free(types);
}
/* -------------------------------------------------------------------- */
......@@ -332,7 +332,7 @@ static void vtkWrapPython_ImportExportEnumTypes(
/* crude code to expand list as necessary */
if (numTypes > 0 && (numTypes % 1000) == 0)
{
types = (const char **)realloc((char **)types,
types = realloc(types,
(numTypes + 1000)*sizeof(const char *));
}
types[numTypes++] = val->Class;
......@@ -396,7 +396,7 @@ static void vtkWrapPython_ImportExportEnumTypes(
enumname, enumname);
}
free((char **)types);
free(types);
}
/* -------------------------------------------------------------------- */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment