home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-04-05 | 67.0 KB | 1,804 lines |
- Newsgroups: comp.sources.unix
- From: gray@antaire.com (Gray Watson)
- Subject: v26i098: malloc - debugging version of malloc, V1.2.0, Part01/05
- Sender: unix-sources-moderator@vix.com
- Approved: paul@vix.com
-
- Submitted-By: gray@antaire.com (Gray Watson)
- Posting-Number: Volume 26, Issue 98
- Archive-Name: malloc-1.2.0/part01
-
- Malloc Debug Library
- ********************
-
- This file documents the general-usage and the inner-workings of the
- memory allocation or "malloc" library it accompanies.
-
- This malloc library has been designed as a drop in replacement for
- the system's malloc, realloc, calloc, free and other memory management
- routines. For more information about their capabilities, do a `man 3
- malloc' to read the system's manual pages.
-
- What is unique about this library is that it contains a number of
- powerful debugging facilities including very comprehensive heap testing
- and excellent run-time debugging information. We have found these
- capabilities to be superb development tools.
-
- I can be reached at `<gray.watson@antaire.com>' with any questions
- or general comments.
-
- Gray Watson, Antaire Corporation.
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 5)."
- # Contents: COPYING-LIB ChangeLog Makefile.in Manifest NOTES README
- # TTD malloc.c
- # Wrapped by gray@toaster.antaire.com on Tue Apr 6 01:24:05 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'COPYING-LIB' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'COPYING-LIB'\"
- else
- echo shar: Extracting \"'COPYING-LIB'\" \(25265 characters\)
- sed "s/^X//" >'COPYING-LIB' <<'END_OF_FILE'
- X GNU LIBRARY GENERAL PUBLIC LICENSE
- X Version 2, June 1991
- X
- X Copyright (C) 1991 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X[This is the first released version of the library GPL. It is
- X numbered 2 because it goes with version 2 of the ordinary GPL.]
- X
- X Preamble
- X
- X The licenses for most software are designed to take away your
- Xfreedom to share and change it. By contrast, the GNU General Public
- XLicenses are intended to guarantee your freedom to share and change
- Xfree software--to make sure the software is free for all its users.
- X
- X This license, the Library General Public License, applies to some
- Xspecially designated Free Software Foundation software, and to any
- Xother libraries whose authors decide to use it. You can use it for
- Xyour libraries, too.
- X
- X When we speak of free software, we are referring to freedom, not
- Xprice. Our General Public Licenses are designed to make sure that you
- Xhave the freedom to distribute copies of free software (and charge for
- Xthis service if you wish), that you receive source code or can get it
- Xif you want it, that you can change the software or use pieces of it
- Xin new free programs; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- Xanyone to deny you these rights or to ask you to surrender the rights.
- XThese restrictions translate to certain responsibilities for you if
- Xyou distribute copies of the library, or if you modify it.
- X
- X For example, if you distribute copies of the library, whether gratis
- Xor for a fee, you must give the recipients all the rights that we gave
- Xyou. You must make sure that they, too, receive or can get the source
- Xcode. If you link a program with the library, you must provide
- Xcomplete object files to the recipients so that they can relink them
- Xwith the library, after making changes to the library and recompiling
- Xit. And you must show them these terms so they know their rights.
- X
- X Our method of protecting your rights has two steps: (1) copyright
- Xthe library, and (2) offer you this license which gives you legal
- Xpermission to copy, distribute and/or modify the library.
- X
- X Also, for each distributor's protection, we want to make certain
- Xthat everyone understands that there is no warranty for this free
- Xlibrary. If the library is modified by someone else and passed on, we
- Xwant its recipients to know that what they have is not the original
- Xversion, so that any problems introduced by others will not reflect on
- Xthe original authors' reputations.
- X
- X Finally, any free program is threatened constantly by software
- Xpatents. We wish to avoid the danger that companies distributing free
- Xsoftware will individually obtain patent licenses, thus in effect
- Xtransforming the program into proprietary software. To prevent this,
- Xwe have made it clear that any patent must be licensed for everyone's
- Xfree use or not licensed at all.
- X
- X Most GNU software, including some libraries, is covered by the ordinary
- XGNU General Public License, which was designed for utility programs. This
- Xlicense, the GNU Library General Public License, applies to certain
- Xdesignated libraries. This license is quite different from the ordinary
- Xone; be sure to read it in full, and don't assume that anything in it is
- Xthe same as in the ordinary license.
- X
- X The reason we have a separate public license for some libraries is that
- Xthey blur the distinction we usually make between modifying or adding to a
- Xprogram and simply using it. Linking a program with a library, without
- Xchanging the library, is in some sense simply using the library, and is
- Xanalogous to running a utility program or application program. However, in
- Xa textual and legal sense, the linked executable is a combined work, a
- Xderivative of the original library, and the ordinary General Public License
- Xtreats it as such.
- X
- X Because of this blurred distinction, using the ordinary General
- XPublic License for libraries did not effectively promote software
- Xsharing, because most developers did not use the libraries. We
- Xconcluded that weaker conditions might promote sharing better.
- X
- X However, unrestricted linking of non-free programs would deprive the
- Xusers of those programs of all benefit from the free status of the
- Xlibraries themselves. This Library General Public License is intended to
- Xpermit developers of non-free programs to use free libraries, while
- Xpreserving your freedom as a user of such programs to change the free
- Xlibraries that are incorporated in them. (We have not seen how to achieve
- Xthis as regards changes in header files, but we have achieved it as regards
- Xchanges in the actual functions of the Library.) The hope is that this
- Xwill lead to faster development of free libraries.
- X
- X The precise terms and conditions for copying, distribution and
- Xmodification follow. Pay close attention to the difference between a
- X"work based on the library" and a "work that uses the library". The
- Xformer contains code derived from the library, while the latter only
- Xworks together with the library.
- X
- X Note that it is possible for a library to be covered by the ordinary
- XGeneral Public License rather than by this special one.
- X
- X GNU LIBRARY GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 0. This License Agreement applies to any software library which
- Xcontains a notice placed by the copyright holder or other authorized
- Xparty saying it may be distributed under the terms of this Library
- XGeneral Public License (also called "this License"). Each licensee is
- Xaddressed as "you".
- X
- X A "library" means a collection of software functions and/or data
- Xprepared so as to be conveniently linked with application programs
- X(which use some of those functions and data) to form executables.
- X
- X The "Library", below, refers to any such software library or work
- Xwhich has been distributed under these terms. A "work based on the
- XLibrary" means either the Library or any derivative work under
- Xcopyright law: that is to say, a work containing the Library or a
- Xportion of it, either verbatim or with modifications and/or translated
- Xstraightforwardly into another language. (Hereinafter, translation is
- Xincluded without limitation in the term "modification".)
- X
- X "Source code" for a work means the preferred form of the work for
- Xmaking modifications to it. For a library, complete source code means
- Xall the source code for all modules it contains, plus any associated
- Xinterface definition files, plus the scripts used to control compilation
- Xand installation of the library.
- X
- X Activities other than copying, distribution and modification are not
- Xcovered by this License; they are outside its scope. The act of
- Xrunning a program using the Library is not restricted, and output from
- Xsuch a program is covered only if its contents constitute a work based
- Xon the Library (independent of the use of the Library in a tool for
- Xwriting it). Whether that is true depends on what the Library does
- Xand what the program that uses the Library does.
- X
- X 1. You may copy and distribute verbatim copies of the Library's
- Xcomplete source code as you receive it, in any medium, provided that
- Xyou conspicuously and appropriately publish on each copy an
- Xappropriate copyright notice and disclaimer of warranty; keep intact
- Xall the notices that refer to this License and to the absence of any
- Xwarranty; and distribute a copy of this License along with the
- XLibrary.
- X
- X You may charge a fee for the physical act of transferring a copy,
- Xand you may at your option offer warranty protection in exchange for a
- Xfee.
- X
- X 2. You may modify your copy or copies of the Library or any portion
- Xof it, thus forming a work based on the Library, and copy and
- Xdistribute such modifications or work under the terms of Section 1
- Xabove, provided that you also meet all of these conditions:
- X
- X a) The modified work must itself be a software library.
- X
- X b) You must cause the files modified to carry prominent notices
- X stating that you changed the files and the date of any change.
- X
- X c) You must cause the whole of the work to be licensed at no
- X charge to all third parties under the terms of this License.
- X
- X d) If a facility in the modified Library refers to a function or a
- X table of data to be supplied by an application program that uses
- X the facility, other than as an argument passed when the facility
- X is invoked, then you must make a good faith effort to ensure that,
- X in the event an application does not supply such function or
- X table, the facility still operates, and performs whatever part of
- X its purpose remains meaningful.
- X
- X (For example, a function in a library to compute square roots has
- X a purpose that is entirely well-defined independent of the
- X application. Therefore, Subsection 2d requires that any
- X application-supplied function or table used by this function must
- X be optional: if the application does not supply it, the square
- X root function must still compute square roots.)
- X
- XThese requirements apply to the modified work as a whole. If
- Xidentifiable sections of that work are not derived from the Library,
- Xand can be reasonably considered independent and separate works in
- Xthemselves, then this License, and its terms, do not apply to those
- Xsections when you distribute them as separate works. But when you
- Xdistribute the same sections as part of a whole which is a work based
- Xon the Library, the distribution of the whole must be on the terms of
- Xthis License, whose permissions for other licensees extend to the
- Xentire whole, and thus to each and every part regardless of who wrote
- Xit.
- X
- XThus, it is not the intent of this section to claim rights or contest
- Xyour rights to work written entirely by you; rather, the intent is to
- Xexercise the right to control the distribution of derivative or
- Xcollective works based on the Library.
- X
- XIn addition, mere aggregation of another work not based on the Library
- Xwith the Library (or with a work based on the Library) on a volume of
- Xa storage or distribution medium does not bring the other work under
- Xthe scope of this License.
- X
- X 3. You may opt to apply the terms of the ordinary GNU General Public
- XLicense instead of this License to a given copy of the Library. To do
- Xthis, you must alter all the notices that refer to this License, so
- Xthat they refer to the ordinary GNU General Public License, version 2,
- Xinstead of to this License. (If a newer version than version 2 of the
- Xordinary GNU General Public License has appeared, then you can specify
- Xthat version instead if you wish.) Do not make any other change in
- Xthese notices.
- X
- X Once this change is made in a given copy, it is irreversible for
- Xthat copy, so the ordinary GNU General Public License applies to all
- Xsubsequent copies and derivative works made from that copy.
- X
- X This option is useful when you wish to copy part of the code of
- Xthe Library into a program that is not a library.
- X
- X 4. You may copy and distribute the Library (or a portion or
- Xderivative of it, under Section 2) in object code or executable form
- Xunder the terms of Sections 1 and 2 above provided that you accompany
- Xit with the complete corresponding machine-readable source code, which
- Xmust be distributed under the terms of Sections 1 and 2 above on a
- Xmedium customarily used for software interchange.
- X
- X If distribution of object code is made by offering access to copy
- Xfrom a designated place, then offering equivalent access to copy the
- Xsource code from the same place satisfies the requirement to
- Xdistribute the source code, even though third parties are not
- Xcompelled to copy the source along with the object code.
- X
- X 5. A program that contains no derivative of any portion of the
- XLibrary, but is designed to work with the Library by being compiled or
- Xlinked with it, is called a "work that uses the Library". Such a
- Xwork, in isolation, is not a derivative work of the Library, and
- Xtherefore falls outside the scope of this License.
- X
- X However, linking a "work that uses the Library" with the Library
- Xcreates an executable that is a derivative of the Library (because it
- Xcontains portions of the Library), rather than a "work that uses the
- Xlibrary". The executable is therefore covered by this License.
- XSection 6 states terms for distribution of such executables.
- X
- X When a "work that uses the Library" uses material from a header file
- Xthat is part of the Library, the object code for the work may be a
- Xderivative work of the Library even though the source code is not.
- XWhether this is true is especially significant if the work can be
- Xlinked without the Library, or if the work is itself a library. The
- Xthreshold for this to be true is not precisely defined by law.
- X
- X If such an object file uses only numerical parameters, data
- Xstructure layouts and accessors, and small macros and small inline
- Xfunctions (ten lines or less in length), then the use of the object
- Xfile is unrestricted, regardless of whether it is legally a derivative
- Xwork. (Executables containing this object code plus portions of the
- XLibrary will still fall under Section 6.)
- X
- X Otherwise, if the work is a derivative of the Library, you may
- Xdistribute the object code for the work under the terms of Section 6.
- XAny executables containing that work also fall under Section 6,
- Xwhether or not they are linked directly with the Library itself.
- X
- X 6. As an exception to the Sections above, you may also compile or
- Xlink a "work that uses the Library" with the Library to produce a
- Xwork containing portions of the Library, and distribute that work
- Xunder terms of your choice, provided that the terms permit
- Xmodification of the work for the customer's own use and reverse
- Xengineering for debugging such modifications.
- X
- X You must give prominent notice with each copy of the work that the
- XLibrary is used in it and that the Library and its use are covered by
- Xthis License. You must supply a copy of this License. If the work
- Xduring execution displays copyright notices, you must include the
- Xcopyright notice for the Library among them, as well as a reference
- Xdirecting the user to the copy of this License. Also, you must do one
- Xof these things:
- X
- X a) Accompany the work with the complete corresponding
- X machine-readable source code for the Library including whatever
- X changes were used in the work (which must be distributed under
- X Sections 1 and 2 above); and, if the work is an executable linked
- X with the Library, with the complete machine-readable "work that
- X uses the Library", as object code and/or source code, so that the
- X user can modify the Library and then relink to produce a modified
- X executable containing the modified Library. (It is understood
- X that the user who changes the contents of definitions files in the
- X Library will not necessarily be able to recompile the application
- X to use the modified definitions.)
- X
- X b) Accompany the work with a written offer, valid for at
- X least three years, to give the same user the materials
- X specified in Subsection 6a, above, for a charge no more
- X than the cost of performing this distribution.
- X
- X c) If distribution of the work is made by offering access to copy
- X from a designated place, offer equivalent access to copy the above
- X specified materials from the same place.
- X
- X d) Verify that the user has already received a copy of these
- X materials or that you have already sent this user a copy.
- X
- X For an executable, the required form of the "work that uses the
- XLibrary" must include any data and utility programs needed for
- Xreproducing the executable from it. However, as a special exception,
- Xthe source code distributed need not include anything that is normally
- Xdistributed (in either source or binary form) with the major
- Xcomponents (compiler, kernel, and so on) of the operating system on
- Xwhich the executable runs, unless that component itself accompanies
- Xthe executable.
- X
- X It may happen that this requirement contradicts the license
- Xrestrictions of other proprietary libraries that do not normally
- Xaccompany the operating system. Such a contradiction means you cannot
- Xuse both them and the Library together in an executable that you
- Xdistribute.
- X
- X 7. You may place library facilities that are a work based on the
- XLibrary side-by-side in a single library together with other library
- Xfacilities not covered by this License, and distribute such a combined
- Xlibrary, provided that the separate distribution of the work based on
- Xthe Library and of the other library facilities is otherwise
- Xpermitted, and provided that you do these two things:
- X
- X a) Accompany the combined library with a copy of the same work
- X based on the Library, uncombined with any other library
- X facilities. This must be distributed under the terms of the
- X Sections above.
- X
- X b) Give prominent notice with the combined library of the fact
- X that part of it is a work based on the Library, and explaining
- X where to find the accompanying uncombined form of the same work.
- X
- X 8. You may not copy, modify, sublicense, link with, or distribute
- Xthe Library except as expressly provided under this License. Any
- Xattempt otherwise to copy, modify, sublicense, link with, or
- Xdistribute the Library is void, and will automatically terminate your
- Xrights under this License. However, parties who have received copies,
- Xor rights, from you under this License will not have their licenses
- Xterminated so long as such parties remain in full compliance.
- X
- X 9. You are not required to accept this License, since you have not
- Xsigned it. However, nothing else grants you permission to modify or
- Xdistribute the Library or its derivative works. These actions are
- Xprohibited by law if you do not accept this License. Therefore, by
- Xmodifying or distributing the Library (or any work based on the
- XLibrary), you indicate your acceptance of this License to do so, and
- Xall its terms and conditions for copying, distributing or modifying
- Xthe Library or works based on it.
- X
- X 10. Each time you redistribute the Library (or any work based on the
- XLibrary), the recipient automatically receives a license from the
- Xoriginal licensor to copy, distribute, link with or modify the Library
- Xsubject to these terms and conditions. You may not impose any further
- Xrestrictions on the recipients' exercise of the rights granted herein.
- XYou are not responsible for enforcing compliance by third parties to
- Xthis License.
- X
- X 11. If, as a consequence of a court judgment or allegation of patent
- Xinfringement or for any other reason (not limited to patent issues),
- Xconditions are imposed on you (whether by court order, agreement or
- Xotherwise) that contradict the conditions of this License, they do not
- Xexcuse you from the conditions of this License. If you cannot
- Xdistribute so as to satisfy simultaneously your obligations under this
- XLicense and any other pertinent obligations, then as a consequence you
- Xmay not distribute the Library at all. For example, if a patent
- Xlicense would not permit royalty-free redistribution of the Library by
- Xall those who receive copies directly or indirectly through you, then
- Xthe only way you could satisfy both it and this License would be to
- Xrefrain entirely from distribution of the Library.
- X
- XIf any portion of this section is held invalid or unenforceable under any
- Xparticular circumstance, the balance of the section is intended to apply,
- Xand the section as a whole is intended to apply in other circumstances.
- X
- XIt is not the purpose of this section to induce you to infringe any
- Xpatents or other property right claims or to contest validity of any
- Xsuch claims; this section has the sole purpose of protecting the
- Xintegrity of the free software distribution system which is
- Ximplemented by public license practices. Many people have made
- Xgenerous contributions to the wide range of software distributed
- Xthrough that system in reliance on consistent application of that
- Xsystem; it is up to the author/donor to decide if he or she is willing
- Xto distribute software through any other system and a licensee cannot
- Ximpose that choice.
- X
- XThis section is intended to make thoroughly clear what is believed to
- Xbe a consequence of the rest of this License.
- X
- X 12. If the distribution and/or use of the Library is restricted in
- Xcertain countries either by patents or by copyrighted interfaces, the
- Xoriginal copyright holder who places the Library under this License may add
- Xan explicit geographical distribution limitation excluding those countries,
- Xso that distribution is permitted only in or among countries not thus
- Xexcluded. In such case, this License incorporates the limitation as if
- Xwritten in the body of this License.
- X
- X 13. The Free Software Foundation may publish revised and/or new
- Xversions of the Library General Public License from time to time.
- XSuch new versions will be similar in spirit to the present version,
- Xbut may differ in detail to address new problems or concerns.
- X
- XEach version is given a distinguishing version number. If the Library
- Xspecifies a version number of this License which applies to it and
- X"any later version", you have the option of following the terms and
- Xconditions either of that version or of any later version published by
- Xthe Free Software Foundation. If the Library does not specify a
- Xlicense version number, you may choose any version ever published by
- Xthe Free Software Foundation.
- X
- X 14. If you wish to incorporate parts of the Library into other free
- Xprograms whose distribution conditions are incompatible with these,
- Xwrite to the author to ask for permission. For software which is
- Xcopyrighted by the Free Software Foundation, write to the Free
- XSoftware Foundation; we sometimes make exceptions for this. Our
- Xdecision will be guided by the two goals of preserving the free status
- Xof all derivatives of our free software and of promoting the sharing
- Xand reuse of software generally.
- X
- X NO WARRANTY
- X
- X 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
- XWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
- XEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
- XOTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
- XKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
- XIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- XPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
- XLIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
- XTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
- X
- X 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
- XWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
- XAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
- XFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
- XCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
- XLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
- XRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
- XFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
- XSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- XDAMAGES.
- X
- X END OF TERMS AND CONDITIONS
- X
- X Appendix: How to Apply These Terms to Your New Libraries
- X
- X If you develop a new library, and you want it to be of the greatest
- Xpossible use to the public, we recommend making it free software that
- Xeveryone can redistribute and change. You can do so by permitting
- Xredistribution under these terms (or, alternatively, under the terms of the
- Xordinary General Public License).
- X
- X To apply these terms, attach the following notices to the library. It is
- Xsafest to attach them to the start of each source file to most effectively
- Xconvey the exclusion of warranty; and each file should have at least the
- X"copyright" line and a pointer to where the full notice is found.
- X
- X <one line to give the library's name and a brief idea of what it does.>
- X Copyright (C) <year> <name of author>
- X
- X This library is free software; you can redistribute it and/or
- X modify it under the terms of the GNU Library General Public
- X License as published by the Free Software Foundation; either
- X version 2 of the License, or (at your option) any later version.
- X
- X This library is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- X Library General Public License for more details.
- X
- X You should have received a copy of the GNU Library General Public
- X License along with this library; if not, write to the Free
- X Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- XAlso add information on how to contact you by electronic and paper mail.
- X
- XYou should also get your employer (if you work as a programmer) or your
- Xschool, if any, to sign a "copyright disclaimer" for the library, if
- Xnecessary. Here is a sample; alter the names:
- X
- X Yoyodyne, Inc., hereby disclaims all copyright interest in the
- X library `Frob' (a library for tweaking knobs) written by James Random Hacker.
- X
- X <signature of Ty Coon>, 1 April 1990
- X Ty Coon, President of Vice
- X
- XThat's all there is to it!
- END_OF_FILE
- if test 25265 -ne `wc -c <'COPYING-LIB'`; then
- echo shar: \"'COPYING-LIB'\" unpacked with wrong size!
- fi
- # end of 'COPYING-LIB'
- fi
- if test -f 'ChangeLog' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ChangeLog'\"
- else
- echo shar: Extracting \"'ChangeLog'\" \(8607 characters\)
- sed "s/^X//" >'ChangeLog' <<'END_OF_FILE'
- XTue Apr 6 00:46:45 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Upgraded to version 1.2.0. Ready for 2nd release to
- X comp.sources.unix. Lots of work on the manual.
- X
- XMon Apr 5 18:28:05 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Finished adding token "check-funcs" to check the arguments of
- X some common string functions to see whether they are in the heap.
- X if so it tries to verify that the pointers are good.
- X
- XSun Apr 4 21:24:45 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Added token "log-unknown" to dump non-free unknown pointers as
- X well as known ones. Also cleaned up the displaying of the
- X pointers.
- X
- X * comp.sources.unix is almost ready to post so lots of last minute
- X cleanups in the manual, etc.
- X
- X * Started integration of function argument checking.
- X
- XTue Mar 30 19:36:27 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Changed malloc.h defines so malloc routines are handled as well
- X as the ALLOC macros.
- X
- X * malloc_dbg program now reports on the token NAME and values.
- X
- X * Added initial string files for string support in the future.
- X
- X * A number of minor changes: fixed gcc compilation problems per
- X scott's help, combined malloc_lp.h into malloc.h, cleaned most .h
- X and .c files.
- X
- XFri Mar 26 04:00:14 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Fixed post 1.1.6 problem with chunk.c. Boy do I need some
- X automated testing tools. Discovered the illusive localtime
- X fence-post error. Had a hard time tracking it down. Maybe due to
- X the fact that the checks were not being made on dblock fence posts
- X before?
- X
- X * Upgraded to 1.1.6
- X
- X * Found some problems with malloc debug codes. Use of DB_FENCE
- X and CHECK_LISTS and some others were improper. A MALLOC_DEBUG
- X value of 0x403000 would crash all malloc programs. :-)
- X
- X * Added some better comments to all files and cleaned up most
- X files too.
- X
- XFri Mar 12 18:35:02 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Upgraded to 1.1.5.
- X
- XSat Feb 13 17:25:43 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Finished add a number of const operators to improve coding per
- X scott's recommendations.
- X
- XSat Jan 30 12:33:43 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Took out the check_vars call inside of malloc_strerror since
- X _malloc_perror calls malloc_strerror which would go quickly
- X recursive. Thanks scott.
- X
- X * Changed to version 1.1.4
- X
- XTue Jan 5 00:00:00 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Sent off 1.1.3 shar files to comp.sources.unix.
- X
- XSat Jan 2 00:16:58 1993 Gray Watson (gray at toaster.antaire.com)
- X
- X * Made last minute changes to solve some gcc/ansi errors and
- X to the manual to get things ready for the post.
- X
- XSun Dec 27 20:28:19 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Fixed problem with some external functions in malloc.c not
- X reseting the in_alloc flag. Also removed some testing of unsigned
- X variables < 0 in chunk.c per gcc 2.3.3 warnings.
- X
- X * Changed version to 1.1.3.
- X
- XMon Dec 21 15:31:50 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Created the series of shar files in preparation to posting to
- X comp.unix.sources. Looking good.
- X
- XThu Dec 17 18:33:38 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Renamed a number of files to comply with the Sys5 12 character
- X restrictions (14 - 2 for RCS/CVS/SCCS). Yeach. malloc_debug ->
- X malloc_dbg.
- X
- XSat Nov 14 15:59:53 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Added all external functions to configure and conf.h even though
- X the library assumes that some functions will be resolved. Also
- X upgraded the version number to 1.01gamma (oooooh).
- X
- X * Added print-perror debug token for logging messages to STDERR as
- X well as log-files. Removed stdio from the malloc library to make
- X sure it does not go recursive (alloc for stderr) at a bad time.
- X
- XWed Nov 11 18:19:49 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Moved the heap_check calls from chunk.c over to malloc so we can
- X be guaranteed that it gets called only once per user call.
- X chunk's routines often cross-call each other meaning that
- X heap-check was being run 5 times be realloc. YEACH!!
- X
- XTue Nov 10 17:55:53 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Added two new debug-tokens: log-blocks and heap-check-map. Also
- X made sure that heap_check was being called from everywhere.
- X Updated the manual and corresponding files.
- X
- X * Added library functions that may not be defined. Updated the
- X conf.h.in and configure.in files to improve confiurability.
- X Upgraded the manual which still needs a lot of work (sigh).
- X
- XMon Nov 9 19:21:25 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Added configure, configure.in, conf.h.in, and Makefile.in to try
- X and conform with autoconf specs. What a bear. The documentation
- X for autoconf needs a whole bunch more examples, etc. Sigh.
- X Removed all the MEMORY and STRING defines, etc.
- X
- XThu Nov 5 22:13:18 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Released version 1.01b. Sending it off to some folks.
- X
- X * Lots and lots of changes. Translated all programs into non-ansi
- X C dependance and then went back again when I found some problems
- X with my macros. :-) Took out all (and I mean all) Antaire
- X dependancies and defines.
- X
- XThu Oct 22 00:47:18 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Ran through most of the debug-flag functionality testing and
- X tweaking. Found some bugs on dblock handling and some messed up
- X logic with the way the LOG flags were working.
- X
- X * malloc_debug is looking good. It now outputs C or Bourne shell
- X code and seems to work in both environments. What do sh folks use
- X in the place of c-shell aliasing? I guess use bash. :-)
- X
- XWed Oct 21 03:27:35 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Major changes. I sort of went overboard tonight. I integrated
- X the new malloc_debug program which sets all the debug variables
- X for you. I also added a .mallocrc which you can define with tags
- X exactly the functionality you want to happen. No more levels!!
- X
- X * Did some renaming of files, cleaned up some other things,
- X had to rework a number of items to get new debug flags working.
- X
- XTue Oct 20 18:06:36 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Removed useful.h requirements and integrated necessary
- X definitions into malloc.h.
- X
- X * Transfered malloc.txt documentation into malloc.texinfo. Boy
- X is it nifty!! And damn easy!!!
- X
- X * Major changes to improve general machine independance. Added
- X malloc_mach.h. Moved alloc.[ch] to malloc.[ch] for sanity
- X reasons.
- X
- XTue Oct 13 16:14:17 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Made various cosmetic changes. Fixed realloc inbound pointer
- X checking per MALLOC_ADDRESS. Fixed problem with MALLOC_ADDRESS
- X initialization to NULL causing free to "find" NULL pointers. :-)
- X
- X * Separated the PERROR debug level and the KILL_SELF level. Now
- X (by default) all memory errors are logged at level 1 and above and
- X malloc kills itself at level 2 and above.
- X
- XMon Sep 28 23:24:36 1992 Gray Watson (gray at toaster.antaire.com)
- X
- X * Added MALLOC_ADDRESS support for free. MALLOC_ADDRESS counts
- X now also apply to frees also.
- X
- XMon Sep 21 20:39:38 1992 Gray Watson (gray at toaster)
- X
- X * Fixed some size problems with bounds checking enabled.
- X
- X * Made free be able to report who freed a pointer. I don't know
- X why this wasn't caught before. free wasn't even using its
- X file/line arguments.
- X
- XThu Sep 3 03:23:39 1992 Gray Watson (gray at toaster)
- X
- X * Added ability to realloc a NULL pointer with an ifdef to
- X disable. Useful in realloc loops where the first time you don't
- X have to alloc it.
- X
- XFri Aug 14 15:54:03 1992 Gray Watson (gray at toaster)
- X
- X * Added a bunch of new environmental variables features:
- X MALLOC_ADDRESS now can have a :# argument. MALLOC_START now has
- X two formats, the old number and new file:line. Looks nice!
- X
- X * Made a pass through chunk.c and fixed a number of problems where
- X debug output pnt/size did not match user-supplied information.
- X
- X * Moved most of the debug variables into alloc.c from chunk.c and
- X added a standardizied check_debug_vars() checking routine.
- X
- XTue Jul 21 16:06:13 1992 Gray Watson (gray at toaster)
- X
- X * Fixed malloc count statistics. Removed duplicate malloc_count
- X varaibale from a number of places.
- X
- XMon Mar 23 10:49:25 1992 Gray Watson (gray at toaster)
- X
- X * Released version 0.04 with new env variable features.
- X
- XThu Mar 12 19:28:34 1992 Gray Watson (gray at toaster)
- X
- X * Fixed a large problem with chunk.c not reporting the correct
- X memory address when listing unfreed memory. This was discovered
- X when MALLOC_ADDRESS was not working correctly.
- END_OF_FILE
- if test 8607 -ne `wc -c <'ChangeLog'`; then
- echo shar: \"'ChangeLog'\" unpacked with wrong size!
- fi
- # end of 'ChangeLog'
- fi
- if test -f 'Makefile.in' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Makefile.in'\"
- else
- echo shar: Extracting \"'Makefile.in'\" \(2972 characters\)
- sed "s/^X//" >'Makefile.in' <<'END_OF_FILE'
- X###############################################################################
- X# Makefile for the Malloc library.
- X# $Id: Makefile.all.in,v 1.11 1993/04/06 05:23:08 gray Exp $
- X###############################################################################
- X
- X# default root installation directory
- Xprefix = /usr/local
- X
- Xsrcdir = @srcdir@
- Xbindir = $(prefix)/bin
- Xlibdir = $(prefix)/lib
- Xincdir = $(prefix)/inc
- Xinfodir = $(prefix)/info
- X
- X# default c-compiler
- XCC = @CC@
- X
- XDEFS =
- XINCS = -I$(srcdir)
- XLIBS = @LIBS@ -L$(srcdir) -lmalloc
- X
- XLIBRARY = libmalloc.a
- XUTIL = malloc_dbg
- XINFOFILE = malloc.info
- X
- XCCFLAGS = -g
- XLDFLAGS = -g
- X
- XINSTALL = @INSTALL@
- XINSTALL_PROGRAM = @INSTALL_PROGRAM@
- XINSTALL_DATA = @INSTALL_DATA@
- X
- X###############################################################################
- X# End of system configuration section.
- X###############################################################################
- X
- XSHELL = /bin/sh
- X
- XHFLS = malloc.h
- XOBJS = chunk.o compat.o error.o heap.o malloc.o malloc_lp.o malloc_str.o
- X
- XCFLAGS = $(CCFLAGS)
- XTESTS = malloc_t
- X
- X# .PHONY : all
- Xall : $(LIBRARY) $(UTIL)
- X
- X# .PHONY : clean
- Xclean :
- X rm -f a.out core *.o *.t
- X
- X# .PHONY : clobber
- Xclobber : clean
- X rm -f $(LIBRARY) $(TESTS) $(UTIL)
- X
- X# .PHONY : realclean
- Xrealclean : clobber
- X
- X# .PHONY : distclean
- Xdistclean : clobber
- X rm -f Makefile conf.h config.status
- X# rm -f configure
- X
- X# .PHONY : install
- Xinstall : $(HFLS) $(UTIL) $(LIBRARY) $(INFOFILES)
- X $(INSTALL_DATA) $(HFLS) $(incdir)
- X $(INSTALL_PROGRAM) $(UTIL) $(bindir)
- X $(INSTALL_DATA) $(LIBRARY) $(libdir)
- X @RANLIB@ $(libdir)/$(LIBRARY)
- X# $(INSTALL_DATA) $(INFOFILES) $(infodir)
- X
- X$(LIBRARY) : $(OBJS)
- X ar cr $(LIBRARY) $?
- X @RANLIB@ $@
- X - chmod 660 $@
- X
- X$(UTIL) : malloc_dbg.o $(LIBRARY)
- X rm -f $@
- X $(CC) $(LDFLAGS) $@.o $(LIBS)
- X mv a.out $@
- X
- X# .PHONY : tests
- Xtests : $(TESTS)
- X
- Xmalloc_t : malloc_t.o $(LIBRARY)
- X rm -f $@
- X $(CC) $(LDFLAGS) malloc_t.o $(LIBS)
- X mv a.out $@
- X
- X.c.o :
- X rm -f $@
- X $(CC) $(CFLAGS) $(CPPFLAGS) $(DEFS) $(INCS) -c $< -o $@
- X
- X.texi.info :
- X makeinfo $<
- X
- X###############################################################################
- X#
- X# These dependencies are automatically generated. Do not edit by hand.
- X#
- X
- Xchunk.o : chunk.c malloc.h malloc_loc.h chunk.h chunk_loc.h compat.h conf.h \
- X dbg_values.h error.h error_val.h heap.h version.h
- Xcompat.o : compat.c malloc.h malloc_loc.h compat.h conf.h
- Xerror.o : error.c malloc.h malloc_loc.h chunk.h compat.h conf.h dbg_values.h \
- X error.h
- Xheap.o : heap.c malloc.h malloc_loc.h chunk.h compat.h conf.h error.h error_val.h \
- X heap.h
- Xmalloc.o : malloc.c malloc.h malloc_loc.h chunk.h compat.h conf.h dbg_values.h \
- X error.h error_str.h error_val.h heap.h malloc_lp.h
- Xmalloc_dbg.o : malloc_dbg.c malloc.h malloc_loc.h compat.h conf.h dbg_tokens.h \
- X dbg_values.h version.h
- Xmalloc_lp.o : malloc_lp.c malloc.h
- Xmalloc_str.o : malloc_str.c malloc.h malloc_loc.h conf.h chunk.h dbg_values.h \
- X error.h malloc_str.h
- Xmalloc_t.o : malloc_t.c malloc.h
- Xsample.o : sample.c malloc.h
- END_OF_FILE
- if test 2972 -ne `wc -c <'Makefile.in'`; then
- echo shar: \"'Makefile.in'\" unpacked with wrong size!
- fi
- # end of 'Makefile.in'
- fi
- if test -f 'Manifest' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Manifest'\"
- else
- echo shar: Extracting \"'Manifest'\" \(2583 characters\)
- sed "s/^X//" >'Manifest' <<'END_OF_FILE'
- X-------------------------------------------------------------------------------
- X$Id: Manifest,v 1.13 1993/04/05 01:28:47 gray Exp $
- X-------------------------------------------------------------------------------
- XDescription of the files in the malloc package.
- X
- XCOPYING-LIB The famous GNU Library Public License.
- X
- XChangelog Change log entries detailing major module
- X changes.
- X
- XMakefile.in Used by configure to create the Makefile.
- X
- XManifest This file.
- X
- XNOTES General Notes of the malloc routines and
- X associated algorithms.
- X
- XREADME Quick startup notes.
- X
- XTTD Things To Do list. It only gets longer and
- X longer.
- X
- Xchunk.[ch] Lower level allocation routines. This is the
- X meat of the allocation algorithms. Manages
- X and debugs the administration structures of
- X the heap. Too large!
- X
- Xchunk_loc.h Local defines specific to the chunk routines
- X only.
- X
- Xcompat.[ch] System compatibility routines if missing
- X functionality.
- X
- Xconf.h.in Used by configure to create the conf.h
- X configurations.
- X
- Xconfigure Configure script.
- X
- Xconfigure.in Used by autoconf to create the configure
- X script.
- X
- Xdbg_tokens.h Tokens that correspond to debugging
- X functionality.
- X
- Xdbg_values.h Values corresponding to the debug tokens.
- X
- Xerror.[ch] Debugging routines and others that provide
- X user output.
- X
- Xerror_str.h Strings that correspond to malloc error codes.
- X
- Xerror_val.h General error codes for the malloc module.
- X
- Xheap.[ch] Possibly machine specific routines for
- X allocating space on and manipulating the heap.
- X
- Xmalloc.[ch] Higher level alloc routines including malloc,
- X free, realloc, etc. These are the routines to
- X be called from user space.
- X
- Xmalloc.info User-level gnu info manual file for the malloc
- X routines. Suitable as a text manual also.
- X
- Xmalloc.texi Texinfo user manual for generating TeX or Info
- X formats. This is not distributed normally to
- X conserve space. Let me know if you want a
- X copy.
- X
- Xmalloc_dbg.c Program that assists in the setting of the
- X MALLOC_DEBUG and other debug environmental
- X variables.
- X
- Xmalloc_loc.h Local defines for all of the malloc routines.
- X
- Xmalloc_lp.[ch] Leap-frog routines to provide file/line info
- X to lib.
- X
- Xmalloc_str.[ch] Malloc string routines for string testing.
- X
- Xmalloc_t.c Meager test program for testing the malloc
- X routines.
- X
- Xmallocrc Sample RC file that is used to set the debug
- X flags.
- X
- Xsample.c A sample file to demonstrate the usage of the
- X library.
- X
- Xversion.h Version number for the library.
- X
- X-------------------------------------------------------------------------------
- END_OF_FILE
- if test 2583 -ne `wc -c <'Manifest'`; then
- echo shar: \"'Manifest'\" unpacked with wrong size!
- fi
- # end of 'Manifest'
- fi
- if test -f 'NOTES' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'NOTES'\"
- else
- echo shar: Extracting \"'NOTES'\" \(4169 characters\)
- sed "s/^X//" >'NOTES' <<'END_OF_FILE'
- X-------------------------------------------------------------------------------
- X$Id: NOTES,v 1.13 1993/04/06 04:24:29 gray Exp $
- X-------------------------------------------------------------------------------
- X
- XWARNINGS:
- X
- X- do not be surprised if the library catches problems with your
- X system's library routines. It took me 6 hours once to finally
- X come to the conclusion that the localtime call, included in
- X SunOS release 4.1 (and maybe before/after), was overwriting
- X one of its fence-post markers.
- X
- X-------------------------------------------------------------------------------
- X
- XGENERAL:
- X
- X- dumping core on errors and then continuing did not look to be a problem to
- X implement. However it became "not recommended" as soon as it was
- X discovered that fork (which is needed) calls malloc itself. If the
- X heap was corrupted or some other critical error has occurred then the
- X library would quickly go recursive.
- X
- X- administration blocks are relocatable:
- X - any administration blocks are relocatable in the heap which means
- X that if we monitor the freeing of a block we have the
- X opportunity to swap a higher admin block down which would mean
- X we could possible locate as many admin blocks as possible in
- X low memory making more contiguous usable areas
- X
- X - you have the freed blocks address
- X
- X - as you go through the admin blocks, until you get to the right entry,
- X save a pointer to the highest (or lowest) one
- X
- X - when you find the free block, find out if it is lower (or higher)
- X than the highest admin block and bcopy the admin block down and
- X redo the pointers
- X
- X-------------------------------------------------------------------------------
- X
- XCODING WARNINGS:
- X
- X- watch for heaps growing up or down (all subtraction or other position
- X dependent code must be changed to macros in heap.h) >,<,-,+,etc
- X- watch for bounds checking assuming + or - code.
- X
- X-------------------------------------------------------------------------------
- X
- XCHUNK INFORMATION:
- X
- X- it is assumed that none of the __FILE__ arguments are on the heap because
- X to determine whether a dblock is free or not it looks at the next
- X argument (unioned with the file argument) and sees if it is null or
- X in the heap meaning it is at the end or middle of a free list.
- X
- X
- X-------------------------------------------------------------------------------
- X
- XDBLOCK METHOD:
- X
- X- have the bblock admin struct point to the dblock admin structure block which
- X contains a number of dblock admin entries.
- X- have a global pointer that points to last free dblock admin structure entry
- X and has a count of the number left in the block
- X- only allocate contiguous dblock admin slots so have some fragmentation
- X - must have contiguous because bblocks do not have pointer to start of
- X array
- X- maybe have a sorted free list of the number of free dblock admin structs.
- X sorted in descending order
- X- you have the free pointer which gets you to the bblock where you can see if
- X it is a dblock and if it is on the correct boundary. Then you go to
- X the dblock admin struct to get the file, line, size info.
- X- the bblock tells you of the number of bits in the chunk, etc.
- X- have some way to run through the dblock admin slot blocks to verify that
- X crc's have not been overwritten.
- X
- X-------------------------------------------------------------------------------
- X
- XNEW ALGORITHMS:
- X
- X- maybe have some sort of bitmask for free space/used space like BSD disk
- X blocks
- X- look in your free_list for first block.
- X - if NULL then move up a bin and try to divide
- X - continue until up X blocks then sbrk a new smaller block
- X- maybe try a finite number of free_bins above the one you want to limit
- X fragmentation, test this thing
- X
- X-------------------------------------------------------------------------------
- X
- XOVERHEAD:
- X
- X- dblock: 8 bytes per pointer
- X- bblock: 12 bytes per pointer
- X
- X-------------------------------------------------------------------------------
- X
- XTHANKS:
- X
- XSpecial thanks to Scott Michel <scottm@intime.intime.COM> for
- Xlistening to my endless chatter and finding/solvings lots of stupid
- Xproblems during the alpha stages of this library.
- X
- X-------------------------------------------------------------------------------
- END_OF_FILE
- if test 4169 -ne `wc -c <'NOTES'`; then
- echo shar: \"'NOTES'\" unpacked with wrong size!
- fi
- # end of 'NOTES'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(1648 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- X-------------------------------------------------------------------------------
- X$Id: README,v 1.14 1993/04/01 04:59:15 gray Exp $
- X-------------------------------------------------------------------------------
- X
- XINSTALLATION:
- X
- X1) Run 'sh ./configure' to configure the library and generate the
- X Makefile and conf.h. Examine conf.h (especially) as well as
- X Makefile to make sure configure set things up correctly.
- X
- X2) Typing 'make' should be enough to build libmalloc.a and
- X malloc_dbg program.
- X
- X3) Typing 'make test' should build the malloc_t test program
- X
- X-------------------------------------------------------------------------------
- X
- XDOCUMENTATION:
- X
- XExamine the malloc.info file. Is is a gnu-info file having the
- Xuser-documentation for the malloc subsystem. It can be installed in
- Xthe emacs info directory and read with emacs/info or the info program
- Xavailable at GNU archive sites. It is also suitable for reading as
- Xtext.
- X
- XIt can be reproduced from the malloc.texi texinfo file which also can
- Xgenerate TeX hardcopy output. You may need the new texinfo.tex from
- Xthe gnu archive sites.
- X
- X-------------------------------------------------------------------------------
- X
- XNOTES:
- X
- X- the system is definitely dependent on a good ansi-c compiler like gcc.
- X- the file Manifest contains a list of each of the file and what it does.
- X- configure can be regenerated by the autoconf script.
- X- the file sample.c contains an example of some of the malloc macros and
- X functions.
- X
- XIf you have any problems with porting issues feel free to send me mail.
- Xgray.watson@antaire.com
- X
- X-------------------------------------------------------------------------------
- END_OF_FILE
- if test 1648 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f 'TTD' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'TTD'\"
- else
- echo shar: Extracting \"'TTD'\" \(5069 characters\)
- sed "s/^X//" >'TTD' <<'END_OF_FILE'
- X-------------------------------------------------------------------------------
- X$Id: TTD,v 1.19 1993/04/05 01:28:49 gray Exp $
- X-------------------------------------------------------------------------------
- X
- XIMPORTANT:
- X
- X- add special-blocks with a sorted-free list
- X - over X bits then it becomes special
- X - if in free special and someone matches then drop the rest of
- X the allocation into a free list maybe, maybe-not
- X- be able to break up bigger blocks of memory into small ones
- X - have a split(x) which asks for x+1 bits and then splits it into
- X 2 blocks of x bits
- X - split then might go recursive
- X - maybe have a level X and only jump up a maximum of X bits to find
- X free space (depending on how much you want to fragment)
- X- change the large block allocation process:
- X - needs to be a lot cleaner and produce a denser heap
- X
- X-------------------------------------------------------------------------------
- X
- XCHECKING:
- X
- X- check in heap_check the cleared space above each allocation instead of
- X only the fence posts
- X- maybe write the address % 256 into bytes instead of a constant
- X - maybe it would slow it down.
- X - a token/option?
- X - \305 is recognizable however
- X- another token to have the library never reclaim memory, always extend the
- X heap (i.e. don't use free lists at all)
- X - this would grow into an enormous heap however.
- X- maybe add another debug level which stores crc information about internal
- X heap structures and verifies it during run time. slow, slow!!
- X
- X-------------------------------------------------------------------------------
- X
- XSTRING SUPPORT:
- X
- X- have special macros for string allocation for string functions. possibly
- X uppercase or normal overrides.
- X- maybe build in most string functions (strcat, strcpy, etc)
- X- have a checking level/value that runs though the strings and makes sure
- X they have a NULL in them.
- X- this may not be too important in the face of the bounds checking stuff but
- X it may report errors more intelligently
- X- need to think if more support for strings would be a good thing
- X- it would be able to locate common errors with strings a lot closer to the
- X actual problem.
- X- inform the user to include the string stuff at the end of include list
- X
- X-------------------------------------------------------------------------------
- X
- XGENERAL:
- X
- X- for fence underflow, print out the allocation below and for fence overflow
- X the allocation above if possible
- X- maybe expand_string dump the first X bytes of an allocation per a token
- X- add __builtin_return_value support for higher gcc versions (2.2.0+)
- X- have either a bunch of free or used bblocks be:
- X - start block and then a set of continuation blocks
- X - this would mean we do not have to hit each bblock entry to redo
- X the type flag
- X- handle memalign, valloc, maybe some form of mallopt
- X- maybe use getpagesize (mach_dep.c) to determine BASIC block size
- X- handle 0 length allocations correctly if the #define is set
- X - i.e. maybe give back a small section with bounds-checking touching
- X- manage dblock_admin entries better
- X - map out usage and get some stats
- X - add to normal db_free lists, zero out each of the entries. if they
- X are both zero or some magic X then we need to get more bblock
- X space for the dblocks.
- X- special case last bunch of bblocks:
- X - have a pointer to the last contiguous set
- X - have them not in a free list
- X - if used and reallocs then just extend it
- X - if free and need some of it then extend (or not) and give
- X - maybe not worth it for 1 pointer
- X- maybe make malloc_dbg use no stdio so no unwanted memory allocations.
- X- turn realloc into an intelligent beasty that looks on either side
- X of existing chunk (if expanding) for free space and manages free-lists
- X appropriately
- X
- X-------------------------------------------------------------------------------
- X
- XTESTING / STATISTICS:
- X
- X- need to write a set of fully automated test programs
- X - maybe start with a test shell like malloc_t but stripped and then
- X run a script through it and analyse the output
- X - should be a killer that does a million hits
- X- test define for allowing 0 length defines
- X- test define for realloc(NULL)
- X- check out situation where sbrk calls return ERROR (from the beginning and
- X in the middle). the library should return NULL's straight off and
- X log appropriate errors.
- X- add free-list statistics whenever it gets more memory to see the viability of
- X dividing larger free entries in two
- X- add statistics whenever it frees memory to see the viability of combining
- X adjacent blocks
- X- maybe a program that would try a standard set of tests on a number of
- X different combinations of debug-values to look for dependancies.
- X
- X-------------------------------------------------------------------------------
- X
- XRMS comments:
- X - integrate into gnu-malloc
- X - change the bit-flags into the functionality strings themselves
- X - get rid of the malloc_dbg program and the mallocrc file (too "hairy")
- X - integrate __builtin_return_address functionality from gcc
- X gdb command 'info line *ADDRESS' to get file/line
- X
- X-------------------------------------------------------------------------------
- END_OF_FILE
- if test 5069 -ne `wc -c <'TTD'`; then
- echo shar: \"'TTD'\" unpacked with wrong size!
- fi
- # end of 'TTD'
- fi
- if test -f 'malloc.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'malloc.c'\"
- else
- echo shar: Extracting \"'malloc.c'\" \(11732 characters\)
- sed "s/^X//" >'malloc.c' <<'END_OF_FILE'
- X/*
- X * user-level memory-allocation routines
- X *
- X * Copyright 1992 by Gray Watson and the Antaire Corporation
- X *
- X * This file is part of the malloc-debug package.
- X *
- X * This library is free software; you can redistribute it and/or
- X * modify it under the terms of the GNU Library General Public
- X * License as published by the Free Software Foundation; either
- X * version 2 of the License, or (at your option) any later version.
- X *
- X * This library is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- X * Library General Public License for more details.
- X *
- X * You should have received a copy of the GNU Library General Public
- X * License along with this library (see COPYING-LIB); if not, write to the
- X * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X *
- X * The author of the program may be contacted at gray.watson@antaire.com
- X */
- X
- X/*
- X * This file contains the user-level calls to the memory allocation
- X * routines. It handles a lot of the miscellaneous support garbage for
- X * chunk.c which is the real heap manager.
- X */
- X
- X#define MALLOC_DEBUG_DISABLE
- X
- X#include "malloc.h"
- X#include "malloc_loc.h"
- X
- X#include "chunk.h"
- X#include "compat.h"
- X#include "conf.h"
- X#include "dbg_values.h"
- X#include "error.h"
- X#include "error_str.h"
- X#include "error_val.h"
- X#include "heap.h"
- X#include "malloc_lp.h"
- X
- X#if INCLUDE_RCS_IDS
- XLOCAL char *rcs_id =
- X "$Id: malloc.c,v 1.22 1993/04/05 22:30:13 gray Exp $";
- X#endif
- X
- X/*
- X * exported variables
- X */
- X/* logfile for dumping malloc info, MALLOC_LOGFILE env. var overrides this */
- XEXPORT char *malloc_logpath = NULL;
- X/* internal malloc error number for reference purposes only */
- XEXPORT int malloc_errno = 0;
- X
- X/* local routines */
- XLOCAL int malloc_startup(void);
- XEXPORT void malloc_shutdown(void);
- X
- X/* local variables */
- XLOCAL int malloc_enabled = FALSE; /* have we started yet? */
- XLOCAL char in_alloc = FALSE; /* can't be here twice */
- XLOCAL char log_path[128] = { NULLC }; /* storage for env path */
- X
- X/* debug variables */
- XLOCAL char *malloc_address = NULL; /* address to catch */
- XLOCAL int address_count = 0; /* address argument */
- XLOCAL char start_file[128] = { NULLC }; /* file to start at */
- XLOCAL int start_line = 0; /* line in module to start */
- XLOCAL int start_count = -1; /* start after X */
- XLOCAL int check_interval = -1; /* check every X */
- X
- X/****************************** local utilities ******************************/
- X
- X/*
- X * hexadecimal STR to int translation
- X */
- XLOCAL int hex_to_int(char * str)
- X{
- X int ret;
- X
- X /* strip off spaces */
- X for (; *str == ' ' || *str == '\t'; str++);
- X
- X /* skip a leading 0[xX] */
- X if (*str == '0' && (*(str + 1) == 'x' || *(str + 1) == 'X'))
- X str += 2;
- X
- X for (ret = 0;; str++) {
- X if (*str >= '0' && *str <= '9')
- X ret = ret * 16 + (*str - '0');
- X else if (*str >= 'a' && *str <= 'f')
- X ret = ret * 16 + (*str - 'a' + 10);
- X else if (*str >= 'A' && *str <= 'F')
- X ret = ret * 16 + (*str - 'A' + 10);
- X else
- X break;
- X }
- X
- X return ret;
- X}
- X
- X/*
- X * a call to the alloc routines has been made, check the debug variables
- X * returns [NO]ERROR.
- X */
- XLOCAL int check_debug_vars(const char * file, const int line)
- X{
- X static int iterc = 0;
- X
- X if (in_alloc) {
- X malloc_errno = MALLOC_IN_TWICE;
- X _malloc_perror("check_debug_vars");
- X /* malloc_perror may die already */
- X _malloc_die();
- X /*NOTREACHED*/
- X }
- X
- X in_alloc = TRUE;
- X
- X if (! malloc_enabled)
- X if (malloc_startup() != NOERROR)
- X return ERROR;
- X
- X /* check start file/line specifications */
- X if (! BIT_IS_SET(_malloc_debug, DEBUG_CHECK_HEAP)
- X && start_file[0] != NULLC
- X && file != NULL
- X && strcmp(start_file, file) == 0
- X && (line == 0 || line == start_line))
- X BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
- X
- X /* start checking heap after X times */
- X if (start_count != -1 && --start_count == 0)
- X BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
- X
- X /* checking heap every X times */
- X if (check_interval != -1) {
- X if (++iterc >= check_interval) {
- X BIT_SET(_malloc_debug, DEBUG_CHECK_HEAP);
- X iterc = 0;
- X }
- X else
- X BIT_CLEAR(_malloc_debug, DEBUG_CHECK_HEAP);
- X }
- X
- X /* after all that, do we need to check the heap? */
- X if (BIT_IS_SET(_malloc_debug, DEBUG_CHECK_HEAP))
- X (void)_chunk_heap_check();
- X
- X return NOERROR;
- X}
- X
- X/*
- X * check out a pointer to see if we were looking for it.
- X * may not return.
- X */
- XLOCAL void check_var(const char * file, const int line, char * pnt)
- X{
- X static int addc = 0;
- X
- X if (malloc_address == NULL || pnt != malloc_address)
- X return;
- X
- X if (++addc < address_count)
- X return;
- X
- X if (BIT_IS_SET(_malloc_debug, DEBUG_LOG_BAD_POINTER))
- X _malloc_message("found address '%#lx' after %d pass%s from '%s:%u'",
- X pnt, addc, (addc == 1 ? "" : "es"), file, line);
- X malloc_errno = MALLOC_POINTER_FOUND;
- X _malloc_perror("check_var");
- X}
- X
- X/*
- X * get the values of malloc environ variables
- X */
- XLOCAL void get_environ(void)
- X{
- X char *env;
- X
- X /* get the malloc_debug value */
- X env = (char *)getenv(DEBUG_ENVIRON);
- X if (env != NULL)
- X _malloc_debug = hex_to_int(env);
- X
- X /* get the malloc debug logfile name into a holding variable */
- X env = (char *)getenv(LOGFILE_ENVIRON);
- X if (env != NULL) {
- X (void)strcpy(log_path, env);
- X malloc_logpath = log_path;
- X }
- X
- X /* watch for a specific address and die when we get it */
- X env = (char *)getenv(ADDRESS_ENVIRON);
- X if (env != NULL) {
- X char *addp;
- X
- X addp = index(env, ':');
- X if (addp != NULL) {
- X *addp = NULLC;
- X address_count = atoi(addp + 1);
- X }
- X else
- X address_count = 1;
- X
- X malloc_address = (char *)hex_to_int(env);
- X }
- X
- X /* check the heap every X times */
- X env = (char *)getenv(INTERVAL_ENVIRON);
- X if (env != NULL)
- X check_interval = atoi(env);
- X
- X /*
- X * start checking the heap after X iterations OR
- X * start at a file:line combination
- X */
- X env = (char *)getenv(START_ENVIRON);
- X if (env != NULL) {
- X char *startp;
- X
- X BIT_CLEAR(_malloc_debug, DEBUG_CHECK_HEAP);
- X
- X startp = index(env, ':');
- X if (startp != NULL) {
- X *startp = NULLC;
- X (void)strcpy(start_file, env);
- X start_line = atoi(startp + 1);
- X start_count = 0;
- X }
- X else
- X start_count = atoi(env);
- X }
- X}
- X
- X/*************************** startup/shutdown calls **************************/
- X
- X/*
- X * startup the memory-allocation module
- X */
- XLOCAL int malloc_startup(void)
- X{
- X /* have we started already? */
- X if (malloc_enabled)
- X return ERROR;
- X
- X /* set this here so if an error occurs below, it will not try again */
- X malloc_enabled = TRUE;
- X
- X /* get the environmental variables */
- X get_environ();
- X
- X /* startup heap code */
- X _heap_startup();
- X
- X /* startup the chunk lower-level code */
- X if (_chunk_startup() == ERROR)
- X return ERROR;
- X
- X return NOERROR;
- X}
- X
- X/*
- X * shutdown memory-allocation module, provide statistics if necessary
- X */
- XEXPORT void malloc_shutdown(void)
- X{
- X /* NOTE: do not test for IN_TWICE here */
- X
- X /* do we need to check the heap? */
- X if (BIT_IS_SET(_malloc_debug, DEBUG_CHECK_HEAP))
- X (void)_chunk_heap_check();
- X
- X /* dump some statistics to the logfile */
- X if (BIT_IS_SET(_malloc_debug, DEBUG_LOG_STATS))
- X _chunk_list_count();
- X if (BIT_IS_SET(_malloc_debug, DEBUG_LOG_STATS))
- X _chunk_stats();
- X
- X /* report on non-freed pointers */
- X if (BIT_IS_SET(_malloc_debug, DEBUG_LOG_NONFREE))
- X _chunk_dump_not_freed();
- X
- X /* NOTE: do not set malloc_enabled to false here */
- X}
- X
- X/******************************** memory calls *******************************/
- X
- X/*
- X * allocate and return a SIZE block of bytes
- X */
- XEXPORT char *malloc(unsigned int size)
- X{
- X char *newp;
- X
- X if (check_debug_vars(_malloc_file, _malloc_line) != NOERROR)
- X return MALLOC_ERROR;
- X
- X newp = (char *)_chunk_malloc(_malloc_file, _malloc_line, size);
- X check_var(_malloc_file, _malloc_line, newp);
- X
- X in_alloc = FALSE;
- X
- X return newp;
- X}
- X
- X/*
- X * allocate and return a block of bytes able to hold NUM_ELEMENTS of elements
- X * of SIZE bytes and zero the block
- X */
- XEXPORT char *calloc(unsigned int num_elements, unsigned int size)
- X{
- X char *newp;
- X unsigned int len = num_elements * size;
- X
- X if (check_debug_vars(_malloc_file, _malloc_line) != NOERROR)
- X return CALLOC_ERROR;
- X
- X /* needs to be done here */
- X _calloc_count++;
- X
- X /* alloc and watch for the die address */
- X newp = (char *)_chunk_malloc(_malloc_file, _malloc_line, len);
- X check_var(_malloc_file, _malloc_line, newp);
- X
- X (void)memset(newp, NULLC, len);
- X
- X in_alloc = FALSE;
- X
- X return newp;
- X}
- X
- X/*
- X * resizes OLD_PNT to SIZE bytes and return the new space after either copying
- X * all of OLD_PNT to the new area or truncating
- X */
- XEXPORT char *realloc(char * old_pnt, unsigned int new_size)
- X{
- X char *newp;
- X
- X#if ALLOW_REALLOC_NULL
- X if (old_pnt == NULL)
- X return malloc(new_size);
- X#endif
- X
- X if (check_debug_vars(_malloc_file, _malloc_line) != NOERROR)
- X return REALLOC_ERROR;
- X
- X check_var(_malloc_file, _malloc_line, old_pnt);
- X newp = (char *)_chunk_realloc(_malloc_file, _malloc_line, old_pnt, new_size);
- X check_var(_malloc_file, _malloc_line, newp);
- X
- X in_alloc = FALSE;
- X
- X return newp;
- X}
- X
- X/*
- X * release PNT in the heap, returning FREE_[NO]ERROR
- X */
- XEXPORT int free(char * pnt)
- X{
- X int ret;
- X
- X if (check_debug_vars(_malloc_file, _malloc_line) != NOERROR)
- X return FREE_ERROR;
- X
- X check_var(_malloc_file, _malloc_line, pnt);
- X ret = _chunk_free(_malloc_file, _malloc_line, pnt);
- X
- X in_alloc = FALSE;
- X
- X return ret;
- X}
- X
- X/******************************** utility calls ******************************/
- X
- X/*
- X * call through to _heap_map function, returns [NO]ERROR
- X */
- XEXPORT int malloc_heap_map(void)
- X{
- X if (check_debug_vars(NULL, 0) != NOERROR)
- X return ERROR;
- X
- X _chunk_log_heap_map();
- X
- X in_alloc = FALSE;
- X
- X return NOERROR;
- X}
- X
- X/*
- X * verify pointer PNT, if PNT is 0 then check the entire heap.
- X * returns MALLOC_VERIFY_[NO]ERROR
- X */
- XEXPORT int malloc_verify(char * pnt)
- X{
- X int ret;
- X
- X if (check_debug_vars(NULL, 0) != NOERROR)
- X return MALLOC_VERIFY_ERROR;
- X
- X if (pnt != 0)
- X ret = _chunk_pnt_check("malloc_verify", pnt, 0, 0);
- X else
- X ret = _chunk_heap_check();
- X
- X in_alloc = FALSE;
- X
- X if (ret == NOERROR)
- X return MALLOC_VERIFY_NOERROR;
- X else
- X return MALLOC_VERIFY_ERROR;
- X}
- X
- X/*
- X * set the global debug functionality flags to DEBUG (0 to disable).
- X * returns [NO]ERROR
- X */
- XEXPORT int malloc_debug(int debug)
- X{
- X int hold;
- X
- X if (check_debug_vars(NULL, 0) != NOERROR)
- X return MALLOC_ERROR;
- X
- X /* make sure that the not-changeable flags' values are preserved */
- X hold = _malloc_debug & DEBUG_NOT_CHANGEABLE;
- X debug &= ~DEBUG_NOT_CHANGEABLE;
- X _malloc_debug = debug | hold;
- X
- X in_alloc = FALSE;
- X
- X return NOERROR;
- X}
- X
- X/*
- X * examine pointer PNT and returns SIZE, and FILE / LINE info on it
- X * if any of the pointers are not NULL.
- X * returns NOERROR or ERROR depending on whether PNT is good or not
- X */
- XEXPORT int malloc_examine(char * pnt, unsigned int * size,
- X char ** file, unsigned int * line)
- X{
- X int ret;
- X
- X if (check_debug_vars(NULL, 0) != NOERROR)
- X return ERROR;
- X
- X ret = _chunk_read_info(pnt, size, file, line);
- X
- X in_alloc = FALSE;
- X
- X if (ret == NOERROR)
- X return NOERROR;
- X else
- X return ERROR;
- X}
- X
- X/*
- X * malloc version of strerror to return the string version of ERRNUM
- X * returns the string for MALLOC_BAD_ERRNO if ERRNUM is out-of-range.
- X */
- XEXPORT char *malloc_strerror(int errnum)
- X{
- X /*
- X * NOTE: should not check_debug_vars here because _malloc_perror calls this.
- X */
- X
- X if (! IS_MALLOC_ERRNO(errnum))
- X return malloc_errlist[MALLOC_BAD_ERRNO];
- X else
- X return malloc_errlist[errnum];
- X}
- END_OF_FILE
- if test 11732 -ne `wc -c <'malloc.c'`; then
- echo shar: \"'malloc.c'\" unpacked with wrong size!
- fi
- # end of 'malloc.c'
- fi
- echo shar: End of archive 1 \(of 5\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 4 5 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 5 archives.
- echo "Do a 'sh ./configure' to configure the library"
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-