home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / memlintok / README < prev    next >
Encoding:
Text File  |  1989-10-26  |  1.7 KB  |  53 lines

  1. "memlintok.h" is a header file that can be used to politely shut lint(1) up
  2. about casting results of memory allocation functions malloc(3), realloc(3),
  3. and calloc(3).  It also stops complaints about the argument of free(3).
  4.  
  5. CONTENTS
  6. --------
  7. Files in this distribution are:
  8.  
  9. README            you're reading it
  10. Makefile        has several useful targets, including "install" and "test"
  11. good            good results for "make test"
  12. memlintok.3        man page
  13. memlintok.h        the header file itself
  14. t_memlintok.c    a test/demo program
  15.  
  16. DISCUSSION
  17. ----------
  18. One common way of ignoring lint errors is to do something like:
  19.  
  20.     #ifdef lint
  21.     #define malloc(arg) NULL
  22.     #endif
  23.  
  24. The trouble with doing things this way is that lint will not then be able to
  25. check malloc's argument, so you could get away with something like:
  26.  
  27.     char *p;
  28.     char *q;
  29.     ...
  30.     p = malloc(q);
  31.  
  32. The macros here are a bit more sophisticated, so that the memory functions
  33. get invoked in a syntactically correct and properly-typed (although
  34. semantically incorrect) fashion and the arguments get checked
  35. independently.  The man page describes their use.
  36.  
  37. The file also includes a macro MR_ALLOC_LINTOK that is simply a compact form
  38. of the commonly-occurring code to allocate memory if a (typically static)
  39. pointer is NULL and to reallocate it if the pointer isn't NULL.
  40.  
  41. There are also macros to do some primitive exception handling of the memory
  42. allocation function.  See the man page for more on these.
  43.  
  44. As I developed it with my own resources, I'm releasing this code to the
  45. public domain.  I hereby deny any responsibility for its use or any damages
  46. resulting from same.
  47.  
  48. Nevertheless, if anyone has any problems with it, questions about it, or
  49. improvements to it, please let me know.
  50.  
  51.     - Bob Lewis
  52.       bobl@tessi.uucp
  53.