char **CellContents=NULL;
int i;
- if ( (CellContents=(char **) malloc( sizeof(char *) * Table->numColumns))\
- == NULL ) {
+ if ( (CellContents=malloc( sizeof(char *) * Table->numColumns))== NULL ) {
fprintf(stderr,"Internal Error. Cannot allocate memory for new CellContents-array.\n");
exit(EXIT_FAILURE);
}
for (i=0;i<Table->numColumns;i++) {
- if ( (CellContents[i]=(char *) malloc(UTIL_T_MAX_CELLCONTENT_LEN)) == NULL) {
+ if ( (CellContents[i]=malloc(UTIL_T_MAX_CELLCONTENT_LEN)) == NULL) {
fprintf(stderr,\
"Internal Error. Cannot allocate memory for new CellContents-array.\n");
exit(EXIT_FAILURE);
Table->Type=Type;
Table->numColumns=numColumns;
Table->numRows=0;
+ Table->numAllocatedRows=0;
if (sortByColumn < 0 || sortByColumn > numColumns) {
fprintf(stderr,"Invalid Table Sortkey: %d.\n", sortByColumn);
errno=EINVAL;
+ free(Table);
return NULL;
}
if (sortByColumn > 0 )
break;
default :
fprintf(stderr,"Error. Invalid TableType: %d.\n", Table->Type);
+ free(Table);
errno=EINVAL;
return NULL;
}
newTableRow(struct util_Table* Table) {
struct util_TableRow *aRow =NULL;
- if ( (aRow= (struct util_TableRow*) malloc(sizeof(struct util_TableRow))) == NULL) {
+ if ( (aRow = malloc(sizeof(struct util_TableRow))) == NULL) {
fprintf(stderr,\
"Internal Error. Cannot allocate memory for new TableRow.\n");
exit(EXIT_FAILURE);