1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
....
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
|
static int
allocate_cells (biff_workbook * workbook)
{
/* allocating the rows and cells for the active Worksheet */
unsigned int row;
unsigned int col;
biff_cell_value *p_cell;
if (workbook == NULL)
return FREEXL_NULL_ARGUMENT;
if (workbook->active_sheet == NULL)
return FREEXL_NULL_ARGUMENT;
/* allocating the cell values array */
workbook->active_sheet->cell_values =
malloc (sizeof (biff_cell_value) *
(workbook->active_sheet->rows *
workbook->active_sheet->columns));
if (workbook->active_sheet->cell_values == NULL)
................................................................................
if (workbook->shared_strings.string_count > 1024 * 1024)
{
/* unexpected huge count ... cowardly giving up ... */
return FREEXL_INSUFFICIENT_MEMORY;
}
workbook->shared_strings.utf8_strings =
malloc (sizeof (char **) * workbook->shared_strings.string_count);
for (i_string = 0; i_string < workbook->shared_strings.string_count;
i_string++)
*(workbook->shared_strings.utf8_strings + i_string) = NULL;
}
else
{
/* SST-CONTINUE */
|
|
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
....
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
|
static int
allocate_cells (biff_workbook * workbook)
{
/* allocating the rows and cells for the active Worksheet */
unsigned int row;
unsigned int col;
double dsize;
biff_cell_value *p_cell;
if (workbook == NULL)
return FREEXL_NULL_ARGUMENT;
if (workbook->active_sheet == NULL)
return FREEXL_NULL_ARGUMENT;
/* testing for an unrealistically high memory size > 256MB */
dsize =
(double) sizeof (biff_cell_value) *
(double) (workbook->active_sheet->rows) *
(double) (workbook->active_sheet->columns);
if (dsize > 256.0 * 1024.0 * 1024.0)
return FREEXL_INSUFFICIENT_MEMORY;
/* allocating the cell values array */
workbook->active_sheet->cell_values =
malloc (sizeof (biff_cell_value) *
(workbook->active_sheet->rows *
workbook->active_sheet->columns));
if (workbook->active_sheet->cell_values == NULL)
................................................................................
if (workbook->shared_strings.string_count > 1024 * 1024)
{
/* unexpected huge count ... cowardly giving up ... */
return FREEXL_INSUFFICIENT_MEMORY;
}
workbook->shared_strings.utf8_strings =
malloc (sizeof (char **) * workbook->shared_strings.string_count);
if (workbook->shared_strings.utf8_strings == NULL)
return FREEXL_INSUFFICIENT_MEMORY;
for (i_string = 0; i_string < workbook->shared_strings.string_count;
i_string++)
*(workbook->shared_strings.utf8_strings + i_string) = NULL;
}
else
{
/* SST-CONTINUE */
|