home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sources / misc / 3901 < prev    next >
Encoding:
Text File  |  1992-09-04  |  55.3 KB  |  1,606 lines

  1. Newsgroups: comp.sources.misc
  2. Path: sparky!kent
  3. From: cpcahil@vti.com (Conor P. Cahill)
  4. Subject:  v32i010:  dbmalloc - Debug Malloc Library PL14, Part05/10
  5. Message-ID: <1992Sep4.152142.13264@sparky.imd.sterling.com>
  6. Followup-To: comp.sources.d
  7. X-Md4-Signature: 16ca4722707e9b9544c6ae8d9c6122dc
  8. Sender: kent@sparky.imd.sterling.com (Kent Landfield)
  9. Organization: Virtual Technologies, Inc., Dulles VA
  10. References: <csm-v32i005=dbmalloc.101423@sparky.IMD.Sterling.COM>
  11. Date: Fri, 4 Sep 1992 15:21:42 GMT
  12. Approved: kent@sparky.imd.sterling.com
  13. Lines: 1591
  14.  
  15. Submitted-by: cpcahil@vti.com (Conor P. Cahill)
  16. Posting-number: Volume 32, Issue 10
  17. Archive-name: dbmalloc/part05
  18. Environment: C, UNIX
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 5 (of 10)."
  27. # Contents:  malloc.3 mallocin.h
  28. # Wrapped by cpcahil@virtech on Thu Sep  3 18:39:19 1992
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'malloc.3' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'malloc.3'\"
  32. else
  33. echo shar: Extracting \"'malloc.3'\" \(42916 characters\)
  34. sed "s/^X//" >'malloc.3' <<'END_OF_FILE'
  35. X.TH DEBUG_MALLOC 3 "VTI" "" "1.11"
  36. X.ds ]T 
  37. X'\"/*
  38. X'\" * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com).
  39. X'\" *
  40. X'\" * This software may be distributed freely as long as the following
  41. X'\" * conditions are met:
  42. X'\" *
  43. X'\" *         * the distribution, or any derivative thereof, may not be
  44. X'\" *          included as part of a commercial product
  45. X'\" *        * full source code is provided including this copyright
  46. X'\" *        * there is no charge for the software itself (there may be
  47. X'\" *          a minimal charge for the copying or distribution effort)
  48. X'\" *        * this copyright notice is not modified or removed from any
  49. X'\" *          source file
  50. X'\" */
  51. X'\" 
  52. X'\" $Id: malloc.3,v 1.28 1992/08/22 16:27:13 cpcahil Exp $
  53. X'\" 
  54. X'\" eX macro -  this macro is used to set up code/picture examples.  It changes
  55. X'\"             the point size & type of font, indents the example 1/2 inch,
  56. X'\"        and turns off fill mode.  To use it just place a .eX before and
  57. X'\"        after your example
  58. X.de eX
  59. X.ie \\n(eX>0 \{\
  60. X.nr eX 0
  61. X.if t .ft
  62. X.fi
  63. X.vs
  64. X.ps
  65. X.in
  66. X.sp \}
  67. X.el \{\
  68. X.nr eX 1
  69. X.br
  70. X.ne 5
  71. X.sp
  72. X.ie \\n(.$>0 .in +\\$1
  73. X.el .in +.5i
  74. X.ie \\n(.$=2 .ps -\\$2
  75. X.el .ps -2
  76. X.ie \\n(.$=2 .vs -\\$2
  77. X.el .vs -2
  78. X.if t .ft CW
  79. X.nf \}
  80. X..
  81. X.nr eX 0
  82. X'\" 
  83. X'\" fake set of VL LI and LE macros for man pages.  This set does handle nested
  84. X'\" calls, but does absolutely NO error checking (so you better do it right).
  85. X'\" 
  86. X.de VL
  87. X.br
  88. X.ie t .nr VL 0\\$1
  89. X.el .nr VL 0\\$1*2
  90. X.ds VS \\$1 \\*(VS
  91. X.in +\\n(VL
  92. X.if t .in +.25i
  93. X..
  94. X.de LI
  95. X.br
  96. X.ti -\\n(VL
  97. X.nr Vw \\n(VLm-\w'\\$1'
  98. X.if \w'\\$1' \&\\$1\h'\\n(Vwu'\&\\c
  99. X..
  100. X.de LE
  101. X.br
  102. X.Le \\*(VS 
  103. X..
  104. X.de Le
  105. X.in -\\n(VL
  106. X.if t .in -.25i
  107. X.ie t .nr VL \\$2
  108. X.el .nr VL \\$2*2
  109. X.ds VS \\$2 \\$3 \\$4 \\$5 \\$6 \\$7
  110. X..
  111. X.ds VS
  112. X.nr VL 0
  113. X.de MP
  114. X.ie t .sp \\n(PDu
  115. X.el .sp
  116. X..
  117. X.de P
  118. X.br
  119. X.ne 4
  120. X.sp
  121. X..
  122. X.SH NAME
  123. Xdbmalloc \- debugging malloc library
  124. X.SH SYNOPSIS
  125. X.nf
  126. X\fB#include <malloc.h>
  127. X.MP
  128. Xint malloc_chain_check(flag);
  129. Xint flag;
  130. X.MP
  131. Xvoid malloc_dump(fd);
  132. Xint fd;
  133. X.MP
  134. Xvoid malloc_list(fd,histid1,histid2);
  135. Xint fd;
  136. Xunsigned long histid1, histid2;
  137. X.MP
  138. Xunsigned long malloc_inuse(histidptr);
  139. Xunsigned long * histidptr;
  140. X.MP
  141. Xvoid malloc_mark(ptr);
  142. Xchar    * ptr;
  143. X.MP
  144. Xint dbmallopt(cmd,val);
  145. Xint cmd; 
  146. Xunion dbmalloptarg val;
  147. X.MP
  148. Xvoid malloc_abort();
  149. X.MP
  150. Xvoid malloc_enter(func);
  151. Xchar * func;
  152. X.MP
  153. Xvoid malloc_leave(func);
  154. Xchar * func;\fP
  155. X.fi
  156. X.SH DESCRIPTION
  157. XThis malloc library is a replacement for the standard library to be used
  158. Xduring software development/debugging.  See the standard malloc(3) pages
  159. Xfor more information on the use of the following functions:
  160. X.MP
  161. X.nf
  162. X.in +.5i
  163. X\fBcalloc\fP(), \fBcfree\fP(), \fBfree\fP(), \fBmalloc\fP(), \fBrealloc\fP()
  164. X.in -.5i
  165. X.fi
  166. X.MP
  167. XThis library differs from the standard malloc library in the
  168. Xfollowing ways:
  169. X.P
  170. X1. Each malloc segment contains a magic number so that free can 
  171. Xverify that the pointer passed points to a valid malloc segment.
  172. X.P
  173. X2. Each malloc segment is filled with a non-zero pattern so that code that
  174. Xdepends upon malloc segments being null will fail.
  175. X.P
  176. X.ne 5
  177. X3. The size of each segment will be at least 1 byte larger than requested
  178. Xand the extra bytes will be filled with a non-zero pattern.  When free is
  179. Xcalled, it will verify that you did not go beyond the number of bytes 
  180. Xyou asked for.
  181. X.P
  182. X4. When a segment is freed, it will be filled with a different non-zero pattern
  183. Xto ensure that the program doesn't depend upon the use of already freed data.
  184. X.P
  185. X.ne 5
  186. X5. Whenever any of the string or memory functions (str*, b*, mem*) are 
  187. Xcalled with a pointer that is within the malloc arena,  the operation is
  188. Xchecked to verify that it does not overrun the malloced segment.  A failure
  189. Xof this check is considered a "warning level error" (described later) and
  190. Xis handled accordingly.
  191. X.P
  192. X6. Run time checking can include verification of the malloc chain at each
  193. Xand every call to one of the malloc functions or manually by calling the
  194. Xmalloc_chain_check function.
  195. X.P
  196. X7. Extensive support for tracking memory leaks is provided.
  197. X.P
  198. X.br
  199. X.ne 15
  200. XWhen a problem is found, the following error message is displayed:
  201. X.eX
  202. XMALLOC Warning from funcname() (called from filename.c line ###):
  203. XWarning message goes here
  204. X.eX
  205. X\fBfuncname\fP is the name of the function that has found the problem
  206. Xand will usually be an entry point into the library.  The information
  207. Xthat identifies where the function is called from will only be 
  208. Xavailable if the source module was compiled with the \fBmalloc.h\fP
  209. Xfile included.
  210. X.P
  211. XIf the error is caused by a problem in the malloc chain and the offending
  212. Xchain element can be identified, the following information is also
  213. Xdisplayed (NOTE: this is just a guess by the software, it may not
  214. Xbe the actual culprit):
  215. X.eX
  216. XThis error is *probably* associated with the following allocation:
  217. X
  218. X   A call to malloc for 33 bytes in program.c on line 834.
  219. X   This was the 172nd call to malloc.
  220. X.eX
  221. X.br
  222. X.ne 15
  223. XThis example assumes that \fBprogram.c\fP included the debugging 
  224. Xlibrary \fBmalloc.h\fP file.  If not, the identification information
  225. Xwill be as follows:
  226. X.eX
  227. XThis error is *probably* associated with the following allocation:
  228. X
  229. X   A call to malloc for 33 bytes in an unknown file.
  230. X   This was the 172nd call to malloc.
  231. X.eX
  232. XThe identification of which call to malloc is associated with the 
  233. Xproblem is helpful in that it gives you the information necessary
  234. Xto set the breakpoint on the allocation function for that particular
  235. Xinvocation (breakpoints usually can have counters associated with
  236. Xthem).  The counters for the three primary allocation entry points (malloc,
  237. Xcalloc, and realloc) are managed separately.
  238. X.P
  239. X.br
  240. X.ne 5
  241. XNOTE 1: if you want to set a breakpoint to capture this invocation
  242. Xof malloc, the actual function that is being called is \fBdebug_malloc\fP
  243. X(or \fBdebug_realloc\fP for \fBrealloc\fP and \fBdebug_calloc\fP for
  244. X\fBcalloc\fP) and that is where the breakpoint should be set.
  245. X.P
  246. X.br
  247. X.ne 19
  248. XNOTE 2: Since the software is guessing at the offending malloc
  249. Xchain segment, it is possible that one of the nearby segments 
  250. Xis actually the culprit.  If the environment variable \s-2MALLOC_SHOW_LINKS\s+2
  251. Xis set, both the segment preceding and the segment following the accused
  252. Xsegment will also be identified.  The following is a sample output:
  253. X.eX
  254. XThis error is *probably* associated with the following allocation:
  255. X
  256. X    A call to malloc for 33 bytes in an unknown file.
  257. X    This was the 172nd call to malloc.
  258. X
  259. X    The malloc chain element prior to the suspect allocation is from:
  260. X
  261. X    A call to calloc for 512 bytes in main.c line 16.
  262. X    This was the 4th call to calloc. 
  263. X    This block was freed on the 2nd call to free()
  264. X    in main.c on line 51.
  265. X    The malloc chain element following the suspect allocation is from: 
  266. X
  267. X    A call to realloc for 4096 bytes in func.c line 376.
  268. X    This was the 1st call to realloc.
  269. X.eX
  270. X.br
  271. X.ne 15
  272. XOnce the error message has been displayed, the software will then 
  273. Xdetermine how to handle the error.  This handling will be based upon
  274. Xthe type of error level (warning or fatal) and the error handling in effect
  275. Xfor that error level (as specified by calls to mallopt or via environment
  276. Xvariables).  The coding for the error handling is as follows:
  277. X.MP
  278. X.VL 3
  279. X.LI "\0\00"
  280. Xcontinue operations
  281. X.LI "\0\01"
  282. Xdrop core and exit
  283. X.LI "\0\02"
  284. Xjust exit
  285. X.LI "\0\03"
  286. Xdrop core, but continue executing.  Core files will
  287. Xbe placed into core.[PID].[counter] i.e: core.00123.001
  288. X.LI "128"
  289. Xdump malloc chain and continue
  290. X.LI "129"
  291. Xdump malloc chain, dump core, and exit
  292. X.LI "130"
  293. Xdump malloc chain, exit
  294. X.LI "131"
  295. Xdump malloc chain, dump core, continue processing
  296. X.LE
  297. X.P
  298. X\fBdbmallopt\fP() is used to set the malloc debugging options. The
  299. Xfollowing options can be set:
  300. X.MP
  301. X.VL 10
  302. X.LI "\s-2MALLOC_WARN\s+2"
  303. Xset the error handling for warning level errors.  \fBval.i\fP is
  304. Xan integer that can contain any one of the following values:
  305. X.MP
  306. X.VL 10
  307. X.LI "\s-2M_HANDLE_IGNORE\s+2"
  308. Xignore error (just display warning message and continue processing)
  309. X.LI "\s-2M_HANDLE_ABORT\s+2"
  310. Xdrop core and exit
  311. X.LI "\s-2M_HANDLE_EXIT\s+2"
  312. Xjust exit (no core drop)
  313. X.LI "\s-2M_HANDLE_CORE\s+2"
  314. Xdrop core, but keep on going
  315. X.LE
  316. X.MP
  317. XIn addition, \s-2M_HANDLE_DUMP\s+2 may be or'd in to cause a dump
  318. Xof the current malloc chain.
  319. X.MP
  320. XThe default action for \s-2MALLOC_WARN\s+2 is \s-2M_HANDLE_IGNORE\s+2.
  321. X.MP
  322. X.LI "\s-2MALLOC_FATAL\s+2"
  323. Xset the error handling for fatal level errors.  \fBval.i\fP is
  324. Xequivalent to \fBval.i\fP for \s-2MALLOC_WARN\s+2.
  325. X.MP
  326. XThe default action for \s-2MALLOC_FATAL\s+2 is \s-2M_HANDLE_ABORT\s+2.
  327. X.MP
  328. X.LI "\s-2MALLOC_ERRFILE\s+2"
  329. Xset the destination for malloc error messages.  \fBval.str\fP
  330. Xis a pointer to a character string containing the name of the file to be used
  331. Xfor error messages.  Note that error messages are \s-1APPENDED\s+1 to this
  332. Xfile, so existing error messages will not be removed.
  333. X.MP
  334. XIf \s-2MALLOC_ERRFILE\s+2 is not set, all error messages will be sent
  335. Xto \fBstderr\fP.
  336. X.MP
  337. X.ne 3
  338. X.LI "\s-2MALLOC_CKCHAIN\s+2"
  339. Xset the malloc chain checking flag.  If \fBval.i\fP is
  340. Xnon-zero, chain checking at every call to malloc is turned on. The 
  341. Xdefault behavior is to not check the chain at each call to malloc because
  342. Xof performance issues (the library is considerably slower when this 
  343. Xfunction is enabled).
  344. X.MP
  345. X.ne 10
  346. X.LI "\s-2MALLOC_FREEMARK\s+2"
  347. Xsets the behavior of freeing of marked areas.  By default, a free of a 
  348. Xmarked segment generates a warning.  If \fBval.i\fP is zero, warnings will
  349. Xnot be generated.
  350. X.MP
  351. X.ne 10
  352. X.LI "\s-2MALLOC_FILLAREA\s+2"
  353. Xset the malloc fill area flag.  \fBval.i\fP specifies the malloc filling
  354. Xmode to be used.   There are four modes: 0, 1, 2 and 3.  Mode 0 disables
  355. Xall filling and checking of filled areas (thereby reducing the effectiveness
  356. Xof the library).  Mode 1 enables the filling of boundary areas before and
  357. Xafter the allocation areas which are used to check for writing before
  358. Xor after the pointer.  Mode 2 includes mode 1 and adds the filling of
  359. Xmalloced regions with a specified fill pattern so that a program does not
  360. Xdepend upon malloced regions to be filled with zeros.  Mode 3 includes
  361. Xall of mode 2 and adds the filling of free'd regions so that an attempt
  362. Xto used a freed data area will result in an error.
  363. X.MP
  364. XAs far as performance is concerned, mode 0 will be the fastest mode, 
  365. Xwhile (somewhat unexpectedly) mode 3 is the next "fastest" mode 
  366. Xwith mode 1 bring up the tail end. 
  367. X.MP
  368. XThe default behavior for \s-2MALLOC_FILLAREA\s+2 is mode 3.
  369. X.MP
  370. X.LI "\s-2MALLOC_LOWFRAG\s+2"
  371. Xset the malloc allocation fragmentation handling level.  By default, malloc
  372. Xuses a first fit algorithm for new allocations.  Under certain allocation
  373. Xscenarios, this can lead to significant memory fragmentation because of
  374. Xthe fact that little allocations can break big blocks up.
  375. X.MP
  376. XIf \fBval.i\fP is non-zero, malloc uses a best fit algorithm which will reduce
  377. Xfragmentation.  This mechanism, while using less memory, is slower because
  378. Xthe entire free list is checked instead of just checking until we find a
  379. Xsegment that is at least big enough.  Normally you will not need to set
  380. Xthis variable.
  381. X.MP
  382. X.LI "\s-2MALLOC_CKDATA\s+2"
  383. Xenable/disable the checking of pointers passed to the memory (mem*,b*) and 
  384. Xstring (str*) functions.  This can be used to startup the code with
  385. Xchecking disabled (when you know the startup code is functioning correctly)
  386. Xand then turn it on later when you get into the area of the code that is 
  387. Xin question.
  388. X.MP
  389. Xif \fBval.i\fP is non-zero, pointer checking is enabled (which is the default
  390. Xmode).
  391. X.MP
  392. X.LI "\s-2MALLOC_REUSE\s+2"
  393. Xenable/disable the reuse of freed segments.  This option can be used to 
  394. Xhelp identify where a freed pointer is being re-used, or where it is being
  395. Xfreed a second time, since the location where it was freed is also kept.
  396. X.MP
  397. XIt should be noted that the memory requirements for a program will typically
  398. Xincrease significantly if this option is used.
  399. X.MP
  400. Xif \fBval.i\fP is zero, freed segments are not reused for subsequent
  401. Xallocations.   If non-zero, freed segments can be reused.  If freed segments
  402. Xare not re-used, you might want to disable filling of freed segments (see
  403. Xthe \s-2MALLOC_FILLAREA\s+2 discussions) so that you can see the data in the
  404. Xsegment - this would be fill mode 2 or below.
  405. X.LE
  406. X.MP
  407. X.ne 10
  408. XFor example, to set up the session to generate a core file for
  409. Xevery malloc warning, to drop core and exit on a malloc fatal, and 
  410. Xto log all messages to the file "malloc_log" do the following:
  411. X.eX
  412. X#include <malloc.h>
  413. Xunion dbmalloptarg  m;
  414. X
  415. Xm.i = M_HANDLE_CORE | M_HANDLE_DUMP;
  416. Xdbmallopt(MALLOC_WARN,m);
  417. X
  418. Xm.i = M_HANDLE_ABORT;
  419. Xdbmallopt(MALLOC_FATAL,m);
  420. X
  421. Xm.str = "malloc_log";
  422. Xdbmallopt(MALLOC_ERRFILE,m);
  423. X.eX
  424. X\fBdbmallopt\fP() can be used to set/alter the debugging options at any
  425. Xtime (i.e. you may want to turn on chain-checking after the program startup if
  426. Xthe program startup does a lot of allocations which are known to be OK).
  427. X.P
  428. X.ne 5
  429. X\fBmalloc_chain_check\fP() will check the status of the malloc arena.
  430. XIf \fBflag\fP is non-zero, an error found in the chain will cause a 
  431. Xfatal error.  \fBmalloc_chain_check\fP() returns zero when there are no
  432. Xproblems found in the malloc chain, non-zero otherwise.
  433. X.P
  434. X.ne 5
  435. X\fBmalloc_dump\fP() will dump a list of all in-use malloc segments 
  436. Xand the first few bytes of each segment.  If the environment variable
  437. X\s-1MALLOC_DETAIL\s+1 is set to a non-zero integer, all segments (including
  438. Xthose that have been freed) are listed and additional internal information
  439. Xis displayed.  \fBfd\fP is the file descriptor to write the data to.
  440. X.P
  441. X.ne 6
  442. X\fBmalloc_list\fP() will dump a list in the same format as \fBmalloc_dump\fP but
  443. Xonly the items that are still in use and which have been allocated within
  444. Xthe malloc history id range specified by \fBhistid1\fP and
  445. X\fBhistid2\fP, inclusive.  The \fBhistid\fPs are obtained from calls
  446. Xto \fBmalloc_inuse\fP(). This is especially useful in tracking down memory
  447. Xleaks.  \fBfd\fP is the file descriptor to write the data to.
  448. X.P
  449. X.ne 6
  450. X\fBmalloc_inuse\fP() returns the amount of malloc data that is currently
  451. Xin use (in bytes).  If \fBhistidptr\fP is not NULL, it is taken to be a pointer
  452. Xto a place to store the current malloc history id which can be used later
  453. Xwhen \fBmalloc_list\fP is called to list items that are still in use.
  454. X.P
  455. X.ne 10
  456. XThe following example shows the typical use of the \fBmalloc_inuse\fP and
  457. X\fBmalloc_list\fP functions in tracking down memory leaks:
  458. X.eX
  459. Xunsigned long    histid1, histid2, orig_size, current_size;
  460. X
  461. Xorig_size = malloc_inuse(&histid1);
  462. X
  463. X/* ..... go do lots of stuff ...... */
  464. X
  465. Xcurrent_size = malloc_inuse(&histid2);
  466. X
  467. Xif( current_size != orig_size )
  468. X{
  469. X    malloc_list(2,histid1,histid2);
  470. X}
  471. X.eX
  472. X\fBmalloc_mark\fP() marks a segment as a non-leak.  Segments that are marked
  473. Xare not counted or listed when dealing with memory leaks.  This is designed
  474. Xto be used on pointers that remain around forever and shouldn't be considered
  475. Xto be a leak (in order to decrease the amount of entries in the leak lists)
  476. X.P
  477. X\fBmalloc_abort\fP() causes the current program to drop core and exit.  This
  478. Xfunction simply calls \fBabort\fP() to do its dirty work and is here solely 
  479. Xfor the purpose of allowing the programmer to substitute thier own abort
  480. Xroutine to handle fatal errors.  If a substitute routine is used, it must not
  481. Xreturn to the caller or else the program will use the \fBabort\fP() system
  482. Xcall to cause the program to stop.
  483. X.P
  484. X\fBmalloc_enter\fP() and \fBmalloc_leave\fP() provide a rudimentary mechanism
  485. Xto track the calling stack that was in place when the allocation was made.
  486. XIn order to use this feature, the enter function should be called upon
  487. Xentry to a function, while the leave function is called when you exit
  488. Xfrom the function.  In order to be accurate, the two functions must be 
  489. Xused in conjunction with each other and a missing call will result in
  490. Xan error generated by the library (if it is detected).
  491. X.P
  492. XNOTE: the argument to either of these functions \fBmust\fP be a constant
  493. Xcharacter string or a static data area.  This is because the stack mechanism
  494. Xdoes not maintain it's own copy of these strings, it just records pointers
  495. Xto the strings and if the strings are on the stack, they will go away.
  496. XTypically the functions would be used with "funcname" as the argument and
  497. Xthis will avoid any problems.
  498. X.P
  499. XThe stack is listed on the dump and/or list reports and on an error 
  500. Xmessage for a segment that has already been freed.
  501. X.P
  502. XIf these functions have been used, error messages will include
  503. Xthe stack information when the identity of the error is 
  504. Xdisplayed.  For example:
  505. X.eX
  506. XThis error is *probably* associated with the following allocation:
  507. X
  508. X    A call to malloc for 1 bytes in teststack.c on line 75.
  509. X    This was the 13th call to malloc.
  510. X    Stack from where allocated:
  511. X     -> sub3() in teststack.c(73)
  512. X     -> sub2() in teststack.c(59)
  513. X     -> main() in teststack.c(23)
  514. X
  515. X.eX
  516. X.br
  517. X.br
  518. X.ne 20
  519. X.SH "USAGE"
  520. XThe library can be used in several modes, each increasingly intrusive (i.e. 
  521. Xrequiring changes to be made to the build process and/or source code).  However,
  522. Xthe extra cost of a little intrusiveness is repaid in much better problem
  523. Xidentification.  Each mode is built upon the previous modes and therefore
  524. Xrequires the changes and/or commands specified in the lower modes.
  525. X.P
  526. X.ne 10
  527. X\fBMODE 1 - library substitution\fP
  528. X.P
  529. XThe simplest use is to just link the object module with the \fBlibdbmalloc.a\fP.
  530. XBe sure to have this library before the C library (\fBlibc.a\fP) on the
  531. Xlink command (this is automatic if you use \fBcc\fP to link and specify the 
  532. Xdebug library without specifying the C library).
  533. X.P
  534. XThis mode links in all of the debug versions of the library modules and
  535. Xwill trap as many errors as it can (yes, there are errors that the malloc
  536. Xlibrary cannot catch).  Environment variables can be used to control the
  537. Xbehavior of the library.
  538. X.P
  539. X.ne 15
  540. X\fBMODE 2 - malloc.h inclusion\fP
  541. X.P
  542. XThis mode involves including the \fBmalloc.h\fP file included with the 
  543. Xdebugging library.  The malloc.h file includes macros that will identify
  544. Xthe source line and file name for each debugging function called.  This
  545. Xis how the library is able to tell you that it was the call to malloc
  546. Xon line 55 in file junk.c.
  547. X.P
  548. X.ne 8
  549. XTypically you should always include malloc.h in your source files and just
  550. Xuse the -I INCLUDEDIR directive for the compiler to point the compiler to
  551. Xthe debugging version of the header file instead of the normal file.  That
  552. Xway you don't have to change the source files when you want to turn off
  553. Xthe debugging library.
  554. X.P
  555. XNOTE: Once you compile code in this mode, you must recompile the code 
  556. Xwithout the debugging malloc.h include file in order to get the software
  557. Xto use the non-debugging functions.
  558. X.P
  559. X.ne 10
  560. X\fBMODE 3 - run-time specification of options\fP
  561. X.P
  562. XEnvironment variables can be used to control the behavior of the debugging
  563. Xlibrary to some extent.  However, this control is very coarse in that
  564. Xyou only have one setting available for the entire running of the program.
  565. X.P
  566. XThis can be a problem if you want to turn on malloc chain checking, but
  567. Xknow that the problem occurs between a relatively narrow portion of the
  568. Xcode and don't want to take the hit of having chain checking on for the
  569. Xentire program execution.  
  570. X.P
  571. X.ne 15
  572. XThe solution to this problem is to include calls to dbmallopt() with the
  573. Xdebugging options which set the appropriate modes when you want them set.
  574. XSince you don't want to have to change the code to remove and add these
  575. Xfunctions every time you decide to include malloc debugging or not, the 
  576. X\fBmalloc.h\fP file defines the preprocessor symbol \s-2_DEBUG_MALLOC_INC\s+2
  577. Xwhich can be used in your code as follows:
  578. X.eX
  579. X#ifdef _DEBUG_MALLOC_INC
  580. X    dbmallopt(.... );
  581. X#endif
  582. X.eX
  583. XIn addition to setting behavior options, you might want to make use of
  584. Xthe memory leak detection routines in this mode.  These calls should
  585. Xalso be surrounded by #ifdefs for the debug malloc symbol so that you
  586. Xcan leave them in the code and automatically get
  587. Xthe increased functionality whenever you compile with the debugging library.
  588. X.P
  589. X.ne 10
  590. X\fBMODE 4 - deeper inclusion of malloc calls\fP
  591. X.P
  592. XThis mode involves inserting calls to the special functions supported
  593. Xby the malloc library (like the leak detection or stack maintenance 
  594. Xroutines).  The effects of the inclusions depends upon the modules
  595. Xincluded and the amount to which they are used. 
  596. X.P
  597. XIt is strongly recommended that you setup your code with the following
  598. Xlines in a header file that is included by all modules, or just add the
  599. Xcode to the beginning of the modules themselves:
  600. X.eX
  601. X#ifndef _DEBUG_MALLOC_INC
  602. X#define malloc_enter(func)
  603. X#define malloc_leave(func)
  604. X#define malloc_chain_check()
  605. X#define malloc_dump(fd)
  606. X#define malloc_list(a,b,c)
  607. X#define malloc_inuse(hist)    (*(hist) = 0, 0)
  608. X#endif
  609. X.eX
  610. XThis will automatically disable the referenced functions when the malloc
  611. Xlibrary is not included (as should be the case when you make a production
  612. Xbuild).
  613. X.br
  614. X.ne 15
  615. X.SH "ENVIRONMENT VARIABLES"
  616. XEnvironment variables can be used to control error handling, error logging
  617. Xand malloc chain checking at run time.  Most of these environment variables
  618. Xcan be set via the \fBdbmallopt\fP() routine and are well described in 
  619. Xthat portion of the document.  Look for further information there.
  620. X.MP
  621. XThe following environment variables are used:
  622. X.P
  623. X.VL 10
  624. X.br
  625. X.ne 4
  626. X.LI "\s-2MALLOC_BOUNDSIZE\s+2"
  627. XThis specifies the minimum number of bytes that the allocation routines
  628. Xwill leave unused at the end of each segment.  This value may be
  629. Xany non-zero positive integer (although you must remember that the
  630. Xamount of memory used is directly related to this buffer area.
  631. X.MP
  632. XIt may be necessary to increase this value if you think you have a module
  633. Xthat is writing far enough beyond its malloc segment that it changes the
  634. Xnext segment (and therefore doesn't make a change that this library
  635. Xwould be able to detect.
  636. X.MP
  637. XThe default for this value is 1 (although because of memory alignment
  638. Xissues, you will usually have more than one byte of filler at the
  639. Xend of most segments).
  640. X.br
  641. X.ne 4
  642. X.LI "\s-2MALLOC_CKCHAIN\s+2"
  643. Xif 1, turns on malloc chain checking at every call to any
  644. Xof the malloc functions.
  645. X.br
  646. X.ne 4
  647. X.LI "\s-2MALLOC_DETAIL\s+2"
  648. Xif set to a non-zero integer, \fBmalloc_dump\fP shows some internal
  649. Xdetail for each 
  650. Xentry in the chain.  This info is probably only of use if you are debugging 
  651. Xthe malloc library itself.
  652. X.br
  653. X.ne 4
  654. X.LI "\s-2MALLOC_ERRFILE\s+2"
  655. Xspecifies the error log file for error messages.  Error messages generated
  656. Xby the library are \fBAPPENDED\fP to this file, so if you want a clean file,
  657. Xyou will have to remove or empty it yourself between runs.  If this option
  658. Xis used, no indication of an error will be sent to stdout or stderr (this 
  659. Xis purposefully done this way so that if you are running a full screen 
  660. Xprogram, it doesn't mess up the screen).
  661. X.br
  662. X.ne 4
  663. X.LI "\s-2MALLOC_FATAL\s+2"
  664. Xspecifies the error handling for fatal errors
  665. X.br
  666. X.ne 4
  667. X.LI "\s-2MALLOC_FILLAREA\s+2"
  668. Xspecifies the fill area flag setting.  If zero, malloc/free area filling 
  669. Xand checking is disabled (thereby increasing performance, while decreasing
  670. Xeffectiveness of the library).  See the discussion of the \fBdbmallopt\fP()
  671. Xarguments for more info on other settings.
  672. X.br
  673. X.ne 5
  674. X.LI "\s-2MALLOC_FILLBYTE\s+2"
  675. XThis specifies the integer value of the character to use when filling
  676. Xallocated areas.  This value defaults to 1 and must be within the range
  677. Xof 0 - 255. This capability is useful if you believe that you are 
  678. Xhaving a problem with code that is trashing its malloc region with
  679. Xa data pattern that matches the default fill pattern.
  680. X.MP
  681. XNOTE: if an attempt is made to use a value outside the specified
  682. Xrange, the new value is \fBsilently\fP ignored and the default is used.
  683. X.br
  684. X.ne 5
  685. X.LI "\s-2MALLOC_FREEBYTE\s+2"
  686. XThis specifies the integer value of the character to use when filling
  687. Xfreed areas.  This value defaults to 1 and must be within the range
  688. Xof 0 - 255. It should also be different from \s-2MALLOC_FILLBYTE\s+2, but
  689. Xthat is not enforced. 
  690. X.MP
  691. XNOTE: if an attempt is made to use a value outside the specified
  692. Xrange, the new value is \fBsilently\fP ignored and the default is used.
  693. X.br
  694. X.ne 4
  695. X.LI "\s-2MALLOC_LOWFRAG\s+2"
  696. Xif 1, turns on best fit allocation algorithm.  Otherwise, first fit algorithm
  697. Xis used for finding allocation segments (which can cause memory fragmentation).
  698. X.br
  699. X.ne 4
  700. X.LI "\s-2MALLOC_CKDATA\s+2"
  701. Xif 0, disables checking of pointers passed to string/memory functions for
  702. Xmalloc region overwrites.
  703. X.br
  704. X.ne 4
  705. X.LI "\s-2MALLOC_REUSE\s+2"
  706. Xif 0, disables reuse of freed memory segments and it does not fill free'd
  707. Xsegments with the fill pattern.  If 1, freed segments are filled and they can
  708. Xbe reused.  If 2, freed segments can be reused, but they are not filled when
  709. Xfreed.
  710. X.br
  711. X.ne 4
  712. X.LI "\s-2MALLOC_SHOW_LINKS\s+2"
  713. Xwhen an error is found, the suspected allocation is
  714. Xdisplayed.  However, since it is possible that the next or previous allocation
  715. Xin the malloc chain was the actual culprit these links may be of interest.
  716. XIf this variable is set to a non-zero integer (i.e. 1) the links will also
  717. Xbe shown.
  718. X.br
  719. X.ne 2
  720. X.LI "\s-2MALLOC_WARN\s+2"
  721. Xspecifies the error handling for warning errors
  722. X.LE
  723. X.P
  724. X.ne 5
  725. XAs an example, to set up the session to generate a core file for
  726. Xevery malloc warning, to drop core and exit on a malloc fatal, and 
  727. Xto log all messages to the file "malloc_log" do the following:
  728. X.eX
  729. XMALLOC_WARN=131
  730. XMALLOC_FATAL=1
  731. XMALLOC_ERRFILE=malloc_log
  732. X
  733. Xexport MALLOC_WARN MALLOC_FATAL MALLOC_ERRFILE
  734. X.eX
  735. X.br
  736. X.ne 15
  737. X.SH "ERROR MESSAGES"
  738. XThe following error messages are reported by the library:
  739. X.VL 15
  740. X.br
  741. X.MP
  742. X.ne 6
  743. X.LI "\s-2M_CODE_BAD_CONNECT\s+2"
  744. XPointers between this segment and adjoining segments are invalid.
  745. X.MP
  746. XThis error indicates that the malloc chain has been corrupted.
  747. XThis is most often caused by an overwrite of the malloc header
  748. Xby an access via the previous malloc segment.
  749. X.br
  750. X.MP
  751. X.ne 6
  752. X.LI "\s-2M_CODE_BAD_MAGIC\s+2"
  753. XMalloc region does not have a valid magic number in header.
  754. X.MP
  755. XThis error is caused by several mechanisms including \fBfree\fP()ing
  756. Xthe same pointer twice or a pointer that was not returned by \fBmalloc\fP(),
  757. Xor writing beyond the end of a segment.
  758. X.br
  759. X.MP
  760. X.ne 6
  761. X.LI "\s-2M_CODE_BAD_PTR\s+2"
  762. XPointer is not within malloc region.
  763. X.MP
  764. XThe pointer passed to \fBfree\fP or\fPrealloc\fP is not pointer 
  765. Xreturned by \fBmalloc\fP.  Another cause is corruption of the
  766. Xmalloc chain by writing beyond the end of a segment.
  767. X.br
  768. X.MP
  769. X.ne 6
  770. X.LI "\s-2M_CODE_CHAIN_BROKE\s+2"
  771. XMalloc chain is corrupted, pointers out of order.
  772. X.MP
  773. XCorruption has been detected in the malloc chain that is
  774. Xrelated to the relative positions of the malloc chain segments
  775. Xin memory.  This is an indication that someone has overwritten
  776. Xbeyond the amount they allocated.
  777. X.br
  778. X.MP
  779. X.ne 6
  780. X.LI "\s-2M_CODE_FREELIST_BAD\s+2"
  781. XMalloc segment in free list is in-use.
  782. X.MP
  783. XA segment that is in the free-list is flagged as in-use.  This is usually
  784. Xcaused by overwriting from the previous segment in the malloc chain.
  785. X.br
  786. X.MP
  787. X.ne 6
  788. X.LI "\s-2M_CODE_FREEMARK\s+2"
  789. XFree called to free a segment that has been marked.
  790. X.MP
  791. XMarking a segment is done because you believe that the segment will not be
  792. Xfree'd and therefore don't want it to appear in the list of possible leaks.
  793. XIf you then go on to free it, perhaps it shouldn't have been marked.  
  794. X.MP
  795. XThis error message can be disabled with the MALLOC_FREEMARK option on 
  796. Xthe \fBdbmallopt\fP() function.
  797. X.br
  798. X.MP
  799. X.ne 6
  800. X.LI "\s-2M_CODE_NOBOUND\s+2"
  801. XUnable to determine doubleword boundary
  802. X.MP
  803. XThe code was unable to figure out the boundary requirements for a doubleword.
  804. XThis error should never occur.
  805. X.br
  806. X.MP
  807. X.ne 6
  808. X.LI "\s-2M_CODE_NOMORE_MEM\s+2"
  809. XUnable to get additional memory from the system.
  810. X.MP
  811. XThe system call \fBsbrk\fP failed to obtain more memory
  812. Xfor the program.
  813. X.br
  814. X.MP
  815. X.ne 6
  816. X.LI "\s-2M_CODE_NOT_INUSE\s+2"
  817. XData is not in use (can't be freed or reallocated).
  818. X.MP
  819. XA pointer to a malloc segment has been passed to \fBfree\fP() or
  820. X\fBrealloc\fP(), but this segment has already been freed.
  821. X.br
  822. X.MP
  823. X.ne 6
  824. X.LI "\s-2M_CODE_NO_END\s+2"
  825. XMalloc chain is corrupted, end before end pointer.
  826. X.MP
  827. XYet another overwrite problem.   This error means that we got to 
  828. Xwhat we believe is the end of the chain, but it does not match
  829. Xthe recorded end of the chain.
  830. X.br
  831. X.MP
  832. X.ne 6
  833. X.LI "\s-2M_CODE_OUTOF_BOUNDS\s+2"
  834. XPointer within malloc region, but outside of malloc data bounds.
  835. X.MP
  836. XThis is caused by a call to one of the string/memory functions
  837. Xthat attempt to read/write bytes that are not included in
  838. Xthe allocation associated with that memory.  This is the
  839. Xmost typical error that you will see from the malloc library.
  840. X.br
  841. X.MP
  842. X.ne 6
  843. X.LI "\s-2M_CODE_OVERRUN\s+2"
  844. XData has overrun beyond requested number of bytes.
  845. X.MP
  846. XThis error is detected by \fBfree\fP() and indicates that the
  847. Xcurrent segment has written data beyond the number of bytes that
  848. Xit requested.  This only catches overwrites when they are within
  849. Xthe extra space allocated with each segment (this can range from
  850. Xone to eight bytes).  If the overwrite occurs further along it
  851. Xwill usually cause some corruption in the malloc chain.
  852. X.br
  853. X.MP
  854. X.ne 6
  855. X.LI "\s-2M_CODE_REUSE\s+2"
  856. XData in free'd area has been modified.
  857. X.MP
  858. XData in a freed segment has been modified.  This usually indicates
  859. Xthat the program is using a pointer after it called free, but it
  860. Xmay also be caused by an overwrite from a previous segment in 
  861. Xthe chain.
  862. X.br
  863. X.MP
  864. X.ne 6
  865. X.LI "\s-2M_CODE_STK_BADFUNC\s+2"
  866. XCurrent function name doesn't match name on stack.
  867. X.MP
  868. X\fBmalloc_leave\fP() was called with a function name that is not
  869. Xthe current function.  This is usually caused by a missing call
  870. Xto \fBmalloc_enter\fP() in the same function, or a missing call
  871. Xto \fBmalloc_leave\fP() in a sub-function.
  872. X.br
  873. X.MP
  874. X.ne 6
  875. X.LI "\s-2M_CODE_STK_NOCUR\s+2"
  876. XNo current function on stack, probably missing call to malloc_enter().
  877. X.MP
  878. X\fBmalloc_leave\fP() was called with a function name and there is 
  879. Xno current function (the stack is empty). This is usually caused
  880. Xby a missing call to \fBmalloc_enter\fP(), or an extra call to 
  881. X\fBmalloc_leave\fP() in the same function.
  882. X.br
  883. X.MP
  884. X.ne 6
  885. X.LI "\s-2M_CODE_UNDERRUN\s+2"
  886. XData has written before beginning of requested bytes.
  887. X.MP
  888. XThis error is detected by \fBfree\fP() and indicates that the current
  889. Xsegment has written data before the beginning of the requested block.
  890. XThis only catches overwrites when they are within the extra space
  891. Xallocated before each segment (this is usually four bytes).  If the
  892. Xoverwrite occurs further back it will usually cause some corruption in
  893. Xthe malloc chain.
  894. X.br
  895. X.MP
  896. X.ne 6
  897. X.LI "\s-2M_CODE_ZERO_ALLOC\s+2"
  898. XAn allocation routine was called to allocate zero bytes.
  899. X.MP
  900. XWhile ANSI C requires that allocations of zero bytes are permissible and
  901. Xshould be supported, the behavior of such an operation can be undefined on
  902. Xnon-ANSI systems.  This warning will alert you to the locations where these
  903. Xcalls are made.
  904. X.MP
  905. XThis error message can be disabled with the MALLOC_ZERO option on 
  906. Xthe \fBdbmallopt\fP() function.
  907. X.LE
  908. X.P
  909. X.br
  910. X.ne 15
  911. X.SH "DUMP OUTPUT"
  912. XSample dump/list output:
  913. X.eX
  914. X************************** Dump of Malloc Chain ****************************
  915. XPOINTER     FILE  WHERE         LINE      ALLOC        DATA     HEX DUMP   
  916. XTO DATA      ALLOCATED         NUMBER     FUNCT       LENGTH  OF BYTES 1-7 
  917. X-------- -------------------- ------- -------------- ------- --------------
  918. X0x403DB4 teststack.c               75 malloc(1)           40 01010101010101  
  919. X         -> sub3() in teststack.c(73)
  920. X         -> main() in teststack.c(23)
  921. X0x403E0C testerr.c                 16 realloc(1)          20 01010101010101  
  922. X.eX
  923. XThe info in each column is as follows:
  924. X.MP
  925. X.VL 10
  926. X.br
  927. X.ne 4
  928. X.LI "\s-2POINTER\s+2"
  929. Xthe pointer returned by the allocation function (the pointer
  930. Xthe the allocated data area).
  931. X.MP
  932. X.br
  933. X.ne 8
  934. X.LI "\s-2FILE\s+2"
  935. Xthe name of the file where the allocation function was called.  This
  936. Xinformation is only available if the source file includes the \fBmalloc.h\fP
  937. Xfile from this library (as opposed to the system include file).  If
  938. Xthe source file did not include this file, the file will be listed
  939. Xas unknown and the line number will be blank.
  940. XNote that any malloc calls from system libraries will probably not have been
  941. Xcompiled with the \fBmalloc.h\fP file included and will therefore
  942. Xappear as unknown.
  943. X.MP
  944. X.br
  945. X.ne 4
  946. X.LI "\s-2LINE NUM\s+2"
  947. XThe line number of the line that called the allocation function.  This 
  948. Xfield will be left blank if the \fBmalloc.h\fP from this library
  949. Xwas not included in the source file when it was compiled. 
  950. X.MP
  951. X.br
  952. X.ne 5
  953. X.LI "\s-2ALLOC FUNC\s+2"
  954. XThe allocation function called: \fBmalloc\fP, \fBrealloc\fP, or \fBcalloc\fP.
  955. XThe number in parenthesis following the function name is the call number
  956. Xfor that particular function.  For example: malloc(1) means that this
  957. Xallocation was the 1st call to malloc.
  958. X.MP
  959. X.br
  960. X.ne 2
  961. X.LI "\s-2DATA LEN\s+2"
  962. XThe number of bytes allocated.
  963. X.MP
  964. X.br
  965. X.ne 6
  966. X.LI "\s-2HEX DUMP\s+2"
  967. XA hexadecimal dump of the first seven bytes in the allocated data.  This example
  968. Xshows the bytes filled with 0x01s which happen to be the fill pattern used
  969. Xby the malloc library (to make sure that one doesn't depend upon the 
  970. Xfact that some calls to malloc result in NULL bytes).  So the
  971. Xallocations that are shown haven't stored any data in the area yet.
  972. X.LE
  973. X.MP
  974. XThe lines that begin with a "->" are stack dump lines which show the
  975. Xcalling environment that was present when the are was allocated.  The
  976. Xenvironment is managed via the use of the \fBmalloc_enter\fP() and 
  977. X\fBmalloc_leave\fP() routines.
  978. X.MP
  979. X.br
  980. X.ne 15
  981. XIf the environment variable \s-2MALLOC_DETAIL\s+2 is non-zero, the 
  982. Xfollowing additional information will be included:
  983. X.eX
  984. X************************************************************** Du... 
  985. X                             FREE     FREE                  ACTUAL SIZE    ...
  986. X  PTR      NEXT     PREV     NEXT     PREV      FLAGS       INT    HEX     ...
  987. X-------- -------- -------- -------- -------- ---------- -------- --------- ...
  988. X0x403C94 0x403CEC 0x40326C 0x000000 0x000000 0x03156111       48(0x000030) ...
  989. X0x403CEC 0x403D2C 0x403C94 0x000000 0x000000 0x03156121       24(0x000018) ...
  990. X0x403D2C 0x403D6C 0x403CEC 0x000000 0x403D6C 0x03156120       24(0x000018) ...
  991. X0x403D6C 0x000000 0x403D2C 0x403D2C 0x000000 0x03156120       24(0x000018) ...
  992. X
  993. XMalloc start:      0x40326C
  994. XMalloc end:        0x403D2C
  995. XMalloc data start: 0x403C94
  996. XMalloc data end:   0x405C94
  997. XMalloc free list:  0x403D6C
  998. X                -> 0x403D2C
  999. X.eX
  1000. XNOTE that I cut off the example at the point where the normal output
  1001. Xwould begin (hence the ...).
  1002. X.MP
  1003. XThe info in each column is as follows:
  1004. X.MP
  1005. X.VL 8
  1006. X.LI "\s-2PTR\s+2"
  1007. XThe malloc chain pointer for the segment (the address of the segment).
  1008. X.MP
  1009. X.LI "\s-2NEXT\s+2"
  1010. XThe pointer to the next segment in the chain.
  1011. X.MP
  1012. X.LI "\s-2PREV\s+2"
  1013. XThe pointer to the previous segment in the chain.
  1014. X.MP
  1015. X.LI "\s-2FREE NEXT\s+2"
  1016. XThe pointer to the next segment in the free list.
  1017. X.MP
  1018. X.LI "\s-2FREE PREV\s+2"
  1019. XThe pointer to the previous segment in the free list.
  1020. X.MP
  1021. X.ne 10
  1022. X.LI "\s-2FLAGS\s+2"
  1023. XThe flags associated with this segment.  This is a long
  1024. Xinteger which contains the following fields
  1025. X.MP
  1026. X.VL 6
  1027. X.LI "0xFFFFFF00"
  1028. Xthe magic number.  This should be 0x03156100 (probably 
  1029. Xsomeone's birthday).
  1030. X.MP
  1031. X.LI "0x00000070"
  1032. Xthe type of allocation function. Malloc (x010), realloc (0x20), or
  1033. Xcalloc (0x30) are the only valid values for this field).
  1034. X.MP
  1035. X.LI "0x00000001"
  1036. Xthe in-use flag.  if this value is non-zero, the indicated segment
  1037. Xis currently in use (not freed).
  1038. X.LE
  1039. X.MP
  1040. X.LI "\s-2ACTUAL SIZE\s+2"
  1041. XThe actual size reserved for the allocation in both decimal and
  1042. Xhex.  This will be at least one byte more than the requested size, and
  1043. Xas much as 8, so that we can check to see if the allocation has been
  1044. Xoverrun.
  1045. X.LE
  1046. X.MP
  1047. X.ne 4
  1048. XMalloc \fBstart\fP and \fBend\fP are pointers to the first and
  1049. Xlast malloc chain segment, respectively.
  1050. X.MP
  1051. X.ne 4
  1052. XMalloc \fBdata start\fP and \fBdata end\fP are the lowest and highest
  1053. Xdata bytes managed my the malloc sub-system.  These are only used as
  1054. Xa quick check to see if a pointer is in the malloc region before we
  1055. Xgo hunting down the chain trying to identify the segment it belongs to.
  1056. X.MP
  1057. X.ne 4
  1058. XMalloc \fBfree list\fP is a chain of the elements in the free list (so 
  1059. Xit is easier for the programmer to follow the free list if they choose 
  1060. Xto).  The address of each element in the list follows below the list head.
  1061. X.br
  1062. X.ne 15
  1063. X.SH "X PROGRAM DEBUGGING"
  1064. XThe malloc library includes a set of compatibility routines for the 
  1065. XXt toolkit allocation routines: \fBXtMalloc\fP(), \fBXtCalloc\fP(),
  1066. X\fBXtRealloc\fP(),and \fBXtFree\fP().   These routines provide the
  1067. Xsame level of malloc area integrity checking that is provided by
  1068. Xthe basic malloc functions while maintaining complete compatibility
  1069. Xwith the X11R5 functions.
  1070. X.P
  1071. XIf you link an X package with the debug library and you make a call
  1072. Xto any of the Xt allocation routines, the debug modules will automatically
  1073. Xbe included.  If you don't call them directly, but you still want to
  1074. Xinclude them in order to better debug their use, you can add a -u
  1075. Xlinker specification for XtRealloc.  For example:
  1076. X.eX
  1077. Xcc -o xapp -u XtRealloc xapp.o -ldbmalloc -lXt -lX....
  1078. X.eX
  1079. XNote that you may have to add an underscore before the XtRealloc if your
  1080. Xcompiler does this automatically.
  1081. X.P
  1082. XA second potential problem with X is caused by a difference between
  1083. XX11R4 and X11R5.  If you only have one of theses packages, then the
  1084. Xmalloc library will be automatically configured to handle that package.
  1085. XIf, however, you have both of them installed and you need to be able
  1086. Xto link with either system, you may have to add a -u _XtHeapInit to
  1087. Xthe link line on the X11R5 links.  This is because X11R5 defines both
  1088. Xthe heap management and malloc management routines in the same 
  1089. Xmodule, while X11R4 defines them in different modules.
  1090. X.P
  1091. XThe sign of this problem is a link error due to duplicate references
  1092. Xto the Xt allocation routines (XtMalloc, etc).
  1093. X.SH LINKING
  1094. XThe order in which you link your programs can have a significant effect
  1095. Xon the usefulness of the library and even on the ability to link itself.
  1096. XThe debug library should be placed as the first system library that you are
  1097. Xlinking to (assuming that you are calling at least one of the malloc, string,
  1098. Xor memory functions).
  1099. X.P
  1100. XFor example, if the following is your normal link command:
  1101. X.eX
  1102. Xcc -o app app.o supp.o else.o applib.a -lmath -lcurses
  1103. X.eX
  1104. XYou should add the malloc debug library in between applib.a and -lmath, 
  1105. Xwhich would result in the following:
  1106. X.eX
  1107. Xcc -o app app.o supp.o else.o applib.a -ldbmalloc -lmath -lcurses
  1108. X.eX
  1109. XThis will ensure that the debug malloc library overrides all of the allocation
  1110. Xroutines within the other libraries.  
  1111. X.P
  1112. XIf you have other problems compiling or linking with the library you should
  1113. Xlook at the \s-2PROBLEMS\s+2 file in the source directory.  This file 
  1114. Xcontains descriptions of common problems and the recommended solutions to
  1115. Xthe problems.
  1116. X.SH PERFORMANCE
  1117. XThis malloc library and its associated string and memory functions are
  1118. Xmuch less efficient than the standard functions due in part to the extra
  1119. Xerror checking.  You do not want to use this library when generating a
  1120. Xproduction (i.e. releasable) version of your software.  It should only
  1121. Xbe used during development and testing.
  1122. X.P
  1123. X.ne 10
  1124. XThe following environment variable settings will give you the best
  1125. Xperformance (at the expense of some additional error checking):
  1126. X.eX
  1127. XMALLOC_CKCHAIN=0
  1128. XMALLOC_CKDATA=0
  1129. XMALLOC_FILLAREA=0
  1130. XMALLOC_LOWFRAG=0
  1131. X.eX
  1132. XWe recommend against setting MALLOC_FILLAREA to zero because, while
  1133. Xit will increase the performance, it takes away the capability
  1134. Xto uncover small malloc overruns which don't overrite the pointers surrounding
  1135. Xthe malloc regions.  The same anti-recommendation applies to MALLOC_CKDATA.
  1136. X.P
  1137. X.ne 5
  1138. XAnyway, with these settings, the malloc library runs at about 1/2 the
  1139. Xspeed (things only take twice as long) as the standard library.  If you program
  1140. Xspends most of its time in malloc, it will still be slow (but perhaps this is
  1141. Xan indication that you need to consider changing the way you are using 
  1142. Xmalloc).
  1143. X.br
  1144. X.ne 15
  1145. X.SH WARNINGS
  1146. XThe include file for this library "malloc.h" should be included after
  1147. Xthe includes for any system related information.  This is because "malloc.h"
  1148. Xredefines several system functions including string and memory routines
  1149. Xand this will usually cause compilation errors if malloc.h is processed
  1150. Xfirst (of course, the compile errors will talk about errors in the other
  1151. Xsystem include files like string.h).
  1152. X.P
  1153. XThis goes hand in hand with the fact that if you have local definitions of
  1154. Xthe return types of standard functions like strcmp() or malloc(), 
  1155. Xthese lines will cause compile errors due to the #defines in the
  1156. Xmalloc.h header file.  Therefore, it is suggested that you remove
  1157. Xall such definitions from your code and rely on the system header
  1158. Xfiles to define these functions, or you surround the definitions 
  1159. Xwith #ifdef \s-2DEBUG_MALLOC_INC\s+2.
  1160. X.P
  1161. XThere is a possibility that the use of \fBsbrk\fP() by other modules
  1162. Xwill cause this library to get confused and possibly report 
  1163. Xsome pointers as bad when the really aren't part of the malloc chain
  1164. Xitself.  Therefore the direct use of \fBsbrk\fP() is strongly discouraged.
  1165. X.P
  1166. XThis library attempts to trap errors and exit/handle them gracefully.  
  1167. XHowever, the nature of the problems may be such that it causes the 
  1168. Xcode in the library itself to crash.  There is no way to avoid this,
  1169. Xbut if it does occur,  turn on chain checking to narrow the place where
  1170. Xit will occur.
  1171. X.P
  1172. XThe functions in this library will often conflict with duplicate functions
  1173. Xin shared library versions of libc.a.  This is usually due to the 
  1174. Xfact that some shared library modules have explicit references to shared
  1175. Xlibrary versions of the debug functions.  The only way around this is
  1176. Xto not use the shared library when linking.
  1177. X.P
  1178. XThis malloc library, like most malloc libraries, is not re-entrant 
  1179. Xand therefore should not be called from interrupt handlers because of the
  1180. Xpotential for receiving an interrupt in the middle of a call to malloc
  1181. Xwhich would really mess things up.
  1182. X.SH SEE ALSO
  1183. Xmalloc(3), string(3), memory(3)
  1184. X.br
  1185. X.ne 10
  1186. X.SH COPYRIGHT
  1187. X.nf
  1188. X (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  1189. X
  1190. X This software may be distributed freely as long as the following conditions
  1191. X are met:
  1192. X        * the distribution, or any derivative thereof, may not be
  1193. X          included as part of a commercial product
  1194. X        * full source code is provided including this copyright
  1195. X        * there is no charge for the software itself (there may be
  1196. X          a minimal charge for the copying or distribution effort)
  1197. X        * this copyright notice is not modified or removed from any
  1198. X             source file
  1199. X
  1200. X.fi
  1201. X.br
  1202. X.ne 10
  1203. X.SH AUTHOR
  1204. X.nf
  1205. XConor P. Cahill
  1206. XVirtual Technologies Incorporated
  1207. X46030 Manekin Plaza, Suite 160
  1208. XSterling VA 22170
  1209. X703-430-9247
  1210. X.MP
  1211. Xcpcahil@virtech.vti.com
  1212. Xuunet!virtech!cpcahil
  1213. END_OF_FILE
  1214. if test 42916 -ne `wc -c <'malloc.3'`; then
  1215.     echo shar: \"'malloc.3'\" unpacked with wrong size!
  1216. fi
  1217. # end of 'malloc.3'
  1218. fi
  1219. if test -f 'mallocin.h' -a "${1}" != "-c" ; then 
  1220.   echo shar: Will not clobber existing file \"'mallocin.h'\"
  1221. else
  1222. echo shar: Extracting \"'mallocin.h'\" \(9557 characters\)
  1223. sed "s/^X//" >'mallocin.h' <<'END_OF_FILE'
  1224. X/*
  1225. X * (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  1226. X *
  1227. X * This software may be distributed freely as long as the following conditions
  1228. X * are met:
  1229. X *         * the distribution, or any derivative thereof, may not be
  1230. X *          included as part of a commercial product
  1231. X *        * full source code is provided including this copyright
  1232. X *        * there is no charge for the software itself (there may be
  1233. X *          a minimal charge for the copying or distribution effort)
  1234. X *        * this copyright notice is not modified or removed from any
  1235. X *          source file
  1236. X */
  1237. X/*
  1238. X * $Id: mallocin.h,v 1.27 1992/09/03 22:24:33 cpcahil Exp $
  1239. X */
  1240. X#ifndef _MALLOCIN_H
  1241. X#define _MALLOCIN_H 1
  1242. X
  1243. X/*
  1244. X * this file contains macros that are internal to the malloc library
  1245. X * and therefore, are not needed in malloc.h.
  1246. X */
  1247. X
  1248. X#if POSIX_HEADERS
  1249. X#include <unistd.h>
  1250. X#endif
  1251. X#if ANSI_HEADERS
  1252. X#include <stdlib.h>
  1253. X#endif
  1254. X
  1255. X#ifndef SYS_TYPES_H_INCLUDED
  1256. X#include <sys/types.h>
  1257. X#endif
  1258. X
  1259. X#define IN_MALLOC_CODE    1
  1260. X#include "sysdefs.h"
  1261. X#include "malloc.h"
  1262. X
  1263. X#define IDTYPE unsigned long
  1264. X#define ULONG  unsigned long
  1265. X
  1266. X/*
  1267. X * Data structures used by stack mechanism
  1268. X */
  1269. Xstruct stack
  1270. X{
  1271. X    struct stack    * beside;
  1272. X    struct stack    * below;
  1273. X    struct stack     * above;
  1274. X    CONST char    * func;
  1275. X    CONST char    * file;
  1276. X    int          line;
  1277. X};
  1278. X
  1279. X/*
  1280. X * minimum round up to get to a doubleword boundry, assuming it is the
  1281. X * strictest alignment requirement on the system.  If not, the union s
  1282. X * in struct mlist will also have to be changed.  Note that this must be
  1283. X * a power of two because of how it is used throughout the code.
  1284. X */
  1285. X#define M_RND        0x08
  1286. X#define M_YOFFSET       (sizeof(SIZETYPE))
  1287. X
  1288. X#define LONGFILL 2
  1289. X
  1290. Xstruct mlist
  1291. X{
  1292. X    struct mlist    * next;            /* next entry in chain    */
  1293. X    struct mlist    * prev;            /* prev entry in chain    */
  1294. X    struct mlist    * freenext;        /* next ent in free chn */
  1295. X    struct mlist    * freeprev;        /* prev ent in free chn */
  1296. X    struct stack    * stack;        /* current stack level    */
  1297. X    struct stack    * freestack;        /* free stack level    */
  1298. X    long           flag;            /* inuse flag        */
  1299. X    CONST char    * file;            /* file where called fm    */
  1300. X    int          line;            /* line where called fm    */
  1301. X    CONST char    * ffile;        /* file where freed     */
  1302. X    int          fline;        /* line where freed     */
  1303. X    IDTYPE          fid;            /* free call number    */
  1304. X    IDTYPE          hist_id;        /* historical id    */
  1305. X    IDTYPE          id;            /* malloc call number    */
  1306. X    SIZETYPE      r_size;        /* requested size    */
  1307. X    union
  1308. X    {
  1309. X        SIZETYPE      size;        /* actual size        */
  1310. X        SIZETYPE      filler[LONGFILL];
  1311. X        double          unused_just_for_alignment;
  1312. X    } s;
  1313. X    char          data[M_RND];
  1314. X};
  1315. X
  1316. X/*
  1317. X * pre-filler size
  1318. X */
  1319. X#define FILLSIZE    (sizeof(mlist.s) - sizeof(mlist.s.filler[0]))
  1320. X
  1321. X/*
  1322. X * kludge to get offsetof the data element for the mlist structure
  1323. X */
  1324. X#define M_SIZE        ((SIZETYPE)(char *)((struct mlist *)0)->data)
  1325. X#define M_FLAGOFF    ((SIZETYPE)(char *)&((struct mlist *)0)->flag)
  1326. X
  1327. X#define M_INUSE     0x01
  1328. X#define M_FILLED     0x02
  1329. X#define M_MARKED    0x04
  1330. X#define M_DFILLED    0x08
  1331. X#define M_MAGIC     0x31561000
  1332. X#define M_MAGIC_BITS    0xfffff000
  1333. X
  1334. X#define M_BLOCKSIZE    (1024*8)
  1335. X
  1336. X#define EOS            '\0'
  1337. X#define M_DFLT_FILL        '\01'
  1338. X#define M_DFLT_FREE_FILL    '\02'
  1339. X#define M_DFLT_BSIZE        1
  1340. X#define M_FILL            ((char)malloc_fillbyte)
  1341. X#define M_FREE_FILL        ((char)malloc_freebyte)
  1342. X#define M_BSIZE            (malloc_boundsize)
  1343. X
  1344. X#define MALLOC_INIT()    if( malloc_data_start == (DATATYPE *)0 ) malloc_init()
  1345. X
  1346. X/* 
  1347. X * malloc internal options
  1348. X */
  1349. X#define MOPT_MFILL    0x0001        /* fill malloc'd segments    */
  1350. X#define MOPT_FFILL    0x0002        /* fill free'd segments        */
  1351. X#define MOPT_REUSE    0x0004        /* reuse free segments?        */
  1352. X#define MOPT_LOWFRAG    0x0008        /* low fragmentation        */
  1353. X#define MOPT_CKCHAIN    0x0010        /* enable chain checking    */
  1354. X#define MOPT_CKDATA    0x0020        /* enable data checking        */
  1355. X#define MOPT_DFILL    0x0040        /* fill over/underflow areas    */
  1356. X#define MOPT_SLINKS     0x0080        /* turn off/on adjacent link disp */
  1357. X#define MOPT_DETAIL     0x0100        /* turn off/on detailed output  */
  1358. X#define MOPT_FREEMARK   0x0200        /* warning when freeing marked    */
  1359. X#define MOPT_ZERO       0x0400        /* warning about zero length allocs */
  1360. X
  1361. X/*
  1362. X * malloc_freeseg() operation arguments
  1363. X */
  1364. X#define M_FREE_REMOVE    1
  1365. X#define M_FREE_ADD    2
  1366. X/*
  1367. X * Malloc types
  1368. X */
  1369. X#define M_T_MALLOC    0x010
  1370. X#define M_T_REALLOC    0x020
  1371. X#define M_T_CALLOC    0x030
  1372. X#define M_T_SPLIT    0x040
  1373. X#define M_T_STACK    0x050
  1374. X#define M_T_XTMALLOC    0x060
  1375. X#define M_T_XTREALLOC    0x070
  1376. X#define M_T_XTCALLOC    0x080
  1377. X#define M_T_ALIGNED    0x090
  1378. X#define M_T_BITS    0x0F0
  1379. X
  1380. X#define GETTYPE(_ptr)        (_ptr->flag & M_T_BITS)
  1381. X#define SETTYPE(_ptr,_type)     (_ptr->flag = ((_ptr->flag & ~M_T_BITS)|_type))
  1382. X
  1383. X#define DATATOMLIST(_ptr) ((struct mlist *) (((char *)_ptr) - M_SIZE))
  1384. X
  1385. X/*
  1386. X * Free types
  1387. X */
  1388. X#define F_T_FREE    0x100
  1389. X#define F_T_CFREE    0x200
  1390. X#define F_T_XTFREE    0x300
  1391. X#define F_T_REALLOC    0x400
  1392. X#define F_T_BITS    0xF00
  1393. X
  1394. X#define GETFTYPE(_ptr)        (_ptr->flag & F_T_BITS)
  1395. X#define SETFTYPE(_ptr,_type)     (_ptr->flag = ((_ptr->flag & ~F_T_BITS)|_type))
  1396. X
  1397. X/*
  1398. X * Fill types
  1399. X */
  1400. X#define FILL_MALLOC    1
  1401. X#define FILL_REALLOC    2
  1402. X#define FILL_CALLOC    3
  1403. X#define FILL_FREE    4
  1404. X#define FILL_SPLIT    5
  1405. X#define FILL_JOIN    6
  1406. X
  1407. X#define FILLCHECK(a,b,c,d,e) ( malloc_fill ? FillCheck(a,b,c,d,e) : 0 )
  1408. X#define FILLDATA(a,b,c,d)     if( malloc_fill ) FillData(a,b,c,d)
  1409. X
  1410. X/*
  1411. X * malloc_chain_check flags
  1412. X */
  1413. X#define SHOWERRORS    1
  1414. X#define DONTSHOWERRS    0
  1415. X
  1416. X/*
  1417. X * DBFmalloc fill flags
  1418. X */
  1419. X#define DOFILL        1
  1420. X#define DONTFILL    0
  1421. X
  1422. X/*
  1423. X * malloc join flags
  1424. X */
  1425. X#define NOTINUSE    0    /* don't join inuse segments        */
  1426. X#define INUSEOK        1    /* ok to join if current seg is in use    */
  1427. X#define NEXTPTR_INUSEOK    2
  1428. X#define ANY_INUSEOK    3
  1429. X
  1430. X/*
  1431. X * number of longwords to search for magic number before we give up and 
  1432. X * search the entire malloc list.
  1433. X */
  1434. X#define MAX_KLUDGE_CHECKS    100
  1435. X/*
  1436. X * Misc stuff..
  1437. X */
  1438. X#define M_ROUNDUP(size)    {\
  1439. X                if( size & (M_RND-1) ) \
  1440. X                { \
  1441. X                    size += (M_RND-1); \
  1442. X                    size &= ~(M_RND-1); \
  1443. X                } \
  1444. X            }
  1445. X
  1446. XEXITTYPE      exit __STDCARGS((int));
  1447. Xchar        * getenv __STDCARGS((CONST char *));
  1448. XDATATYPE    * sbrk __STDCARGS((int));
  1449. X
  1450. X/*
  1451. X * stuff for X compatibility routines (needed here so that the prototypes 
  1452. X * don't fail
  1453. X */
  1454. Xtypedef struct {
  1455. X    char*       start;
  1456. X    char*       current;
  1457. X    int         bytes_remaining;
  1458. X} Heap;
  1459. X
  1460. X#ifndef _XtIntrinsic_h
  1461. Xtypedef unsigned int Cardinal;
  1462. Xtypedef char * String;
  1463. X#endif
  1464. X
  1465. X#include "prototypes.h"
  1466. X
  1467. X/*
  1468. X * global variables
  1469. X */
  1470. Xextern int          in_malloc_code;
  1471. Xextern SIZETYPE          malloc_align;
  1472. Xextern int          malloc_boundsize;
  1473. Xextern DATATYPE        * malloc_data_start;
  1474. Xextern DATATYPE        * malloc_data_end;
  1475. Xextern struct mlist     * malloc_end;
  1476. Xextern int          malloc_errfd;
  1477. Xextern int          malloc_errno;
  1478. Xextern CONST char    * malloc_err_strings[];
  1479. Xextern int          malloc_fatal_level;
  1480. Xextern int          malloc_fill;
  1481. Xextern int          malloc_fillbyte;
  1482. Xextern int          malloc_freebyte;
  1483. Xextern struct mlist    * malloc_freelist;
  1484. Xextern long          malloc_hist_id;
  1485. Xextern int          malloc_opts;
  1486. Xextern int          malloc_round;
  1487. Xextern struct mlist      malloc_start;
  1488. Xextern int          malloc_warn_level;
  1489. X
  1490. X#endif /* _MALLOCIN_H */
  1491. X
  1492. X/*
  1493. X * $Log: mallocin.h,v $
  1494. X * Revision 1.27  1992/09/03  22:24:33  cpcahil
  1495. X * final changes for PL14
  1496. X *
  1497. X * Revision 1.26  1992/08/22  16:27:13  cpcahil
  1498. X * final changes for pl14
  1499. X *
  1500. X * Revision 1.25  1992/07/12  15:30:58  cpcahil
  1501. X * Merged in Jonathan I Kamens' changes
  1502. X *
  1503. X * Revision 1.24  1992/07/03  00:03:25  cpcahil
  1504. X * more fixes for pl13, several suggestons from Rich Salz.
  1505. X *
  1506. X * Revision 1.23  1992/07/02  13:49:54  cpcahil
  1507. X * added support for new malloc_size function and additional tests to testerr
  1508. X *
  1509. X * Revision 1.22  1992/06/30  13:06:39  cpcahil
  1510. X * added support for aligned allocations
  1511. X *
  1512. X * Revision 1.21  1992/06/22  23:40:10  cpcahil
  1513. X * many fixes for working on small int systems
  1514. X *
  1515. X * Revision 1.20  1992/05/09  00:16:16  cpcahil
  1516. X * port to hpux and lots of fixes
  1517. X *
  1518. X * Revision 1.19  1992/05/08  02:30:35  cpcahil
  1519. X * minor cleanups from minix/atari port
  1520. X *
  1521. X * Revision 1.18  1992/05/08  01:44:11  cpcahil
  1522. X * more performance enhancements
  1523. X *
  1524. X * Revision 1.17  1992/05/06  05:37:44  cpcahil
  1525. X * added overriding of fill characters and boundary size
  1526. X *
  1527. X * Revision 1.16  1992/05/06  04:53:29  cpcahil
  1528. X * performance enhancments
  1529. X *
  1530. X * Revision 1.15  1992/04/24  12:09:13  cpcahil
  1531. X * (hopefully) final cleanup for patch 10
  1532. X *
  1533. X * Revision 1.14  1992/04/24  11:18:52  cpcahil
  1534. X * Fixes from Denny Page and Better integration of Xt alloc hooks
  1535. X *
  1536. X * Revision 1.13  1992/04/22  18:17:32  cpcahil
  1537. X * added support for Xt Alloc functions, linted code
  1538. X *
  1539. X * Revision 1.12  1992/04/20  22:29:14  cpcahil
  1540. X * changes to fix problems introduced by insertion of size_t
  1541. X *
  1542. X * Revision 1.11  1992/04/13  18:26:30  cpcahil
  1543. X * changed sbrk arg to int which it should be on all systems.
  1544. X *
  1545. X * Revision 1.10  1992/04/13  14:16:11  cpcahil
  1546. X * ansi changes corresponding to changes made in stack.c
  1547. X *
  1548. X * Revision 1.9  1992/04/13  03:06:33  cpcahil
  1549. X * Added Stack support, marking of non-leaks, auto-config, auto-testing
  1550. X *
  1551. X * Revision 1.8  1992/03/01  12:42:38  cpcahil
  1552. X * added support for managing freed areas and fixed doublword bndr problems
  1553. X *
  1554. X * Revision 1.7  1991/12/31  21:31:26  cpcahil
  1555. X * changes for patch 6.  See CHANGES file for more info
  1556. X *
  1557. X * Revision 1.6  1991/12/06  08:54:18  cpcahil
  1558. X * cleanup of __STDC__ usage and addition of CHANGES file
  1559. X *
  1560. X * Revision 1.5  91/12/04  18:01:22  cpcahil
  1561. X * cleand up some aditional warnings from gcc -Wall
  1562. X * 
  1563. X * Revision 1.4  91/12/04  09:23:42  cpcahil
  1564. X * several performance enhancements including addition of free list
  1565. X * 
  1566. X * Revision 1.3  91/12/02  19:10:12  cpcahil
  1567. X * changes for patch release 5
  1568. X * 
  1569. X * Revision 1.2  91/11/25  14:42:02  cpcahil
  1570. X * Final changes in preparation for patch 4 release
  1571. X * 
  1572. X * Revision 1.1  91/11/24  00:49:30  cpcahil
  1573. X * first cut at patch 4
  1574. X * 
  1575. X */
  1576. END_OF_FILE
  1577. if test 9557 -ne `wc -c <'mallocin.h'`; then
  1578.     echo shar: \"'mallocin.h'\" unpacked with wrong size!
  1579. fi
  1580. # end of 'mallocin.h'
  1581. fi
  1582. echo shar: End of archive 5 \(of 10\).
  1583. cp /dev/null ark5isdone
  1584. MISSING=""
  1585. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  1586.     if test ! -f ark${I}isdone ; then
  1587.     MISSING="${MISSING} ${I}"
  1588.     fi
  1589. done
  1590. if test "${MISSING}" = "" ; then
  1591.     echo You have unpacked all 10 archives.
  1592.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1593. else
  1594.     echo You still need to unpack the following archives:
  1595.     echo "        " ${MISSING}
  1596. fi
  1597. ##  End of shell archive.
  1598. exit 0
  1599. *** SENTINEL(tm) The ultimate Debugging Environment - email for more info ***
  1600.  
  1601. Conor P. Cahill              (703)430-9247            cpcahil@virtech.vti.com
  1602. Virtual Technologies, Inc.  46030 Manekin Plaza          Dulles, VA 21066 
  1603.  
  1604. exit 0 # Just in case...
  1605.