Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Made compliant with MEM02-A, matched error checking styles, finished replacing triarray with matrix

...

Code Block
bgColor#FFcccc
/* assuming 32-bit pointer, 32-bit integer */
size_t i;
int **matrix = (int **)calloc(100, 4);
if (matrix == NULL) {
  /* handle error */
}

for (i = 0; i < 100; i++) {
   matrix[i] = (int *)calloc(i, 4);
   if (matrix[i] == NULL) {
     /* handle error */
   }
}

...

Code Block
bgColor#ccccff
size_t i;
int **matrix = (int **)calloc(100, sizeof(int *));
if (matrix == NULL) {
   /* handle error */
}

for (i = 0; i < 100; i++) {
   matrix[i] = (int *)calloc(i, sizeof(int));
   if (!matrix[i] == NULL) {
      /* handle error */
   }
}

...