Versions Compared

Key

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

...

Code Block
bgColor#ccccff
langc
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>

enum { STR_SIZE = 32 };

size_t func(const char *source) {
  char ac_str[STR_SIZE];
  size_t ret = 0;

  if (source) {
    errno_t err = strncpy_s(
      ac_str, sizeof(ac_str), source, strnlen(source, sizeof(ac_str))
    );
    if (err != 0) {
      /* Handle error */
    } else {
      ret = strnlen_s(ac_str, sizeof(ac_str));
    }
  } else {
     /* Handle null pointer */
  }
  return ret;
}

...