Versions Compared

Key

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

...

Code Block
bgColor#FFcccc
#define MIN_SIZE_ALLOWED 10

int verify_size(intchar *list, size_t list_size) {
  if (size < MIN_SIZE_ALLOWED) {
    /* Handle Error Condition */
    free(list);
    return -1;
  }

  /* Process list */

  return 0;
}

void process_list(int *list, size_t number) {
  char *list = malloc(sizeof(int));
  if (list == NULL) {
    /* ... Handle Allocation Error */
  }

  if (verify_size(list,number) == -1) {
    /* Handle Error */
  }

  /* Continue Processing list */

  free(list);
}

...

Code Block
bgColorccccff
#define MIN_SIZE_ALLOWED 10

int  func2(int *list, size_t list_size) {
  if (size < MIN_SIZE_ALLOWED) {
     /* Handle Error Condition */
      return;
  }
  /* Process list */
}

void func1 (size_t number) {
  intchar *list = malloc (number * sizeof(int));
  if (list == NULL) {
    /* Handle Allocation Error */
  }
  func2(list,number);

  /* Continue Processing list */

  free(list);
}

...