...
Code Block | ||
---|---|---|
| ||
#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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
#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.
...