home *** CD-ROM | disk | FTP | other *** search
- "memlintok.h" is a header file that can be used to politely shut lint(1) up
- about casting results of memory allocation functions malloc(3), realloc(3),
- and calloc(3). It also stops complaints about the argument of free(3).
-
- CONTENTS
- --------
- Files in this distribution are:
-
- README you're reading it
- Makefile has several useful targets, including "install" and "test"
- good good results for "make test"
- memlintok.3 man page
- memlintok.h the header file itself
- t_memlintok.c a test/demo program
-
- DISCUSSION
- ----------
- One common way of ignoring lint errors is to do something like:
-
- #ifdef lint
- #define malloc(arg) NULL
- #endif
-
- The trouble with doing things this way is that lint will not then be able to
- check malloc's argument, so you could get away with something like:
-
- char *p;
- char *q;
- ...
- p = malloc(q);
-
- The macros here are a bit more sophisticated, so that the memory functions
- get invoked in a syntactically correct and properly-typed (although
- semantically incorrect) fashion and the arguments get checked
- independently. The man page describes their use.
-
- The file also includes a macro MR_ALLOC_LINTOK that is simply a compact form
- of the commonly-occurring code to allocate memory if a (typically static)
- pointer is NULL and to reallocate it if the pointer isn't NULL.
-
- There are also macros to do some primitive exception handling of the memory
- allocation function. See the man page for more on these.
-
- As I developed it with my own resources, I'm releasing this code to the
- public domain. I hereby deny any responsibility for its use or any damages
- resulting from same.
-
- Nevertheless, if anyone has any problems with it, questions about it, or
- improvements to it, please let me know.
-
- - Bob Lewis
- bobl@tessi.uucp
-