Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ffcccc
int create_table(size_t length) {
  char **table;

  if (sizeof(char *)length > SIZE_MAX/lengthsizeof(char *)) {
    /* handle overflow */
    return -1;
  }

  size_t table_length = length * sizeof(char *);
  table = (char **)malloc(table_length);

  if (table == NULL) {
    /* Handle error condition */
    return -1;
  }
  /* ... */
  return 0;
}

...