Commit 314a8bd6 authored by David Gobbi's avatar David Gobbi

Use size_t for array size in wrappers

Previously the size type was 'int', which can overflow for large
arrays.
parent a92ee8b2
This diff is collapsed.
This diff is collapsed.
......@@ -1148,7 +1148,7 @@ void vtkWrap_DeclareVariableSize(
if (val->NumberOfDimensions > 1)
{
fprintf(fp,
" static int %s%s[%d] = ",
" static size_t %s%s[%d] = ",
name, idx, val->NumberOfDimensions);
for (j = 0; j < val->NumberOfDimensions; j++)
......@@ -1161,14 +1161,14 @@ void vtkWrap_DeclareVariableSize(
else if (val->Count != 0 || val->CountHint || vtkWrap_IsPODPointer(val))
{
fprintf(fp,
" %sint %s%s = %d;\n",
" %ssize_t %s%s = %d;\n",
((val->Count == 0 || val->Value != 0) ? "" : "const "),
name, idx, (val->Count == 0 ? 0 : val->Count));
}
else if (val->NumberOfDimensions == 1)
{
fprintf(fp,
" const int %s%s = %s;\n",
" const size_t %s%s = %s;\n",
name, idx, val->Dimensions[0]);
}
}
......
......@@ -115,7 +115,7 @@ void vtkWrapPython_DeclareVariables(
{
/* prepare for "char *" arg for non-const char pointer */
fprintf(fp,
" int size%d = ap.GetStringSize(%d);\n"
" size_t size%d = ap.GetStringSize(%d);\n"
" vtkPythonArgs::Array<char> store%d(%ssize%d + 1);\n"
" char *temp%d = store%d.Data();\n",
i, i,
......@@ -132,7 +132,7 @@ void vtkWrapPython_DeclareVariables(
{
/* prepare for "T *" arg, where T is a plain type */
fprintf(fp,
" int size%d = ap.GetArgSize(%d);\n"
" size_t size%d = ap.GetArgSize(%d);\n"
" vtkPythonArgs::Array<%s> store%d(%ssize%d);\n"
" %s *temp%d = store%d.Data();\n",
i, i,
......@@ -150,7 +150,7 @@ void vtkWrapPython_DeclareVariables(
{
/* prepare for "T a[n] = nullptr" arg (array with default of NULL) */
fprintf(fp,
" int size%d = 0;\n"
" size_t size%d = 0;\n"
" %s store%d[%s%d];\n"
" %s *temp%d = nullptr;\n",
i,
......@@ -226,7 +226,7 @@ void vtkWrapPython_DeclareVariables(
!theFunc->ReturnValue->CountHint)
{
fprintf(fp,
" int sizer = %d;\n",
" size_t sizer = %d;\n",
theFunc->ReturnValue->Count);
}
}
......@@ -1282,7 +1282,7 @@ void vtkWrapPython_GenerateOneMethod(
if (theOccurrence->ReturnValue && theOccurrence->ReturnValue->CountHint)
{
fprintf(fp,
" int sizer = ");
" size_t sizer = ");
vtkWrapPython_SubstituteCode(fp, data, theOccurrence,
theOccurrence->ReturnValue->CountHint);
fprintf(fp, ";\n");
......
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