home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / mallc120 / part01 < prev    next >
Encoding:
Text File  |  1993-04-05  |  67.0 KB  |  1,804 lines

  1. Newsgroups: comp.sources.unix
  2. From: gray@antaire.com (Gray Watson)
  3. Subject: v26i098: malloc - debugging version of malloc, V1.2.0, Part01/05
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: gray@antaire.com (Gray Watson)
  8. Posting-Number: Volume 26, Issue 98
  9. Archive-Name: malloc-1.2.0/part01
  10.  
  11. Malloc Debug Library
  12. ********************
  13.  
  14.    This file documents the general-usage and the inner-workings of the
  15. memory allocation or "malloc" library it accompanies.
  16.  
  17.    This malloc library has been designed as a drop in replacement for
  18. the system's malloc, realloc, calloc, free and other memory management
  19. routines.  For more information about their capabilities, do a `man 3
  20. malloc' to read the system's manual pages.
  21.  
  22.    What is unique about this library is that it contains a number of
  23. powerful debugging facilities including very comprehensive heap testing
  24. and excellent run-time debugging information.  We have found these
  25. capabilities to be superb development tools.
  26.  
  27.    I can be reached at `<gray.watson@antaire.com>' with any questions
  28. or general comments.
  29.  
  30.    Gray Watson, Antaire Corporation.
  31.  
  32. #! /bin/sh
  33. # This is a shell archive.  Remove anything before this line, then unpack
  34. # it by saving it into a file and typing "sh file".  To overwrite existing
  35. # files, type "sh file -c".  You can also feed this as standard input via
  36. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  37. # will see the following message at the end:
  38. #        "End of archive 1 (of 5)."
  39. # Contents:  COPYING-LIB ChangeLog Makefile.in Manifest NOTES README
  40. #   TTD malloc.c
  41. # Wrapped by gray@toaster.antaire.com on Tue Apr  6 01:24:05 1993
  42. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  43. if test -f 'COPYING-LIB' -a "${1}" != "-c" ; then 
  44.   echo shar: Will not clobber existing file \"'COPYING-LIB'\"
  45. else
  46. echo shar: Extracting \"'COPYING-LIB'\" \(25265 characters\)
  47. sed "s/^X//" >'COPYING-LIB' <<'END_OF_FILE'
  48. X          GNU LIBRARY GENERAL PUBLIC LICENSE
  49. X               Version 2, June 1991
  50. X
  51. X Copyright (C) 1991 Free Software Foundation, Inc.
  52. X                    675 Mass Ave, Cambridge, MA 02139, USA
  53. X Everyone is permitted to copy and distribute verbatim copies
  54. X of this license document, but changing it is not allowed.
  55. X
  56. X[This is the first released version of the library GPL.  It is
  57. X numbered 2 because it goes with version 2 of the ordinary GPL.]
  58. X
  59. X                Preamble
  60. X
  61. X  The licenses for most software are designed to take away your
  62. Xfreedom to share and change it.  By contrast, the GNU General Public
  63. XLicenses are intended to guarantee your freedom to share and change
  64. Xfree software--to make sure the software is free for all its users.
  65. X
  66. X  This license, the Library General Public License, applies to some
  67. Xspecially designated Free Software Foundation software, and to any
  68. Xother libraries whose authors decide to use it.  You can use it for
  69. Xyour libraries, too.
  70. X
  71. X  When we speak of free software, we are referring to freedom, not
  72. Xprice.  Our General Public Licenses are designed to make sure that you
  73. Xhave the freedom to distribute copies of free software (and charge for
  74. Xthis service if you wish), that you receive source code or can get it
  75. Xif you want it, that you can change the software or use pieces of it
  76. Xin new free programs; and that you know you can do these things.
  77. X
  78. X  To protect your rights, we need to make restrictions that forbid
  79. Xanyone to deny you these rights or to ask you to surrender the rights.
  80. XThese restrictions translate to certain responsibilities for you if
  81. Xyou distribute copies of the library, or if you modify it.
  82. X
  83. X  For example, if you distribute copies of the library, whether gratis
  84. Xor for a fee, you must give the recipients all the rights that we gave
  85. Xyou.  You must make sure that they, too, receive or can get the source
  86. Xcode.  If you link a program with the library, you must provide
  87. Xcomplete object files to the recipients so that they can relink them
  88. Xwith the library, after making changes to the library and recompiling
  89. Xit.  And you must show them these terms so they know their rights.
  90. X
  91. X  Our method of protecting your rights has two steps: (1) copyright
  92. Xthe library, and (2) offer you this license which gives you legal
  93. Xpermission to copy, distribute and/or modify the library.
  94. X
  95. X  Also, for each distributor's protection, we want to make certain
  96. Xthat everyone understands that there is no warranty for this free
  97. Xlibrary.  If the library is modified by someone else and passed on, we
  98. Xwant its recipients to know that what they have is not the original
  99. Xversion, so that any problems introduced by others will not reflect on
  100. Xthe original authors' reputations.
  101. X
  102. X  Finally, any free program is threatened constantly by software
  103. Xpatents.  We wish to avoid the danger that companies distributing free
  104. Xsoftware will individually obtain patent licenses, thus in effect
  105. Xtransforming the program into proprietary software.  To prevent this,
  106. Xwe have made it clear that any patent must be licensed for everyone's
  107. Xfree use or not licensed at all.
  108. X
  109. X  Most GNU software, including some libraries, is covered by the ordinary
  110. XGNU General Public License, which was designed for utility programs.  This
  111. Xlicense, the GNU Library General Public License, applies to certain
  112. Xdesignated libraries.  This license is quite different from the ordinary
  113. Xone; be sure to read it in full, and don't assume that anything in it is
  114. Xthe same as in the ordinary license.
  115. X
  116. X  The reason we have a separate public license for some libraries is that
  117. Xthey blur the distinction we usually make between modifying or adding to a
  118. Xprogram and simply using it.  Linking a program with a library, without
  119. Xchanging the library, is in some sense simply using the library, and is
  120. Xanalogous to running a utility program or application program.  However, in
  121. Xa textual and legal sense, the linked executable is a combined work, a
  122. Xderivative of the original library, and the ordinary General Public License
  123. Xtreats it as such.
  124. X
  125. X  Because of this blurred distinction, using the ordinary General
  126. XPublic License for libraries did not effectively promote software
  127. Xsharing, because most developers did not use the libraries.  We
  128. Xconcluded that weaker conditions might promote sharing better.
  129. X
  130. X  However, unrestricted linking of non-free programs would deprive the
  131. Xusers of those programs of all benefit from the free status of the
  132. Xlibraries themselves.  This Library General Public License is intended to
  133. Xpermit developers of non-free programs to use free libraries, while
  134. Xpreserving your freedom as a user of such programs to change the free
  135. Xlibraries that are incorporated in them.  (We have not seen how to achieve
  136. Xthis as regards changes in header files, but we have achieved it as regards
  137. Xchanges in the actual functions of the Library.)  The hope is that this
  138. Xwill lead to faster development of free libraries.
  139. X
  140. X  The precise terms and conditions for copying, distribution and
  141. Xmodification follow.  Pay close attention to the difference between a
  142. X"work based on the library" and a "work that uses the library".  The
  143. Xformer contains code derived from the library, while the latter only
  144. Xworks together with the library.
  145. X
  146. X  Note that it is possible for a library to be covered by the ordinary
  147. XGeneral Public License rather than by this special one.
  148. X
  149. X          GNU LIBRARY GENERAL PUBLIC LICENSE
  150. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  151. X
  152. X  0. This License Agreement applies to any software library which
  153. Xcontains a notice placed by the copyright holder or other authorized
  154. Xparty saying it may be distributed under the terms of this Library
  155. XGeneral Public License (also called "this License").  Each licensee is
  156. Xaddressed as "you".
  157. X
  158. X  A "library" means a collection of software functions and/or data
  159. Xprepared so as to be conveniently linked with application programs
  160. X(which use some of those functions and data) to form executables.
  161. X
  162. X  The "Library", below, refers to any such software library or work
  163. Xwhich has been distributed under these terms.  A "work based on the
  164. XLibrary" means either the Library or any derivative work under
  165. Xcopyright law: that is to say, a work containing the Library or a
  166. Xportion of it, either verbatim or with modifications and/or translated
  167. Xstraightforwardly into another language.  (Hereinafter, translation is
  168. Xincluded without limitation in the term "modification".)
  169. X
  170. X  "Source code" for a work means the preferred form of the work for
  171. Xmaking modifications to it.  For a library, complete source code means
  172. Xall the source code for all modules it contains, plus any associated
  173. Xinterface definition files, plus the scripts used to control compilation
  174. Xand installation of the library.
  175. X
  176. X  Activities other than copying, distribution and modification are not
  177. Xcovered by this License; they are outside its scope.  The act of
  178. Xrunning a program using the Library is not restricted, and output from
  179. Xsuch a program is covered only if its contents constitute a work based
  180. Xon the Library (independent of the use of the Library in a tool for
  181. Xwriting it).  Whether that is true depends on what the Library does
  182. Xand what the program that uses the Library does.
  183. X  
  184. X  1. You may copy and distribute verbatim copies of the Library's
  185. Xcomplete source code as you receive it, in any medium, provided that
  186. Xyou conspicuously and appropriately publish on each copy an
  187. Xappropriate copyright notice and disclaimer of warranty; keep intact
  188. Xall the notices that refer to this License and to the absence of any
  189. Xwarranty; and distribute a copy of this License along with the
  190. XLibrary.
  191. X
  192. X  You may charge a fee for the physical act of transferring a copy,
  193. Xand you may at your option offer warranty protection in exchange for a
  194. Xfee.
  195. X
  196. X  2. You may modify your copy or copies of the Library or any portion
  197. Xof it, thus forming a work based on the Library, and copy and
  198. Xdistribute such modifications or work under the terms of Section 1
  199. Xabove, provided that you also meet all of these conditions:
  200. X
  201. X    a) The modified work must itself be a software library.
  202. X
  203. X    b) You must cause the files modified to carry prominent notices
  204. X    stating that you changed the files and the date of any change.
  205. X
  206. X    c) You must cause the whole of the work to be licensed at no
  207. X    charge to all third parties under the terms of this License.
  208. X
  209. X    d) If a facility in the modified Library refers to a function or a
  210. X    table of data to be supplied by an application program that uses
  211. X    the facility, other than as an argument passed when the facility
  212. X    is invoked, then you must make a good faith effort to ensure that,
  213. X    in the event an application does not supply such function or
  214. X    table, the facility still operates, and performs whatever part of
  215. X    its purpose remains meaningful.
  216. X
  217. X    (For example, a function in a library to compute square roots has
  218. X    a purpose that is entirely well-defined independent of the
  219. X    application.  Therefore, Subsection 2d requires that any
  220. X    application-supplied function or table used by this function must
  221. X    be optional: if the application does not supply it, the square
  222. X    root function must still compute square roots.)
  223. X
  224. XThese requirements apply to the modified work as a whole.  If
  225. Xidentifiable sections of that work are not derived from the Library,
  226. Xand can be reasonably considered independent and separate works in
  227. Xthemselves, then this License, and its terms, do not apply to those
  228. Xsections when you distribute them as separate works.  But when you
  229. Xdistribute the same sections as part of a whole which is a work based
  230. Xon the Library, the distribution of the whole must be on the terms of
  231. Xthis License, whose permissions for other licensees extend to the
  232. Xentire whole, and thus to each and every part regardless of who wrote
  233. Xit.
  234. X
  235. XThus, it is not the intent of this section to claim rights or contest
  236. Xyour rights to work written entirely by you; rather, the intent is to
  237. Xexercise the right to control the distribution of derivative or
  238. Xcollective works based on the Library.
  239. X
  240. XIn addition, mere aggregation of another work not based on the Library
  241. Xwith the Library (or with a work based on the Library) on a volume of
  242. Xa storage or distribution medium does not bring the other work under
  243. Xthe scope of this License.
  244. X
  245. X  3. You may opt to apply the terms of the ordinary GNU General Public
  246. XLicense instead of this License to a given copy of the Library.  To do
  247. Xthis, you must alter all the notices that refer to this License, so
  248. Xthat they refer to the ordinary GNU General Public License, version 2,
  249. Xinstead of to this License.  (If a newer version than version 2 of the
  250. Xordinary GNU General Public License has appeared, then you can specify
  251. Xthat version instead if you wish.)  Do not make any other change in
  252. Xthese notices.
  253. X
  254. X  Once this change is made in a given copy, it is irreversible for
  255. Xthat copy, so the ordinary GNU General Public License applies to all
  256. Xsubsequent copies and derivative works made from that copy.
  257. X
  258. X  This option is useful when you wish to copy part of the code of
  259. Xthe Library into a program that is not a library.
  260. X
  261. X  4. You may copy and distribute the Library (or a portion or
  262. Xderivative of it, under Section 2) in object code or executable form
  263. Xunder the terms of Sections 1 and 2 above provided that you accompany
  264. Xit with the complete corresponding machine-readable source code, which
  265. Xmust be distributed under the terms of Sections 1 and 2 above on a
  266. Xmedium customarily used for software interchange.
  267. X
  268. X  If distribution of object code is made by offering access to copy
  269. Xfrom a designated place, then offering equivalent access to copy the
  270. Xsource code from the same place satisfies the requirement to
  271. Xdistribute the source code, even though third parties are not
  272. Xcompelled to copy the source along with the object code.
  273. X
  274. X  5. A program that contains no derivative of any portion of the
  275. XLibrary, but is designed to work with the Library by being compiled or
  276. Xlinked with it, is called a "work that uses the Library".  Such a
  277. Xwork, in isolation, is not a derivative work of the Library, and
  278. Xtherefore falls outside the scope of this License.
  279. X
  280. X  However, linking a "work that uses the Library" with the Library
  281. Xcreates an executable that is a derivative of the Library (because it
  282. Xcontains portions of the Library), rather than a "work that uses the
  283. Xlibrary".  The executable is therefore covered by this License.
  284. XSection 6 states terms for distribution of such executables.
  285. X
  286. X  When a "work that uses the Library" uses material from a header file
  287. Xthat is part of the Library, the object code for the work may be a
  288. Xderivative work of the Library even though the source code is not.
  289. XWhether this is true is especially significant if the work can be
  290. Xlinked without the Library, or if the work is itself a library.  The
  291. Xthreshold for this to be true is not precisely defined by law.
  292. X
  293. X  If such an object file uses only numerical parameters, data
  294. Xstructure layouts and accessors, and small macros and small inline
  295. Xfunctions (ten lines or less in length), then the use of the object
  296. Xfile is unrestricted, regardless of whether it is legally a derivative
  297. Xwork.  (Executables containing this object code plus portions of the
  298. XLibrary will still fall under Section 6.)
  299. X
  300. X  Otherwise, if the work is a derivative of the Library, you may
  301. Xdistribute the object code for the work under the terms of Section 6.
  302. XAny executables containing that work also fall under Section 6,
  303. Xwhether or not they are linked directly with the Library itself.
  304. X
  305. X  6. As an exception to the Sections above, you may also compile or
  306. Xlink a "work that uses the Library" with the Library to produce a
  307. Xwork containing portions of the Library, and distribute that work
  308. Xunder terms of your choice, provided that the terms permit
  309. Xmodification of the work for the customer's own use and reverse
  310. Xengineering for debugging such modifications.
  311. X
  312. X  You must give prominent notice with each copy of the work that the
  313. XLibrary is used in it and that the Library and its use are covered by
  314. Xthis License.  You must supply a copy of this License.  If the work
  315. Xduring execution displays copyright notices, you must include the
  316. Xcopyright notice for the Library among them, as well as a reference
  317. Xdirecting the user to the copy of this License.  Also, you must do one
  318. Xof these things:
  319. X
  320. X    a) Accompany the work with the complete corresponding
  321. X    machine-readable source code for the Library including whatever
  322. X    changes were used in the work (which must be distributed under
  323. X    Sections 1 and 2 above); and, if the work is an executable linked
  324. X    with the Library, with the complete machine-readable "work that
  325. X    uses the Library", as object code and/or source code, so that the
  326. X    user can modify the Library and then relink to produce a modified
  327. X    executable containing the modified Library.  (It is understood
  328. X    that the user who changes the contents of definitions files in the
  329. X    Library will not necessarily be able to recompile the application
  330. X    to use the modified definitions.)
  331. X
  332. X    b) Accompany the work with a written offer, valid for at
  333. X    least three years, to give the same user the materials
  334. X    specified in Subsection 6a, above, for a charge no more
  335. X    than the cost of performing this distribution.
  336. X
  337. X    c) If distribution of the work is made by offering access to copy
  338. X    from a designated place, offer equivalent access to copy the above
  339. X    specified materials from the same place.
  340. X
  341. X    d) Verify that the user has already received a copy of these
  342. X    materials or that you have already sent this user a copy.
  343. X
  344. X  For an executable, the required form of the "work that uses the
  345. XLibrary" must include any data and utility programs needed for
  346. Xreproducing the executable from it.  However, as a special exception,
  347. Xthe source code distributed need not include anything that is normally
  348. Xdistributed (in either source or binary form) with the major
  349. Xcomponents (compiler, kernel, and so on) of the operating system on
  350. Xwhich the executable runs, unless that component itself accompanies
  351. Xthe executable.
  352. X
  353. X  It may happen that this requirement contradicts the license
  354. Xrestrictions of other proprietary libraries that do not normally
  355. Xaccompany the operating system.  Such a contradiction means you cannot
  356. Xuse both them and the Library together in an executable that you
  357. Xdistribute.
  358. X
  359. X  7. You may place library facilities that are a work based on the
  360. XLibrary side-by-side in a single library together with other library
  361. Xfacilities not covered by this License, and distribute such a combined
  362. Xlibrary, provided that the separate distribution of the work based on
  363. Xthe Library and of the other library facilities is otherwise
  364. Xpermitted, and provided that you do these two things:
  365. X
  366. X    a) Accompany the combined library with a copy of the same work
  367. X    based on the Library, uncombined with any other library
  368. X    facilities.  This must be distributed under the terms of the
  369. X    Sections above.
  370. X
  371. X    b) Give prominent notice with the combined library of the fact
  372. X    that part of it is a work based on the Library, and explaining
  373. X    where to find the accompanying uncombined form of the same work.
  374. X
  375. X  8. You may not copy, modify, sublicense, link with, or distribute
  376. Xthe Library except as expressly provided under this License.  Any
  377. Xattempt otherwise to copy, modify, sublicense, link with, or
  378. Xdistribute the Library is void, and will automatically terminate your
  379. Xrights under this License.  However, parties who have received copies,
  380. Xor rights, from you under this License will not have their licenses
  381. Xterminated so long as such parties remain in full compliance.
  382. X
  383. X  9. You are not required to accept this License, since you have not
  384. Xsigned it.  However, nothing else grants you permission to modify or
  385. Xdistribute the Library or its derivative works.  These actions are
  386. Xprohibited by law if you do not accept this License.  Therefore, by
  387. Xmodifying or distributing the Library (or any work based on the
  388. XLibrary), you indicate your acceptance of this License to do so, and
  389. Xall its terms and conditions for copying, distributing or modifying
  390. Xthe Library or works based on it.
  391. X
  392. X  10. Each time you redistribute the Library (or any work based on the
  393. XLibrary), the recipient automatically receives a license from the
  394. Xoriginal licensor to copy, distribute, link with or modify the Library
  395. Xsubject to these terms and conditions.  You may not impose any further
  396. Xrestrictions on the recipients' exercise of the rights granted herein.
  397. XYou are not responsible for enforcing compliance by third parties to
  398. Xthis License.
  399. X
  400. X  11. If, as a consequence of a court judgment or allegation of patent
  401. Xinfringement or for any other reason (not limited to patent issues),
  402. Xconditions are imposed on you (whether by court order, agreement or
  403. Xotherwise) that contradict the conditions of this License, they do not
  404. Xexcuse you from the conditions of this License.  If you cannot
  405. Xdistribute so as to satisfy simultaneously your obligations under this
  406. XLicense and any other pertinent obligations, then as a consequence you
  407. Xmay not distribute the Library at all.  For example, if a patent
  408. Xlicense would not permit royalty-free redistribution of the Library by
  409. Xall those who receive copies directly or indirectly through you, then
  410. Xthe only way you could satisfy both it and this License would be to
  411. Xrefrain entirely from distribution of the Library.
  412. X
  413. XIf any portion of this section is held invalid or unenforceable under any
  414. Xparticular circumstance, the balance of the section is intended to apply,
  415. Xand the section as a whole is intended to apply in other circumstances.
  416. X
  417. XIt is not the purpose of this section to induce you to infringe any
  418. Xpatents or other property right claims or to contest validity of any
  419. Xsuch claims; this section has the sole purpose of protecting the
  420. Xintegrity of the free software distribution system which is
  421. Ximplemented by public license practices.  Many people have made
  422. Xgenerous contributions to the wide range of software distributed
  423. Xthrough that system in reliance on consistent application of that
  424. Xsystem; it is up to the author/donor to decide if he or she is willing
  425. Xto distribute software through any other system and a licensee cannot
  426. Ximpose that choice.
  427. X
  428. XThis section is intended to make thoroughly clear what is believed to
  429. Xbe a consequence of the rest of this License.
  430. X
  431. X  12. If the distribution and/or use of the Library is restricted in
  432. Xcertain countries either by patents or by copyrighted interfaces, the
  433. Xoriginal copyright holder who places the Library under this License may add
  434. Xan explicit geographical distribution limitation excluding those countries,
  435. Xso that distribution is permitted only in or among countries not thus
  436. Xexcluded.  In such case, this License incorporates the limitation as if
  437. Xwritten in the body of this License.
  438. X
  439. X  13. The Free Software Foundation may publish revised and/or new
  440. Xversions of the Library General Public License from time to time.
  441. XSuch new versions will be similar in spirit to the present version,
  442. Xbut may differ in detail to address new problems or concerns.
  443. X
  444. XEach version is given a distinguishing version number.  If the Library
  445. Xspecifies a version number of this License which applies to it and
  446. X"any later version", you have the option of following the terms and
  447. Xconditions either of that version or of any later version published by
  448. Xthe Free Software Foundation.  If the Library does not specify a
  449. Xlicense version number, you may choose any version ever published by
  450. Xthe Free Software Foundation.
  451. X
  452. X  14. If you wish to incorporate parts of the Library into other free
  453. Xprograms whose distribution conditions are incompatible with these,
  454. Xwrite to the author to ask for permission.  For software which is
  455. Xcopyrighted by the Free Software Foundation, write to the Free
  456. XSoftware Foundation; we sometimes make exceptions for this.  Our
  457. Xdecision will be guided by the two goals of preserving the free status
  458. Xof all derivatives of our free software and of promoting the sharing
  459. Xand reuse of software generally.
  460. X
  461. X                NO WARRANTY
  462. X
  463. X  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
  464. XWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
  465. XEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
  466. XOTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
  467. XKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
  468. XIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  469. XPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  470. XLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
  471. XTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  472. X
  473. X  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  474. XWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
  475. XAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
  476. XFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
  477. XCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
  478. XLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
  479. XRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
  480. XFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
  481. XSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  482. XDAMAGES.
  483. X
  484. X             END OF TERMS AND CONDITIONS
  485. X
  486. X     Appendix: How to Apply These Terms to Your New Libraries
  487. X
  488. X  If you develop a new library, and you want it to be of the greatest
  489. Xpossible use to the public, we recommend making it free software that
  490. Xeveryone can redistribute and change.  You can do so by permitting
  491. Xredistribution under these terms (or, alternatively, under the terms of the
  492. Xordinary General Public License).
  493. X
  494. X  To apply these terms, attach the following notices to the library.  It is
  495. Xsafest to attach them to the start of each source file to most effectively
  496. Xconvey the exclusion of warranty; and each file should have at least the
  497. X"copyright" line and a pointer to where the full notice is found.
  498. X
  499. X    <one line to give the library's name and a brief idea of what it does.>
  500. X    Copyright (C) <year>  <name of author>
  501. X
  502. X    This library is free software; you can redistribute it and/or
  503. X    modify it under the terms of the GNU Library General Public
  504. X    License as published by the Free Software Foundation; either
  505. X    version 2 of the License, or (at your option) any later version.
  506. X
  507. X    This library is distributed in the hope that it will be useful,
  508. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  509. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  510. X    Library General Public License for more details.
  511. X
  512. X    You should have received a copy of the GNU Library General Public
  513. X    License along with this library; if not, write to the Free
  514. X    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  515. X
  516. XAlso add information on how to contact you by electronic and paper mail.
  517. X
  518. XYou should also get your employer (if you work as a programmer) or your
  519. Xschool, if any, to sign a "copyright disclaimer" for the library, if
  520. Xnecessary.  Here is a sample; alter the names:
  521. X
  522. X  Yoyodyne, Inc., hereby disclaims all copyright interest in the
  523. X  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
  524. X
  525. X  <signature of Ty Coon>, 1 April 1990
  526. X  Ty Coon, President of Vice
  527. X
  528. XThat's all there is to it!
  529. END_OF_FILE
  530. if test 25265 -ne `wc -c <'COPYING-LIB'`; then
  531.     echo shar: \"'COPYING-LIB'\" unpacked with wrong size!
  532. fi
  533. # end of 'COPYING-LIB'
  534. fi
  535. if test -f 'ChangeLog' -a "${1}" != "-c" ; then 
  536.   echo shar: Will not clobber existing file \"'ChangeLog'\"
  537. else
  538. echo shar: Extracting \"'ChangeLog'\" \(8607 characters\)
  539. sed "s/^X//" >'ChangeLog' <<'END_OF_FILE'
  540. XTue Apr  6 00:46:45 1993  Gray Watson  (gray at toaster.antaire.com)
  541. X
  542. X    * Upgraded to version 1.2.0.  Ready for 2nd release to
  543. X    comp.sources.unix.  Lots of work on the manual.
  544. X
  545. XMon Apr  5 18:28:05 1993  Gray Watson  (gray at toaster.antaire.com)
  546. X
  547. X    * Finished adding token "check-funcs" to check the arguments of
  548. X    some common string functions to see whether they are in the heap.
  549. X    if so it tries to verify that the pointers are good.
  550. X
  551. XSun Apr  4 21:24:45 1993  Gray Watson  (gray at toaster.antaire.com)
  552. X
  553. X    * Added token "log-unknown" to dump non-free unknown pointers as
  554. X    well as known ones.  Also cleaned up the displaying of the
  555. X    pointers.
  556. X
  557. X    * comp.sources.unix is almost ready to post so lots of last minute
  558. X    cleanups in the manual, etc.
  559. X
  560. X    * Started integration of function argument checking.
  561. X
  562. XTue Mar 30 19:36:27 1993  Gray Watson  (gray at toaster.antaire.com)
  563. X
  564. X    * Changed malloc.h defines so malloc routines are handled as well
  565. X    as the ALLOC macros.
  566. X
  567. X    * malloc_dbg program now reports on the token NAME and values.
  568. X
  569. X    * Added initial string files for string support in the future.
  570. X
  571. X    * A number of minor changes: fixed gcc compilation problems per
  572. X    scott's help, combined malloc_lp.h into malloc.h, cleaned most .h
  573. X    and .c files.
  574. X
  575. XFri Mar 26 04:00:14 1993  Gray Watson  (gray at toaster.antaire.com)
  576. X
  577. X    * Fixed post 1.1.6 problem with chunk.c.  Boy do I need some
  578. X    automated testing tools.  Discovered the illusive localtime
  579. X    fence-post error.  Had a hard time tracking it down.  Maybe due to
  580. X    the fact that the checks were not being made on dblock fence posts
  581. X    before?
  582. X
  583. X    * Upgraded to 1.1.6
  584. X
  585. X    * Found some problems with malloc debug codes.  Use of DB_FENCE
  586. X    and CHECK_LISTS and some others were improper.  A MALLOC_DEBUG
  587. X    value of 0x403000 would crash all malloc programs.  :-)
  588. X
  589. X    * Added some better comments to all files and cleaned up most
  590. X    files too.
  591. X
  592. XFri Mar 12 18:35:02 1993  Gray Watson  (gray at toaster.antaire.com)
  593. X
  594. X    * Upgraded to 1.1.5.
  595. X
  596. XSat Feb 13 17:25:43 1993  Gray Watson  (gray at toaster.antaire.com)
  597. X
  598. X    * Finished add a number of const operators to improve coding per
  599. X    scott's recommendations.
  600. X
  601. XSat Jan 30 12:33:43 1993  Gray Watson  (gray at toaster.antaire.com)
  602. X
  603. X    * Took out the check_vars call inside of malloc_strerror since
  604. X    _malloc_perror calls malloc_strerror which would go quickly
  605. X    recursive.  Thanks scott.
  606. X
  607. X    * Changed to version 1.1.4
  608. X
  609. XTue Jan  5 00:00:00 1993  Gray Watson  (gray at toaster.antaire.com)
  610. X
  611. X    * Sent off 1.1.3 shar files to comp.sources.unix.
  612. X
  613. XSat Jan  2 00:16:58 1993  Gray Watson  (gray at toaster.antaire.com)
  614. X
  615. X    * Made last minute changes to solve some gcc/ansi errors and
  616. X    to the manual to get things ready for the post.
  617. X
  618. XSun Dec 27 20:28:19 1992  Gray Watson  (gray at toaster.antaire.com)
  619. X
  620. X    * Fixed problem with some external functions in malloc.c not
  621. X    reseting the in_alloc flag.  Also removed some testing of unsigned
  622. X    variables < 0 in chunk.c per gcc 2.3.3 warnings.
  623. X
  624. X    * Changed version to 1.1.3.
  625. X
  626. XMon Dec 21 15:31:50 1992  Gray Watson  (gray at toaster.antaire.com)
  627. X
  628. X    * Created the series of shar files in preparation to posting to
  629. X    comp.unix.sources.  Looking good.
  630. X
  631. XThu Dec 17 18:33:38 1992  Gray Watson  (gray at toaster.antaire.com)
  632. X
  633. X    * Renamed a number of files to comply with the Sys5 12 character
  634. X    restrictions (14 - 2 for RCS/CVS/SCCS).  Yeach.  malloc_debug ->
  635. X    malloc_dbg.
  636. X
  637. XSat Nov 14 15:59:53 1992  Gray Watson  (gray at toaster.antaire.com)
  638. X
  639. X    * Added all external functions to configure and conf.h even though
  640. X    the library assumes that some functions will be resolved.  Also
  641. X    upgraded the version number to 1.01gamma (oooooh).
  642. X
  643. X    * Added print-perror debug token for logging messages to STDERR as
  644. X    well as log-files.  Removed stdio from the malloc library to make
  645. X    sure it does not go recursive (alloc for stderr) at a bad time.
  646. X
  647. XWed Nov 11 18:19:49 1992  Gray Watson  (gray at toaster.antaire.com)
  648. X
  649. X    * Moved the heap_check calls from chunk.c over to malloc so we can
  650. X    be guaranteed that it gets called only once per user call.
  651. X    chunk's routines often cross-call each other meaning that
  652. X    heap-check was being run 5 times be realloc.  YEACH!!
  653. X
  654. XTue Nov 10 17:55:53 1992  Gray Watson  (gray at toaster.antaire.com)
  655. X
  656. X    * Added two new debug-tokens: log-blocks and heap-check-map.  Also
  657. X    made sure that heap_check was being called from everywhere.
  658. X    Updated the manual and corresponding files.
  659. X
  660. X    * Added library functions that may not be defined.  Updated the
  661. X    conf.h.in and configure.in files to improve confiurability.
  662. X    Upgraded the manual which still needs a lot of work (sigh).
  663. X
  664. XMon Nov  9 19:21:25 1992  Gray Watson  (gray at toaster.antaire.com)
  665. X
  666. X    * Added configure, configure.in, conf.h.in, and Makefile.in to try
  667. X    and conform with autoconf specs.  What a bear.  The documentation
  668. X    for autoconf needs a whole bunch more examples, etc.  Sigh.
  669. X    Removed all the MEMORY and STRING defines, etc.
  670. X
  671. XThu Nov  5 22:13:18 1992  Gray Watson  (gray at toaster.antaire.com)
  672. X
  673. X    * Released version 1.01b.  Sending it off to some folks.
  674. X
  675. X    * Lots and lots of changes.  Translated all programs into non-ansi
  676. X    C dependance and then went back again when I found some problems
  677. X    with my macros.  :-)  Took out all (and I mean all) Antaire
  678. X    dependancies and defines.
  679. X
  680. XThu Oct 22 00:47:18 1992  Gray Watson  (gray at toaster.antaire.com)
  681. X
  682. X    * Ran through most of the debug-flag functionality testing and
  683. X    tweaking.  Found some bugs on dblock handling and some messed up
  684. X    logic with the way the LOG flags were working.
  685. X
  686. X    * malloc_debug is looking good.  It now outputs C or Bourne shell
  687. X    code and seems to work in both environments.  What do sh folks use
  688. X    in the place of c-shell aliasing?  I guess use bash.  :-)
  689. X
  690. XWed Oct 21 03:27:35 1992  Gray Watson  (gray at toaster.antaire.com)
  691. X
  692. X    * Major changes.  I sort of went overboard tonight.  I integrated
  693. X    the new malloc_debug program which sets all the debug variables
  694. X    for you.  I also added a .mallocrc which you can define with tags
  695. X    exactly the functionality you want to happen.  No more levels!!
  696. X
  697. X    * Did some renaming of files, cleaned up some other things,
  698. X    had to rework a number of items to get new debug flags working.
  699. X
  700. XTue Oct 20 18:06:36 1992  Gray Watson  (gray at toaster.antaire.com)
  701. X
  702. X    * Removed useful.h requirements and integrated necessary
  703. X    definitions into malloc.h.
  704. X
  705. X    * Transfered malloc.txt documentation into malloc.texinfo.  Boy
  706. X    is it nifty!!  And damn easy!!!
  707. X
  708. X    * Major changes to improve general machine independance.  Added
  709. X    malloc_mach.h.  Moved alloc.[ch] to malloc.[ch] for sanity
  710. X    reasons.
  711. X
  712. XTue Oct 13 16:14:17 1992  Gray Watson  (gray at toaster.antaire.com)
  713. X
  714. X    * Made various cosmetic changes.  Fixed realloc inbound pointer
  715. X    checking per MALLOC_ADDRESS.  Fixed problem with MALLOC_ADDRESS
  716. X    initialization to NULL causing free to "find" NULL pointers.  :-)
  717. X
  718. X    * Separated the PERROR debug level and the KILL_SELF level.  Now
  719. X    (by default) all memory errors are logged at level 1 and above and
  720. X    malloc kills itself at level 2 and above.
  721. X
  722. XMon Sep 28 23:24:36 1992  Gray Watson  (gray at toaster.antaire.com)
  723. X
  724. X    * Added MALLOC_ADDRESS support for free.  MALLOC_ADDRESS counts
  725. X    now also apply to frees also.
  726. X
  727. XMon Sep 21 20:39:38 1992  Gray Watson  (gray at toaster)
  728. X
  729. X    * Fixed some size problems with bounds checking enabled.
  730. X
  731. X    * Made free be able to report who freed a pointer.  I don't know
  732. X    why this wasn't caught before.  free wasn't even using its
  733. X    file/line arguments.
  734. X
  735. XThu Sep  3 03:23:39 1992  Gray Watson  (gray at toaster)
  736. X
  737. X    * Added ability to realloc a NULL pointer with an ifdef to
  738. X    disable.  Useful in realloc loops where the first time you don't
  739. X    have to alloc it.
  740. X
  741. XFri Aug 14 15:54:03 1992  Gray Watson  (gray at toaster)
  742. X
  743. X    * Added a bunch of new environmental variables features:
  744. X    MALLOC_ADDRESS now can have a :# argument.  MALLOC_START now has
  745. X    two formats, the old number and new file:line.  Looks nice!
  746. X
  747. X    * Made a pass through chunk.c and fixed a number of problems where
  748. X    debug output pnt/size did not match user-supplied information.
  749. X
  750. X    * Moved most of the debug variables into alloc.c from chunk.c and
  751. X    added a standardizied check_debug_vars() checking routine.
  752. X
  753. XTue Jul 21 16:06:13 1992  Gray Watson  (gray at toaster)
  754. X
  755. X    * Fixed malloc count statistics.  Removed duplicate malloc_count
  756. X    varaibale from a number of places.
  757. X
  758. XMon Mar 23 10:49:25 1992  Gray Watson  (gray at toaster)
  759. X
  760. X    * Released version 0.04 with new env variable features.
  761. X
  762. XThu Mar 12 19:28:34 1992  Gray Watson  (gray at toaster)
  763. X
  764. X    * Fixed a large problem with chunk.c not reporting the correct
  765. X    memory address when listing unfreed memory.  This was discovered
  766. X    when MALLOC_ADDRESS was not working correctly.
  767. END_OF_FILE
  768. if test 8607 -ne `wc -c <'ChangeLog'`; then
  769.     echo shar: \"'ChangeLog'\" unpacked with wrong size!
  770. fi
  771. # end of 'ChangeLog'
  772. fi
  773. if test -f 'Makefile.in' -a "${1}" != "-c" ; then 
  774.   echo shar: Will not clobber existing file \"'Makefile.in'\"
  775. else
  776. echo shar: Extracting \"'Makefile.in'\" \(2972 characters\)
  777. sed "s/^X//" >'Makefile.in' <<'END_OF_FILE'
  778. X###############################################################################
  779. X# Makefile for the Malloc library.
  780. X# $Id: Makefile.all.in,v 1.11 1993/04/06 05:23:08 gray Exp $
  781. X###############################################################################
  782. X
  783. X# default root installation directory
  784. Xprefix = /usr/local
  785. X
  786. Xsrcdir = @srcdir@
  787. Xbindir = $(prefix)/bin
  788. Xlibdir = $(prefix)/lib
  789. Xincdir = $(prefix)/inc
  790. Xinfodir = $(prefix)/info
  791. X
  792. X# default c-compiler
  793. XCC = @CC@
  794. X
  795. XDEFS =
  796. XINCS = -I$(srcdir)
  797. XLIBS = @LIBS@ -L$(srcdir) -lmalloc
  798. X
  799. XLIBRARY    = libmalloc.a
  800. XUTIL = malloc_dbg
  801. XINFOFILE = malloc.info
  802. X
  803. XCCFLAGS = -g
  804. XLDFLAGS = -g
  805. X
  806. XINSTALL = @INSTALL@
  807. XINSTALL_PROGRAM = @INSTALL_PROGRAM@
  808. XINSTALL_DATA = @INSTALL_DATA@
  809. X
  810. X###############################################################################
  811. X# End of system configuration section.
  812. X###############################################################################
  813. X
  814. XSHELL = /bin/sh
  815. X
  816. XHFLS = malloc.h
  817. XOBJS = chunk.o compat.o error.o heap.o malloc.o malloc_lp.o malloc_str.o
  818. X
  819. XCFLAGS = $(CCFLAGS)
  820. XTESTS = malloc_t
  821. X
  822. X# .PHONY : all
  823. Xall : $(LIBRARY) $(UTIL)
  824. X
  825. X# .PHONY : clean
  826. Xclean :
  827. X    rm -f a.out core *.o *.t
  828. X
  829. X# .PHONY : clobber
  830. Xclobber : clean
  831. X    rm -f $(LIBRARY) $(TESTS) $(UTIL)
  832. X
  833. X# .PHONY : realclean
  834. Xrealclean : clobber
  835. X
  836. X# .PHONY : distclean
  837. Xdistclean : clobber
  838. X    rm -f Makefile conf.h config.status
  839. X#    rm -f configure
  840. X
  841. X# .PHONY : install
  842. Xinstall : $(HFLS) $(UTIL) $(LIBRARY) $(INFOFILES)
  843. X    $(INSTALL_DATA) $(HFLS) $(incdir)
  844. X    $(INSTALL_PROGRAM) $(UTIL) $(bindir)
  845. X    $(INSTALL_DATA) $(LIBRARY) $(libdir)
  846. X    @RANLIB@ $(libdir)/$(LIBRARY)
  847. X#    $(INSTALL_DATA) $(INFOFILES) $(infodir)
  848. X
  849. X$(LIBRARY) : $(OBJS)
  850. X    ar cr $(LIBRARY) $?
  851. X    @RANLIB@ $@
  852. X    - chmod 660 $@
  853. X
  854. X$(UTIL) : malloc_dbg.o $(LIBRARY)
  855. X    rm -f $@
  856. X    $(CC) $(LDFLAGS) $@.o $(LIBS)
  857. X    mv a.out $@
  858. X
  859. X# .PHONY : tests
  860. Xtests : $(TESTS)
  861. X
  862. Xmalloc_t : malloc_t.o $(LIBRARY)
  863. X    rm -f $@
  864. X    $(CC) $(LDFLAGS) malloc_t.o $(LIBS)
  865. X    mv a.out $@
  866. X
  867. X.c.o :
  868. X    rm -f $@
  869. X    $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o $@
  870. X
  871. X.texi.info :
  872. X    makeinfo $<
  873. X
  874. X###############################################################################
  875. X#
  876. X# These dependencies are automatically generated.  Do not edit by hand.
  877. X#
  878. X
  879. Xchunk.o : chunk.c malloc.h malloc_loc.h chunk.h chunk_loc.h compat.h conf.h \
  880. X  dbg_values.h error.h error_val.h heap.h version.h 
  881. Xcompat.o : compat.c malloc.h malloc_loc.h compat.h conf.h 
  882. Xerror.o : error.c malloc.h malloc_loc.h chunk.h compat.h conf.h dbg_values.h \
  883. X  error.h 
  884. Xheap.o : heap.c malloc.h malloc_loc.h chunk.h compat.h conf.h error.h error_val.h \
  885. X  heap.h 
  886. Xmalloc.o : malloc.c malloc.h malloc_loc.h chunk.h compat.h conf.h dbg_values.h \
  887. X  error.h error_str.h error_val.h heap.h malloc_lp.h 
  888. Xmalloc_dbg.o : malloc_dbg.c malloc.h malloc_loc.h compat.h conf.h dbg_tokens.h \
  889. X  dbg_values.h version.h 
  890. Xmalloc_lp.o : malloc_lp.c malloc.h 
  891. Xmalloc_str.o : malloc_str.c malloc.h malloc_loc.h conf.h chunk.h dbg_values.h \
  892. X  error.h malloc_str.h 
  893. Xmalloc_t.o : malloc_t.c malloc.h 
  894. Xsample.o : sample.c malloc.h 
  895. END_OF_FILE
  896. if test 2972 -ne `wc -c <'Makefile.in'`; then
  897.     echo shar: \"'Makefile.in'\" unpacked with wrong size!
  898. fi
  899. # end of 'Makefile.in'
  900. fi
  901. if test -f 'Manifest' -a "${1}" != "-c" ; then 
  902.   echo shar: Will not clobber existing file \"'Manifest'\"
  903. else
  904. echo shar: Extracting \"'Manifest'\" \(2583 characters\)
  905. sed "s/^X//" >'Manifest' <<'END_OF_FILE'
  906. X-------------------------------------------------------------------------------
  907. X$Id: Manifest,v 1.13 1993/04/05 01:28:47 gray Exp $
  908. X-------------------------------------------------------------------------------
  909. XDescription of the files in the malloc package.
  910. X
  911. XCOPYING-LIB        The famous GNU Library Public License.
  912. X
  913. XChangelog        Change log entries detailing major module
  914. X            changes.
  915. X
  916. XMakefile.in        Used by configure to create the Makefile.
  917. X
  918. XManifest        This file.
  919. X
  920. XNOTES            General Notes of the malloc routines and
  921. X            associated algorithms.
  922. X
  923. XREADME            Quick startup notes.
  924. X
  925. XTTD            Things To Do list.  It only gets longer and
  926. X            longer.
  927. X
  928. Xchunk.[ch]        Lower level allocation routines.  This is the
  929. X            meat of the allocation algorithms.  Manages
  930. X            and debugs the administration structures of
  931. X            the heap.  Too large!
  932. X
  933. Xchunk_loc.h        Local defines specific to the chunk routines
  934. X            only.
  935. X
  936. Xcompat.[ch]        System compatibility routines if missing
  937. X            functionality.
  938. X
  939. Xconf.h.in        Used by configure to create the conf.h
  940. X            configurations.
  941. X
  942. Xconfigure        Configure script.
  943. X
  944. Xconfigure.in        Used by autoconf to create the configure
  945. X            script.
  946. X
  947. Xdbg_tokens.h        Tokens that correspond to debugging
  948. X            functionality.
  949. X
  950. Xdbg_values.h        Values corresponding to the debug tokens.
  951. X
  952. Xerror.[ch]        Debugging routines and others that provide
  953. X            user output.
  954. X
  955. Xerror_str.h        Strings that correspond to malloc error codes.
  956. X
  957. Xerror_val.h        General error codes for the malloc module.
  958. X
  959. Xheap.[ch]        Possibly machine specific routines for
  960. X            allocating space on and manipulating the heap.
  961. X
  962. Xmalloc.[ch]        Higher level alloc routines including malloc,
  963. X            free, realloc, etc.  These are the routines to
  964. X            be called from user space.
  965. X
  966. Xmalloc.info        User-level gnu info manual file for the malloc
  967. X            routines.  Suitable as a text manual also.
  968. X
  969. Xmalloc.texi        Texinfo user manual for generating TeX or Info
  970. X            formats.  This is not distributed normally to
  971. X            conserve space.  Let me know if you want a
  972. X            copy.
  973. X
  974. Xmalloc_dbg.c        Program that assists in the setting of the
  975. X            MALLOC_DEBUG and other debug environmental
  976. X            variables.
  977. X
  978. Xmalloc_loc.h        Local defines for all of the malloc routines.
  979. X
  980. Xmalloc_lp.[ch]        Leap-frog routines to provide file/line info
  981. X            to lib.
  982. X
  983. Xmalloc_str.[ch]        Malloc string routines for string testing.
  984. X
  985. Xmalloc_t.c        Meager test program for testing the malloc
  986. X            routines.
  987. X
  988. Xmallocrc        Sample RC file that is used to set the debug
  989. X            flags.
  990. X
  991. Xsample.c        A sample file to demonstrate the usage of the
  992. X            library.
  993. X
  994. Xversion.h        Version number for the library.
  995. X
  996. X-------------------------------------------------------------------------------
  997. END_OF_FILE
  998. if test 2583 -ne `wc -c <'Manifest'`; then
  999.     echo shar: \"'Manifest'\" unpacked with wrong size!
  1000. fi
  1001. # end of 'Manifest'
  1002. fi
  1003. if test -f 'NOTES' -a "${1}" != "-c" ; then 
  1004.   echo shar: Will not clobber existing file \"'NOTES'\"
  1005. else
  1006. echo shar: Extracting \"'NOTES'\" \(4169 characters\)
  1007. sed "s/^X//" >'NOTES' <<'END_OF_FILE'
  1008. X-------------------------------------------------------------------------------
  1009. X$Id: NOTES,v 1.13 1993/04/06 04:24:29 gray Exp $
  1010. X-------------------------------------------------------------------------------
  1011. X
  1012. XWARNINGS:
  1013. X
  1014. X- do not be surprised if the library catches problems with your
  1015. X    system's library routines.  It took me 6 hours once to finally
  1016. X    come to the conclusion that the localtime call, included in
  1017. X    SunOS release 4.1 (and maybe before/after), was overwriting
  1018. X    one of its fence-post markers.
  1019. X
  1020. X-------------------------------------------------------------------------------
  1021. X
  1022. XGENERAL:
  1023. X
  1024. X- dumping core on errors and then continuing did not look to be a problem to
  1025. X    implement.  However it became "not recommended" as soon as it was
  1026. X    discovered that fork (which is needed) calls malloc itself.  If the
  1027. X    heap was corrupted or some other critical error has occurred then the
  1028. X    library would quickly go recursive.
  1029. X
  1030. X- administration blocks are relocatable:
  1031. X    - any administration blocks are relocatable in the heap which means
  1032. X        that if we monitor the freeing of a block we have the
  1033. X        opportunity to swap a higher admin block down which would mean
  1034. X        we could possible locate as many admin blocks as possible in
  1035. X        low memory making more contiguous usable areas
  1036. X
  1037. X    - you have the freed blocks address
  1038. X
  1039. X    - as you go through the admin blocks, until you get to the right entry,
  1040. X        save a pointer to the highest (or lowest) one
  1041. X
  1042. X    - when you find the free block, find out if it is lower (or higher)
  1043. X        than the highest admin block and bcopy the admin block down and
  1044. X        redo the pointers
  1045. X
  1046. X-------------------------------------------------------------------------------
  1047. X
  1048. XCODING WARNINGS:
  1049. X
  1050. X- watch for heaps growing up or down (all subtraction or other position
  1051. X    dependent code must be changed to macros in heap.h) >,<,-,+,etc
  1052. X- watch for bounds checking assuming + or - code.
  1053. X
  1054. X-------------------------------------------------------------------------------
  1055. X
  1056. XCHUNK INFORMATION:
  1057. X
  1058. X- it is assumed that none of the __FILE__ arguments are on the heap because
  1059. X    to determine whether a dblock is free or not it looks at the next
  1060. X    argument (unioned with the file argument) and sees if it is null or
  1061. X    in the heap meaning it is at the end or middle of a free list.
  1062. X
  1063. X
  1064. X-------------------------------------------------------------------------------
  1065. X
  1066. XDBLOCK METHOD:
  1067. X
  1068. X- have the bblock admin struct point to the dblock admin structure block which
  1069. X    contains a number of dblock admin entries.
  1070. X- have a global pointer that points to last free dblock admin structure entry
  1071. X    and has a count of the number left in the block
  1072. X- only allocate contiguous dblock admin slots so have some fragmentation
  1073. X    - must have contiguous because bblocks do not have pointer to start of
  1074. X        array
  1075. X- maybe have a sorted free list of the number of free dblock admin structs.
  1076. X    sorted in descending order
  1077. X- you have the free pointer which gets you to the bblock where you can see if
  1078. X    it is a dblock and if it is on the correct boundary.  Then you go to
  1079. X    the dblock admin struct to get the file, line, size info.
  1080. X- the bblock tells you of the number of bits in the chunk, etc.
  1081. X- have some way to run through the dblock admin slot blocks to verify that
  1082. X    crc's have not been overwritten.
  1083. X
  1084. X-------------------------------------------------------------------------------
  1085. X
  1086. XNEW ALGORITHMS:
  1087. X
  1088. X- maybe have some sort of bitmask for free space/used space like BSD disk
  1089. X    blocks
  1090. X- look in your free_list for first block.
  1091. X    - if NULL then move up a bin and try to divide
  1092. X    - continue until up X blocks then sbrk a new smaller block
  1093. X- maybe try a finite number of free_bins above the one you want to limit
  1094. X    fragmentation, test this thing
  1095. X
  1096. X-------------------------------------------------------------------------------
  1097. X
  1098. XOVERHEAD:
  1099. X
  1100. X- dblock: 8 bytes per pointer
  1101. X- bblock: 12 bytes per pointer
  1102. X
  1103. X-------------------------------------------------------------------------------
  1104. X
  1105. XTHANKS:
  1106. X
  1107. XSpecial thanks to Scott Michel <scottm@intime.intime.COM> for
  1108. Xlistening to my endless chatter and finding/solvings lots of stupid
  1109. Xproblems during the alpha stages of this library.
  1110. X
  1111. X-------------------------------------------------------------------------------
  1112. END_OF_FILE
  1113. if test 4169 -ne `wc -c <'NOTES'`; then
  1114.     echo shar: \"'NOTES'\" unpacked with wrong size!
  1115. fi
  1116. # end of 'NOTES'
  1117. fi
  1118. if test -f 'README' -a "${1}" != "-c" ; then 
  1119.   echo shar: Will not clobber existing file \"'README'\"
  1120. else
  1121. echo shar: Extracting \"'README'\" \(1648 characters\)
  1122. sed "s/^X//" >'README' <<'END_OF_FILE'
  1123. X-------------------------------------------------------------------------------
  1124. X$Id: README,v 1.14 1993/04/01 04:59:15 gray Exp $
  1125. X-------------------------------------------------------------------------------
  1126. X
  1127. XINSTALLATION:
  1128. X
  1129. X1) Run 'sh ./configure' to configure the library and generate the
  1130. X    Makefile and conf.h.  Examine conf.h (especially) as well as
  1131. X    Makefile to make sure configure set things up correctly.
  1132. X
  1133. X2) Typing 'make' should be enough to build libmalloc.a and
  1134. X    malloc_dbg program.
  1135. X
  1136. X3) Typing 'make test' should build the malloc_t test program
  1137. X
  1138. X-------------------------------------------------------------------------------
  1139. X
  1140. XDOCUMENTATION:
  1141. X
  1142. XExamine the malloc.info file.  Is is a gnu-info file having the
  1143. Xuser-documentation for the malloc subsystem.  It can be installed in
  1144. Xthe emacs info directory and read with emacs/info or the info program
  1145. Xavailable at GNU archive sites.  It is also suitable for reading as
  1146. Xtext.
  1147. X
  1148. XIt can be reproduced from the malloc.texi texinfo file which also can
  1149. Xgenerate TeX hardcopy output.  You may need the new texinfo.tex from
  1150. Xthe gnu archive sites.
  1151. X
  1152. X-------------------------------------------------------------------------------
  1153. X
  1154. XNOTES:
  1155. X
  1156. X- the system is definitely dependent on a good ansi-c compiler like gcc.
  1157. X- the file Manifest contains a list of each of the file and what it does.
  1158. X- configure can be regenerated by the autoconf script.
  1159. X- the file sample.c contains an example of some of the malloc macros and
  1160. X    functions.
  1161. X
  1162. XIf you have any problems with porting issues feel free to send me mail.
  1163. Xgray.watson@antaire.com
  1164. X
  1165. X-------------------------------------------------------------------------------
  1166. END_OF_FILE
  1167. if test 1648 -ne `wc -c <'README'`; then
  1168.     echo shar: \"'README'\" unpacked with wrong size!
  1169. fi
  1170. # end of 'README'
  1171. fi
  1172. if test -f 'TTD' -a "${1}" != "-c" ; then 
  1173.   echo shar: Will not clobber existing file \"'TTD'\"
  1174. else
  1175. echo shar: Extracting \"'TTD'\" \(5069 characters\)
  1176. sed "s/^X//" >'TTD' <<'END_OF_FILE'
  1177. X-------------------------------------------------------------------------------
  1178. X$Id: TTD,v 1.19 1993/04/05 01:28:49 gray Exp $
  1179. X-------------------------------------------------------------------------------
  1180. X
  1181. XIMPORTANT:
  1182. X
  1183. X- add special-blocks with a sorted-free list
  1184. X    - over X bits then it becomes special
  1185. X    - if in free special and someone matches then drop the rest of
  1186. X        the allocation into a free list maybe, maybe-not
  1187. X- be able to break up bigger blocks of memory into small ones
  1188. X    - have a split(x) which asks for x+1 bits and then splits it into
  1189. X        2 blocks of x bits
  1190. X    - split then might go recursive
  1191. X    - maybe have a level X and only jump up a maximum of X bits to find
  1192. X        free space (depending on how much you want to fragment)
  1193. X- change the large block allocation process:
  1194. X    - needs to be a lot cleaner and produce a denser heap
  1195. X
  1196. X-------------------------------------------------------------------------------
  1197. X
  1198. XCHECKING:
  1199. X
  1200. X- check in heap_check the cleared space above each allocation instead of
  1201. X    only the fence posts
  1202. X- maybe write the address % 256 into bytes instead of a constant
  1203. X    - maybe it would slow it down.
  1204. X    - a token/option?
  1205. X    - \305 is recognizable however
  1206. X- another token to have the library never reclaim memory, always extend the
  1207. X    heap (i.e. don't use free lists at all)
  1208. X    - this would grow into an enormous heap however.
  1209. X- maybe add another debug level which stores crc information about internal
  1210. X    heap structures and verifies it during run time.  slow, slow!!
  1211. X
  1212. X-------------------------------------------------------------------------------
  1213. X
  1214. XSTRING SUPPORT:
  1215. X
  1216. X- have special macros for string allocation for string functions.  possibly
  1217. X    uppercase or normal overrides.
  1218. X- maybe build in most string functions (strcat, strcpy, etc)
  1219. X- have a checking level/value that runs though the strings and makes sure
  1220. X    they have a NULL in them.
  1221. X- this may not be too important in the face of the bounds checking stuff but
  1222. X    it may report errors more intelligently
  1223. X- need to think if more support for strings would be a good thing
  1224. X- it would be able to locate common errors with strings a lot closer to the
  1225. X    actual problem.
  1226. X- inform the user to include the string stuff at the end of include list
  1227. X
  1228. X-------------------------------------------------------------------------------
  1229. X
  1230. XGENERAL:
  1231. X
  1232. X- for fence underflow, print out the allocation below and for fence overflow
  1233. X    the allocation above if possible
  1234. X- maybe expand_string dump the first X bytes of an allocation per a token
  1235. X- add __builtin_return_value support for higher gcc versions (2.2.0+)
  1236. X- have either a bunch of free or used bblocks be:
  1237. X    - start block and then a set of continuation blocks
  1238. X    - this would mean we do not have to hit each bblock entry to redo
  1239. X        the type flag
  1240. X- handle memalign, valloc, maybe some form of mallopt
  1241. X- maybe use getpagesize (mach_dep.c) to determine BASIC block size
  1242. X- handle 0 length allocations correctly if the #define is set
  1243. X    - i.e. maybe give back a small section with bounds-checking touching
  1244. X- manage dblock_admin entries better
  1245. X    - map out usage and get some stats
  1246. X    - add to normal db_free lists, zero out each of the entries.  if they
  1247. X        are both zero or some magic X then we need to get more bblock
  1248. X        space for the dblocks.
  1249. X- special case last bunch of bblocks:
  1250. X    - have a pointer to the last contiguous set
  1251. X    - have them not in a free list
  1252. X    - if used and reallocs then just extend it
  1253. X    - if free and need some of it then extend (or not) and give
  1254. X    - maybe not worth it for 1 pointer
  1255. X- maybe make malloc_dbg use no stdio so no unwanted memory allocations.
  1256. X- turn realloc into an intelligent beasty that looks on either side
  1257. X    of existing chunk (if expanding) for free space and manages free-lists
  1258. X    appropriately
  1259. X
  1260. X-------------------------------------------------------------------------------
  1261. X
  1262. XTESTING / STATISTICS:
  1263. X
  1264. X- need to write a set of fully automated test programs
  1265. X    - maybe start with a test shell like malloc_t but stripped and then
  1266. X        run a script through it and analyse the output
  1267. X    - should be a killer that does a million hits
  1268. X- test define for allowing 0 length defines
  1269. X- test define for realloc(NULL)
  1270. X- check out situation where sbrk calls return ERROR (from the beginning and
  1271. X    in the middle).  the library should return NULL's straight off and
  1272. X    log appropriate errors.
  1273. X- add free-list statistics whenever it gets more memory to see the viability of
  1274. X    dividing larger free entries in two
  1275. X- add statistics whenever it frees memory to see the viability of combining
  1276. X    adjacent blocks
  1277. X- maybe a program that would try a standard set of tests on a number of
  1278. X    different combinations of debug-values to look for dependancies.
  1279. X
  1280. X-------------------------------------------------------------------------------
  1281. X
  1282. XRMS comments:
  1283. X    - integrate into gnu-malloc
  1284. X    - change the bit-flags into the functionality strings themselves
  1285. X    - get rid of the malloc_dbg program and the mallocrc file (too "hairy")
  1286. X    - integrate __builtin_return_address functionality from gcc
  1287. X        gdb command 'info line *ADDRESS' to get file/line
  1288. X
  1289. X-------------------------------------------------------------------------------
  1290. END_OF_FILE
  1291. if test 5069 -ne `wc -c <'TTD'`; then
  1292.     echo shar: \"'TTD'\" unpacked with wrong size!
  1293. fi
  1294. # end of 'TTD'
  1295. fi
  1296. if test -f 'malloc.c' -a "${1}" != "-c" ; then 
  1297.   echo shar: Will not clobber existing file \"'malloc.c'\"
  1298. else
  1299. echo shar: Extracting \"'malloc.c'\" \(11732 characters\)
  1300. sed "s/^X//" >'malloc.c' <<'END_OF_FILE'
  1301. X/*
  1302. X * user-level memory-allocation routines
  1303. X *
  1304. X * Copyright 1992 by Gray Watson and the Antaire Corporation
  1305. X *
  1306. X * This file is part of the malloc-debug package.
  1307. X *
  1308. X * This library is free software; you can redistribute it and/or
  1309. X * modify it under the terms of the GNU Library General Public
  1310. X * License as published by the Free Software Foundation; either
  1311. X * version 2 of the License, or (at your option) any later version.
  1312. X *
  1313. X * This library is distributed in the hope that it will be useful,
  1314. X * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1315. X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  1316. X * Library General Public License for more details.
  1317. X *
  1318. X * You should have received a copy of the GNU Library General Public
  1319. X * License along with this library (see COPYING-LIB); if not, write to the
  1320. X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1321. X *
  1322. X * The author of the program may be contacted at gray.watson@antaire.com
  1323. X */
  1324. X
  1325. X/*
  1326. X * This file contains the user-level calls to the memory allocation
  1327. X * routines.  It handles a lot of the miscellaneous support garbage for
  1328. X * chunk.c which is the real heap manager.
  1329. X */
  1330. X
  1331. X#define MALLOC_DEBUG_DISABLE
  1332. X
  1333. X#include "malloc.h"
  1334. X#include "malloc_loc.h"
  1335. X
  1336. X#include "chunk.h"
  1337. X#include "compat.h"
  1338. X#include "conf.h"
  1339. X#include "dbg_values.h"
  1340. X#include "error.h"
  1341. X#include "error_str.h"
  1342. X#include "error_val.h"
  1343. X#include "heap.h"
  1344. X#include "malloc_lp.h"
  1345. X
  1346. X#if INCLUDE_RCS_IDS
  1347. XLOCAL    char    *rcs_id =
  1348. X  "$Id: malloc.c,v 1.22 1993/04/05 22:30:13 gray Exp $";
  1349. X#endif
  1350. X
  1351. X/*
  1352. X * exported variables
  1353. X */
  1354. X/* logfile for dumping malloc info, MALLOC_LOGFILE env. var overrides this */
  1355. XEXPORT    char        *malloc_logpath    = NULL;
  1356. X/* internal malloc error number for reference purposes only */
  1357. XEXPORT    int        malloc_errno = 0;
  1358. X
  1359. X/* local routines */
  1360. XLOCAL    int        malloc_startup(void);
  1361. XEXPORT    void        malloc_shutdown(void);
  1362. X
  1363. X/* local variables */
  1364. XLOCAL    int        malloc_enabled    = FALSE; /* have we started yet? */
  1365. XLOCAL    char        in_alloc    = FALSE; /* can't be here twice */
  1366. XLOCAL    char        log_path[128]    = { NULLC }; /* storage for env path */
  1367. X
  1368. X/* debug variables */
  1369. XLOCAL    char        *malloc_address    = NULL;    /* address to catch */
  1370. XLOCAL    int        address_count    = 0;    /* address argument */
  1371. XLOCAL    char        start_file[128] = { NULLC }; /* file to start at */
  1372. XLOCAL    int        start_line    = 0;    /* line in module to start */
  1373. XLOCAL    int        start_count    = -1;    /* start after X */
  1374. XLOCAL    int        check_interval    = -1;    /* check every X */
  1375. X
  1376. X/****************************** local utilities ******************************/
  1377. X
  1378. X/*
  1379. X * hexadecimal STR to int translation
  1380. X */
  1381. XLOCAL    int    hex_to_int(char * str)
  1382. X{
  1383. X  int        ret;
  1384. X  
  1385. X  /* strip off spaces */
  1386. X  for (; *str == ' ' || *str == '\t'; str++);
  1387. X  
  1388. X  /* skip a leading 0[xX] */
  1389. X  if (*str == '0' && (*(str + 1) == 'x' || *(str + 1) == 'X'))
  1390. X    str += 2;
  1391. X  
  1392. X  for (ret = 0;; str++) {
  1393. X    if (*str >= '0' && *str <= '9')
  1394. X      ret = ret * 16 + (*str - '0');
  1395. X    else if (*str >= 'a' && *str <= 'f')
  1396. X      ret = ret * 16 + (*str - 'a' + 10);
  1397. X    else if (*str >= 'A' && *str <= 'F')
  1398. X      ret = ret * 16 + (*str - 'A' + 10);
  1399. X    else
  1400. X      break;
  1401. X  }
  1402. X  
  1403. X  return ret;
  1404. X}
  1405. X
  1406. X/*
  1407. X * a call to the alloc routines has been made, check the debug variables
  1408. X * returns [NO]ERROR.
  1409. X */
  1410. XLOCAL    int    check_debug_vars(const char * file, const int line)
  1411. X{
  1412. X  static int    iterc = 0;
  1413. X  
  1414. X  if (in_alloc) {
  1415. X    malloc_errno = MALLOC_IN_TWICE;
  1416. X    _malloc_perror("check_debug_vars");
  1417. X    /* malloc_perror may die already */
  1418. X    _malloc_die();
  1419. X    /*NOTREACHED*/
  1420. X  }
  1421. X  
  1422. X  in_alloc = TRUE;
  1423. X  
  1424. X  if (! malloc_enabled)
  1425. X    if (malloc_startup() != NOERROR)
  1426. X      return ERROR;
  1427. X  
  1428. X  /* check start file/line specifications */
  1429. X  if (! BIT_IS_SET(_malloc_debug, DEBUG_CHECK_HEAP)
  1430. X      && start_file[0] != NULLC
  1431. X      && file != NULL
  1432. X      && strcmp(start_file, file) == 0
  1433. X      && (line == 0 || line == start_line))
  1434. X    BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
  1435. X  
  1436. X  /* start checking heap after X times */
  1437. X  if (start_count != -1 && --start_count == 0)
  1438. X    BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
  1439. X  
  1440. X  /* checking heap every X times */
  1441. X  if (check_interval != -1) {
  1442. X    if (++iterc >= check_interval) {
  1443. X      BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
  1444. X      iterc = 0;
  1445. X    }
  1446. X    else
  1447. X      BIT_CLEAR(_malloc_debug, DEBUG_CHECK_HEAP);
  1448. X  }
  1449. X  
  1450. X  /* after all that, do we need to check the heap? */
  1451. X  if (BIT_IS_SET(_malloc_debug, DEBUG_CHECK_HEAP))
  1452. X    (void)_chunk_heap_check();
  1453. X  
  1454. X  return NOERROR;
  1455. X}
  1456. X
  1457. X/*
  1458. X * check out a pointer to see if we were looking for it.
  1459. X * may not return.
  1460. X */
  1461. XLOCAL    void    check_var(const char * file, const int line, char * pnt)
  1462. X{
  1463. X  static int    addc = 0;
  1464. X  
  1465. X  if (malloc_address == NULL || pnt != malloc_address)
  1466. X    return;
  1467. X  
  1468. X  if (++addc < address_count)
  1469. X    return;
  1470. X  
  1471. X  if (BIT_IS_SET(_malloc_debug, DEBUG_LOG_BAD_POINTER))
  1472. X    _malloc_message("found address '%#lx' after %d pass%s from '%s:%u'",
  1473. X            pnt, addc, (addc == 1 ? "" : "es"), file, line);
  1474. X  malloc_errno = MALLOC_POINTER_FOUND;
  1475. X  _malloc_perror("check_var");
  1476. X}
  1477. X
  1478. X/*
  1479. X * get the values of malloc environ variables
  1480. X */
  1481. XLOCAL    void    get_environ(void)
  1482. X{
  1483. X  char        *env;
  1484. X  
  1485. X  /* get the malloc_debug value */
  1486. X  env = (char *)getenv(DEBUG_ENVIRON);
  1487. X  if (env != NULL)
  1488. X    _malloc_debug = hex_to_int(env);
  1489. X  
  1490. X  /* get the malloc debug logfile name into a holding variable */
  1491. X  env = (char *)getenv(LOGFILE_ENVIRON);
  1492. X  if (env != NULL) {
  1493. X    (void)strcpy(log_path, env);
  1494. X    malloc_logpath = log_path;
  1495. X  }
  1496. X  
  1497. X  /* watch for a specific address and die when we get it */
  1498. X  env = (char *)getenv(ADDRESS_ENVIRON);
  1499. X  if (env != NULL) {
  1500. X    char    *addp;
  1501. X    
  1502. X    addp = index(env, ':');
  1503. X    if (addp != NULL) {
  1504. X      *addp = NULLC;
  1505. X      address_count = atoi(addp + 1);
  1506. X    }
  1507. X    else
  1508. X      address_count = 1;
  1509. X    
  1510. X    malloc_address = (char *)hex_to_int(env);
  1511. X  }
  1512. X  
  1513. X  /* check the heap every X times */
  1514. X  env = (char *)getenv(INTERVAL_ENVIRON);
  1515. X  if (env != NULL)
  1516. X    check_interval = atoi(env);
  1517. X  
  1518. X  /*
  1519. X   * start checking the heap after X iterations OR
  1520. X   * start at a file:line combination
  1521. X   */
  1522. X  env = (char *)getenv(START_ENVIRON);
  1523. X  if (env != NULL) {
  1524. X    char    *startp;
  1525. X    
  1526. X    BIT_CLEAR(_malloc_debug, DEBUG_CHECK_HEAP);
  1527. X    
  1528. X    startp = index(env, ':');
  1529. X    if (startp != NULL) {
  1530. X      *startp = NULLC;
  1531. X      (void)strcpy(start_file, env);
  1532. X      start_line = atoi(startp + 1);
  1533. X      start_count = 0;
  1534. X    }
  1535. X    else
  1536. X      start_count = atoi(env);
  1537. X  }
  1538. X}
  1539. X
  1540. X/*************************** startup/shutdown calls **************************/
  1541. X
  1542. X/*
  1543. X * startup the memory-allocation module
  1544. X */
  1545. XLOCAL    int    malloc_startup(void)
  1546. X{
  1547. X  /* have we started already? */
  1548. X  if (malloc_enabled)
  1549. X    return ERROR;
  1550. X  
  1551. X  /* set this here so if an error occurs below, it will not try again */
  1552. X  malloc_enabled = TRUE;
  1553. X  
  1554. X  /* get the environmental variables */
  1555. X  get_environ();
  1556. X  
  1557. X  /* startup heap code */
  1558. X  _heap_startup();
  1559. X  
  1560. X  /* startup the chunk lower-level code */
  1561. X  if (_chunk_startup() == ERROR)
  1562. X    return ERROR;
  1563. X  
  1564. X  return NOERROR;
  1565. X}
  1566. X
  1567. X/*
  1568. X * shutdown memory-allocation module, provide statistics if necessary
  1569. X */
  1570. XEXPORT    void    malloc_shutdown(void)
  1571. X{
  1572. X  /* NOTE: do not test for IN_TWICE here */
  1573. X  
  1574. X  /* do we need to check the heap? */
  1575. X  if (BIT_IS_SET(_malloc_debug, DEBUG_CHECK_HEAP))
  1576. X    (void)_chunk_heap_check();
  1577. X  
  1578. X  /* dump some statistics to the logfile */
  1579. X  if (BIT_IS_SET(_malloc_debug, DEBUG_LOG_STATS))
  1580. X    _chunk_list_count();
  1581. X  if (BIT_IS_SET(_malloc_debug, DEBUG_LOG_STATS))
  1582. X    _chunk_stats();
  1583. X  
  1584. X  /* report on non-freed pointers */
  1585. X  if (BIT_IS_SET(_malloc_debug, DEBUG_LOG_NONFREE))
  1586. X    _chunk_dump_not_freed();
  1587. X  
  1588. X  /* NOTE: do not set malloc_enabled to false here */
  1589. X}
  1590. X
  1591. X/******************************** memory calls *******************************/
  1592. X
  1593. X/*
  1594. X * allocate and return a SIZE block of bytes
  1595. X */
  1596. XEXPORT    char    *malloc(unsigned int size)
  1597. X{
  1598. X  char        *newp;
  1599. X  
  1600. X  if (check_debug_vars(_malloc_file, _malloc_line) != NOERROR)
  1601. X    return MALLOC_ERROR;
  1602. X  
  1603. X  newp = (char *)_chunk_malloc(_malloc_file, _malloc_line, size);
  1604. X  check_var(_malloc_file, _malloc_line, newp);
  1605. X  
  1606. X  in_alloc = FALSE;
  1607. X  
  1608. X  return newp;
  1609. X}
  1610. X
  1611. X/*
  1612. X * allocate and return a block of bytes able to hold NUM_ELEMENTS of elements
  1613. X * of SIZE bytes and zero the block
  1614. X */
  1615. XEXPORT    char    *calloc(unsigned int num_elements, unsigned int size)
  1616. X{
  1617. X  char        *newp;
  1618. X  unsigned int    len = num_elements * size;
  1619. X  
  1620. X  if (check_debug_vars(_malloc_file, _malloc_line) != NOERROR)
  1621. X    return CALLOC_ERROR;
  1622. X  
  1623. X  /* needs to be done here */
  1624. X  _calloc_count++;
  1625. X  
  1626. X  /* alloc and watch for the die address */
  1627. X  newp = (char *)_chunk_malloc(_malloc_file, _malloc_line, len);
  1628. X  check_var(_malloc_file, _malloc_line, newp);
  1629. X  
  1630. X  (void)memset(newp, NULLC, len);
  1631. X  
  1632. X  in_alloc = FALSE;
  1633. X  
  1634. X  return newp;
  1635. X}
  1636. X
  1637. X/*
  1638. X * resizes OLD_PNT to SIZE bytes and return the new space after either copying
  1639. X * all of OLD_PNT to the new area or truncating
  1640. X */
  1641. XEXPORT    char    *realloc(char * old_pnt, unsigned int new_size)
  1642. X{
  1643. X  char        *newp;
  1644. X  
  1645. X#if ALLOW_REALLOC_NULL
  1646. X  if (old_pnt == NULL)
  1647. X    return malloc(new_size);
  1648. X#endif
  1649. X  
  1650. X  if (check_debug_vars(_malloc_file, _malloc_line) != NOERROR)
  1651. X    return REALLOC_ERROR;
  1652. X  
  1653. X  check_var(_malloc_file, _malloc_line, old_pnt);
  1654. X  newp = (char *)_chunk_realloc(_malloc_file, _malloc_line, old_pnt, new_size);
  1655. X  check_var(_malloc_file, _malloc_line, newp);
  1656. X  
  1657. X  in_alloc = FALSE;
  1658. X  
  1659. X  return newp;
  1660. X}
  1661. X
  1662. X/*
  1663. X * release PNT in the heap, returning FREE_[NO]ERROR
  1664. X */
  1665. XEXPORT    int    free(char * pnt)
  1666. X{
  1667. X  int        ret;
  1668. X  
  1669. X  if (check_debug_vars(_malloc_file, _malloc_line) != NOERROR)
  1670. X    return FREE_ERROR;
  1671. X  
  1672. X  check_var(_malloc_file, _malloc_line, pnt);
  1673. X  ret = _chunk_free(_malloc_file, _malloc_line, pnt);
  1674. X  
  1675. X  in_alloc = FALSE;
  1676. X  
  1677. X  return ret;
  1678. X}
  1679. X
  1680. X/******************************** utility calls ******************************/
  1681. X
  1682. X/*
  1683. X * call through to _heap_map function, returns [NO]ERROR
  1684. X */
  1685. XEXPORT    int    malloc_heap_map(void)
  1686. X{
  1687. X  if (check_debug_vars(NULL, 0) != NOERROR)
  1688. X    return ERROR;
  1689. X  
  1690. X  _chunk_log_heap_map();
  1691. X  
  1692. X  in_alloc = FALSE;
  1693. X  
  1694. X  return NOERROR;
  1695. X}
  1696. X
  1697. X/*
  1698. X * verify pointer PNT, if PNT is 0 then check the entire heap.
  1699. X * returns MALLOC_VERIFY_[NO]ERROR
  1700. X */
  1701. XEXPORT    int    malloc_verify(char * pnt)
  1702. X{
  1703. X  int    ret;
  1704. X  
  1705. X  if (check_debug_vars(NULL, 0) != NOERROR)
  1706. X    return MALLOC_VERIFY_ERROR;
  1707. X  
  1708. X  if (pnt != 0)
  1709. X    ret = _chunk_pnt_check("malloc_verify", pnt, 0, 0);
  1710. X  else
  1711. X    ret = _chunk_heap_check();
  1712. X  
  1713. X  in_alloc = FALSE;
  1714. X  
  1715. X  if (ret == NOERROR)
  1716. X    return MALLOC_VERIFY_NOERROR;
  1717. X  else
  1718. X    return MALLOC_VERIFY_ERROR;
  1719. X}
  1720. X
  1721. X/*
  1722. X * set the global debug functionality flags to DEBUG (0 to disable).
  1723. X * returns [NO]ERROR
  1724. X */
  1725. XEXPORT    int    malloc_debug(int debug)
  1726. X{
  1727. X  int    hold;
  1728. X  
  1729. X  if (check_debug_vars(NULL, 0) != NOERROR)
  1730. X    return MALLOC_ERROR;
  1731. X  
  1732. X  /* make sure that the not-changeable flags' values are preserved */
  1733. X  hold = _malloc_debug & DEBUG_NOT_CHANGEABLE;
  1734. X  debug &= ~DEBUG_NOT_CHANGEABLE;
  1735. X  _malloc_debug = debug | hold;
  1736. X  
  1737. X  in_alloc = FALSE;
  1738. X  
  1739. X  return NOERROR;
  1740. X}
  1741. X
  1742. X/*
  1743. X * examine pointer PNT and returns SIZE, and FILE / LINE info on it
  1744. X * if any of the pointers are not NULL.
  1745. X * returns NOERROR or ERROR depending on whether PNT is good or not
  1746. X */
  1747. XEXPORT    int    malloc_examine(char * pnt, unsigned int * size,
  1748. X                   char ** file, unsigned int * line)
  1749. X{
  1750. X  int        ret;
  1751. X  
  1752. X  if (check_debug_vars(NULL, 0) != NOERROR)
  1753. X    return ERROR;
  1754. X  
  1755. X  ret = _chunk_read_info(pnt, size, file, line);
  1756. X  
  1757. X  in_alloc = FALSE;
  1758. X  
  1759. X  if (ret == NOERROR)
  1760. X    return NOERROR;
  1761. X  else
  1762. X    return ERROR;
  1763. X}
  1764. X
  1765. X/*
  1766. X * malloc version of strerror to return the string version of ERRNUM
  1767. X * returns the string for MALLOC_BAD_ERRNO if ERRNUM is out-of-range.
  1768. X */
  1769. XEXPORT    char    *malloc_strerror(int errnum)
  1770. X{
  1771. X  /*
  1772. X   * NOTE: should not check_debug_vars here because _malloc_perror calls this.
  1773. X   */
  1774. X  
  1775. X  if (! IS_MALLOC_ERRNO(errnum))
  1776. X    return malloc_errlist[MALLOC_BAD_ERRNO];
  1777. X  else
  1778. X    return malloc_errlist[errnum];
  1779. X}
  1780. END_OF_FILE
  1781. if test 11732 -ne `wc -c <'malloc.c'`; then
  1782.     echo shar: \"'malloc.c'\" unpacked with wrong size!
  1783. fi
  1784. # end of 'malloc.c'
  1785. fi
  1786. echo shar: End of archive 1 \(of 5\).
  1787. cp /dev/null ark1isdone
  1788. MISSING=""
  1789. for I in 1 2 3 4 5 ; do
  1790.     if test ! -f ark${I}isdone ; then
  1791.     MISSING="${MISSING} ${I}"
  1792.     fi
  1793. done
  1794. if test "${MISSING}" = "" ; then
  1795.     echo You have unpacked all 5 archives.
  1796.     echo "Do a 'sh ./configure' to configure the library"
  1797.     rm -f ark[1-9]isdone
  1798. else
  1799.     echo You still need to unpack the following archives:
  1800.     echo "        " ${MISSING}
  1801. fi
  1802. ##  End of shell archive.
  1803. exit 0
  1804.