Versions Compared

Key

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

...

This compliant solution explicitly installs a runtime constraint handler by invoking the set_constraint_handler_s() function. This would typically be performed during system initialization and before any functions that used the mechanism were invoked.

Code Block
bgColor#ccccff
constraint_handler_t handle_errors(void) {
  /* handle runtime constraint error */
}

/*...*/

set_constraint_handler_s(handle_errors);

/*...*/

/* Returns zero on success */
errno_t function(char *dst1, size_t size){
  char src1[100] = "hello";

  if (strcpy_s(dst1, size, src1) != 0) {
    return -1;
  }
  /* ... */
  return 0;
}

...