Versions Compared

Key

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

...

One way to eliminate invalid pointers is to define a function that accepts a pointer argument and indicates whether or not the pointer is valid for some definition of valid. For example, the following function declares any pointer to be valid except NULL.:

Code Block
int valid(void *ptr) {
  return (ptr != NULL);
}

...

 

...