Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Moving errno NCCE to MSC38-C

...

Code Block
bgColor#ccccff
#include <stddef.h>

void* my_malloc(size_t nbytes) {
  void *ptr;
  /* allocate storage from own pool and set ptr */
  return ptr;
}

void* my_calloc(size_t nelems, size_t elsize) {
  void *ptr;
  /* allocate storage from own pool and set ptr */
  return ptr;
}

void* my_realloc(void *ptr, size_t nbytes) {
  /* reallocate storage from own pool and set ptr */
  return ptr;
}

void my_free(void *ptr) {
  /* return storage to own pool */
}

Noncompliant Code Example (Redefinition of Reserved Library Identifier)

Legacy code is apt to include an incorrect declaration such as the following.

Code Block
bgColor#FFcccc

extern int errno;

Compliant Solution (Redefinition of Reserved Library Identifier)

The correct way to declare errno is to include the header <errno.h>.

Code Block
bgColor#ccccff

#include <errno.h>

Implementations conforming to C99 are required to declare errno in <errno.h>, although some historic implementations failed to do so.

Risk Assessment

Using reserved identifiers can lead to incorrect program operation.

...