home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume08 / memlin.tok < prev    next >
SHell self-extracting ARchive  |  1991-08-27  |  15.8 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: SHell self-extracting ARchive (archive/shar).

You can browse this item here: memlin.tok

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file ASCII text default
100% TrID E-Mail message (Var. 2) default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime application/mbox default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 20 64 65 63 | 77 72 6c 21 75 63 62 76 |From dec|wrl!ucbv|
|00000010| 61 78 21 74 75 74 2e 63 | 69 73 2e 6f 68 69 6f 2d |ax!tut.c|is.ohio-|
|00000020| 73 74 61 74 65 2e 65 64 | 75 21 67 65 6d 2e 6d 70 |state.ed|u!gem.mp|
|00000030| 73 2e 6f 68 69 6f 2d 73 | 74 61 74 65 2e 65 64 75 |s.ohio-s|tate.edu|
|00000040| 21 67 69 6e 6f 73 6b 6f | 21 75 75 6e 65 74 21 61 |!ginosko|!uunet!a|
|00000050| 6c 6c 62 65 72 79 20 4d | 6f 6e 20 41 75 67 20 32 |llbery M|on Aug 2|
|00000060| 38 20 31 39 3a 34 32 3a | 31 36 20 50 44 54 20 31 |8 19:42:|16 PDT 1|
|00000070| 39 38 39 0a 41 72 74 69 | 63 6c 65 20 31 30 36 33 |989.Arti|cle 1063|
|00000080| 20 6f 66 20 63 6f 6d 70 | 2e 73 6f 75 72 63 65 73 | of comp|.sources|
|00000090| 2e 6d 69 73 63 3a 0a 50 | 61 74 68 3a 20 64 65 63 |.misc:.P|ath: dec|
|000000a0| 77 72 6c 21 75 63 62 76 | 61 78 21 74 75 74 2e 63 |wrl!ucbv|ax!tut.c|
|000000b0| 69 73 2e 6f 68 69 6f 2d | 73 74 61 74 65 2e 65 64 |is.ohio-|state.ed|
|000000c0| 75 21 67 65 6d 2e 6d 70 | 73 2e 6f 68 69 6f 2d 73 |u!gem.mp|s.ohio-s|
|000000d0| 74 61 74 65 2e 65 64 75 | 21 67 69 6e 6f 73 6b 6f |tate.edu|!ginosko|
|000000e0| 21 75 75 6e 65 74 21 61 | 6c 6c 62 65 72 79 0a 46 |!uunet!a|llbery.F|
|000000f0| 72 6f 6d 3a 20 61 6c 6c | 62 65 72 79 40 75 75 6e |rom: all|bery@uun|
|00000100| 65 74 2e 55 55 2e 4e 45 | 54 20 28 42 72 61 6e 64 |et.UU.NE|T (Brand|
|00000110| 6f 6e 20 53 2e 20 41 6c | 6c 62 65 72 79 20 2d 20 |on S. Al|lbery - |
|00000120| 63 6f 6d 70 2e 73 6f 75 | 72 63 65 73 2e 6d 69 73 |comp.sou|rces.mis|
|00000130| 63 29 0a 4e 65 77 73 67 | 72 6f 75 70 73 3a 20 63 |c).Newsg|roups: c|
|00000140| 6f 6d 70 2e 73 6f 75 72 | 63 65 73 2e 6d 69 73 63 |omp.sour|ces.misc|
|00000150| 0a 53 75 62 6a 65 63 74 | 3a 20 76 30 38 69 30 32 |.Subject|: v08i02|
|00000160| 33 3a 20 6d 65 6d 6c 69 | 6e 74 6f 6b 3a 20 6d 61 |3: memli|ntok: ma|
|00000170| 63 72 6f 73 20 74 6f 20 | 61 76 6f 69 64 20 6c 69 |cros to |avoid li|
|00000180| 6e 74 20 63 6f 6d 70 6c | 61 69 6e 74 73 20 61 62 |nt compl|aints ab|
|00000190| 6f 75 74 20 6d 61 6c 6c | 6f 63 2f 66 72 65 65 0a |out mall|oc/free.|
|000001a0| 4d 65 73 73 61 67 65 2d | 49 44 3a 20 3c 36 35 36 |Message-|ID: <656|
|000001b0| 30 31 40 75 75 6e 65 74 | 2e 55 55 2e 4e 45 54 3e |01@uunet|.UU.NET>|
|000001c0| 0a 44 61 74 65 3a 20 32 | 39 20 41 75 67 20 38 39 |.Date: 2|9 Aug 89|
|000001d0| 20 30 30 3a 31 33 3a 35 | 36 20 47 4d 54 0a 53 65 | 00:13:5|6 GMT.Se|
|000001e0| 6e 64 65 72 3a 20 61 6c | 6c 62 65 72 79 40 75 75 |nder: al|lbery@uu|
|000001f0| 6e 65 74 2e 55 55 2e 4e | 45 54 0a 52 65 70 6c 79 |net.UU.N|ET.Reply|
|00000200| 2d 54 6f 3a 20 62 6f 62 | 6c 40 74 65 73 73 69 2e |-To: bob|l@tessi.|
|00000210| 55 55 43 50 0a 4f 72 67 | 61 6e 69 7a 61 74 69 6f |UUCP.Org|anizatio|
|00000220| 6e 3a 20 54 53 53 49 2c | 20 42 65 61 76 65 72 74 |n: TSSI,| Beavert|
|00000230| 6f 6e 2c 20 4f 72 65 67 | 6f 6e 0a 4c 69 6e 65 73 |on, Oreg|on.Lines|
|00000240| 3a 20 35 34 33 0a 41 70 | 70 72 6f 76 65 64 3a 20 |: 543.Ap|proved: |
|00000250| 61 6c 6c 62 65 72 79 40 | 75 75 6e 65 74 2e 55 55 |allbery@|uunet.UU|
|00000260| 2e 4e 45 54 20 28 42 72 | 61 6e 64 6f 6e 20 53 2e |.NET (Br|andon S.|
|00000270| 20 41 6c 6c 62 65 72 79 | 20 2d 20 63 6f 6d 70 2e | Allbery| - comp.|
|00000280| 73 6f 75 72 63 65 73 2e | 6d 69 73 63 29 0a 0a 50 |sources.|misc)..P|
|00000290| 6f 73 74 69 6e 67 2d 6e | 75 6d 62 65 72 3a 20 56 |osting-n|umber: V|
|000002a0| 6f 6c 75 6d 65 20 38 2c | 20 49 73 73 75 65 20 32 |olume 8,| Issue 2|
|000002b0| 33 0a 53 75 62 6d 69 74 | 74 65 64 2d 62 79 3a 20 |3.Submit|ted-by: |
|000002c0| 62 6f 62 6c 40 74 65 73 | 73 69 2e 55 55 43 50 0a |bobl@tes|si.UUCP.|
|000002d0| 41 72 63 68 69 76 65 2d | 6e 61 6d 65 3a 20 6d 65 |Archive-|name: me|
|000002e0| 6d 6c 69 6e 74 6f 6b 0a | 0a 48 65 72 65 20 69 73 |mlintok.|.Here is|
|000002f0| 20 61 20 70 61 63 6b 61 | 67 65 20 77 68 69 63 68 | a packa|ge which|
|00000300| 20 70 61 69 6e 6c 65 73 | 73 6c 79 20 67 65 74 73 | painles|sly gets|
|00000310| 20 61 72 6f 75 6e 64 20 | 6c 69 6e 74 20 63 6f 6d | around |lint com|
|00000320| 70 6c 61 69 6e 74 73 20 | 61 62 6f 75 74 0a 74 68 |plaints |about.th|
|00000330| 65 20 6d 65 6d 6f 72 79 | 20 61 6c 6c 6f 63 61 74 |e memory| allocat|
|00000340| 69 6f 6e 20 66 75 6e 63 | 74 69 6f 6e 73 2e 20 20 |ion func|tions. |
|00000350| 53 65 65 20 65 6e 63 6c | 6f 73 65 64 20 74 68 65 |See encl|osed the|
|00000360| 20 22 52 45 41 44 4d 45 | 22 20 66 69 6c 65 20 61 | "README|" file a|
|00000370| 6e 64 0a 6d 61 6e 20 70 | 61 67 65 20 66 6f 72 20 |nd.man p|age for |
|00000380| 6d 6f 72 65 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e |more inf|ormation|
|00000390| 2e 0a 0a 09 2d 20 42 6f | 62 20 4c 65 77 69 73 0a |....- Bo|b Lewis.|
|000003a0| 09 20 20 62 6f 62 6c 40 | 74 65 73 73 69 2e 75 75 |. bobl@|tessi.uu|
|000003b0| 63 70 0a 0a 23 21 20 2f | 62 69 6e 2f 73 68 0a 23 |cp..#! /|bin/sh.#|
|000003c0| 20 54 68 69 73 20 69 73 | 20 61 20 73 68 65 6c 6c | This is| a shell|
|000003d0| 20 61 72 63 68 69 76 65 | 2e 20 20 52 65 6d 6f 76 | archive|. Remov|
|000003e0| 65 20 61 6e 79 74 68 69 | 6e 67 20 62 65 66 6f 72 |e anythi|ng befor|
|000003f0| 65 20 74 68 69 73 20 6c | 69 6e 65 2c 20 74 68 65 |e this l|ine, the|
|00000400| 6e 20 75 6e 70 61 63 6b | 0a 23 20 69 74 20 62 79 |n unpack|.# it by|
|00000410| 20 73 61 76 69 6e 67 20 | 69 74 20 69 6e 74 6f 20 | saving |it into |
|00000420| 61 20 66 69 6c 65 20 61 | 6e 64 20 74 79 70 69 6e |a file a|nd typin|
|00000430| 67 20 22 73 68 20 66 69 | 6c 65 22 2e 20 20 54 6f |g "sh fi|le". To|
|00000440| 20 6f 76 65 72 77 72 69 | 74 65 20 65 78 69 73 74 | overwri|te exist|
|00000450| 69 6e 67 0a 23 20 66 69 | 6c 65 73 2c 20 74 79 70 |ing.# fi|les, typ|
|00000460| 65 20 22 73 68 20 66 69 | 6c 65 20 2d 63 22 2e 20 |e "sh fi|le -c". |
|00000470| 20 59 6f 75 20 63 61 6e | 20 61 6c 73 6f 20 66 65 | You can| also fe|
|00000480| 65 64 20 74 68 69 73 20 | 61 73 20 73 74 61 6e 64 |ed this |as stand|
|00000490| 61 72 64 20 69 6e 70 75 | 74 20 76 69 61 0a 23 20 |ard inpu|t via.# |
|000004a0| 75 6e 73 68 61 72 2c 20 | 6f 72 20 62 79 20 74 79 |unshar, |or by ty|
|000004b0| 70 69 6e 67 20 22 73 68 | 20 3c 66 69 6c 65 22 2c |ping "sh| <file",|
|000004c0| 20 65 2e 67 2e 2e 20 20 | 49 66 20 74 68 69 73 20 | e.g.. |If this |
|000004d0| 61 72 63 68 69 76 65 20 | 69 73 20 63 6f 6d 70 6c |archive |is compl|
|000004e0| 65 74 65 2c 20 79 6f 75 | 0a 23 20 77 69 6c 6c 20 |ete, you|.# will |
|000004f0| 73 65 65 20 74 68 65 20 | 66 6f 6c 6c 6f 77 69 6e |see the |followin|
|00000500| 67 20 6d 65 73 73 61 67 | 65 20 61 74 20 74 68 65 |g messag|e at the|
|00000510| 20 65 6e 64 3a 0a 23 09 | 09 22 45 6e 64 20 6f 66 | end:.#.|."End of|
|00000520| 20 73 68 65 6c 6c 20 61 | 72 63 68 69 76 65 2e 22 | shell a|rchive."|
|00000530| 0a 23 20 43 6f 6e 74 65 | 6e 74 73 3a 20 20 52 45 |.# Conte|nts: RE|
|00000540| 41 44 4d 45 20 4d 61 6b | 65 66 69 6c 65 20 67 6f |ADME Mak|efile go|
|00000550| 6f 64 20 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 33 20 6d |od memli|ntok.3 m|
|00000560| 65 6d 6c 69 6e 74 6f 6b | 2e 68 20 74 5f 6d 65 6d |emlintok|.h t_mem|
|00000570| 6c 69 6e 74 6f 6b 2e 63 | 0a 23 20 57 72 61 70 70 |lintok.c|.# Wrapp|
|00000580| 65 64 20 62 79 20 62 6f | 62 6c 40 67 68 69 64 72 |ed by bo|bl@ghidr|
|00000590| 61 68 20 6f 6e 20 4d 6f | 6e 20 41 75 67 20 32 38 |ah on Mo|n Aug 28|
|000005a0| 20 31 30 3a 34 39 3a 33 | 33 20 31 39 38 39 0a 50 | 10:49:3|3 1989.P|
|000005b0| 41 54 48 3d 2f 62 69 6e | 3a 2f 75 73 72 2f 62 69 |ATH=/bin|:/usr/bi|
|000005c0| 6e 3a 2f 75 73 72 2f 75 | 63 62 20 3b 20 65 78 70 |n:/usr/u|cb ; exp|
|000005d0| 6f 72 74 20 50 41 54 48 | 0a 69 66 20 74 65 73 74 |ort PATH|.if test|
|000005e0| 20 2d 66 20 52 45 41 44 | 4d 45 20 2d 61 20 22 24 | -f READ|ME -a "$|
|000005f0| 7b 31 7d 22 20 21 3d 20 | 22 2d 63 22 20 3b 20 74 |{1}" != |"-c" ; t|
|00000600| 68 65 6e 20 0a 20 20 65 | 63 68 6f 20 73 68 61 72 |hen . e|cho shar|
|00000610| 3a 20 57 69 6c 6c 20 6e | 6f 74 20 6f 76 65 72 2d |: Will n|ot over-|
|00000620| 77 72 69 74 65 20 65 78 | 69 73 74 69 6e 67 20 66 |write ex|isting f|
|00000630| 69 6c 65 20 5c 22 52 45 | 41 44 4d 45 5c 22 0a 65 |ile \"RE|ADME\".e|
|00000640| 6c 73 65 0a 65 63 68 6f | 20 73 68 61 72 3a 20 45 |lse.echo| shar: E|
|00000650| 78 74 72 61 63 74 69 6e | 67 20 5c 22 52 45 41 44 |xtractin|g \"READ|
|00000660| 4d 45 5c 22 20 5c 28 31 | 37 34 37 20 63 68 61 72 |ME\" \(1|747 char|
|00000670| 61 63 74 65 72 73 5c 29 | 0a 73 65 64 20 22 73 2f |acters\)|.sed "s/|
|00000680| 5e 58 2f 2f 22 20 3e 52 | 45 41 44 4d 45 20 3c 3c |^X//" >R|EADME <<|
|00000690| 27 45 4e 44 5f 4f 46 5f | 52 45 41 44 4d 45 27 0a |'END_OF_|README'.|
|000006a0| 58 22 6d 65 6d 6c 69 6e | 74 6f 6b 2e 68 22 20 69 |X"memlin|tok.h" i|
|000006b0| 73 20 61 20 68 65 61 64 | 65 72 20 66 69 6c 65 20 |s a head|er file |
|000006c0| 74 68 61 74 20 63 61 6e | 20 62 65 20 75 73 65 64 |that can| be used|
|000006d0| 20 74 6f 20 70 6f 6c 69 | 74 65 6c 79 20 73 68 75 | to poli|tely shu|
|000006e0| 74 20 6c 69 6e 74 28 31 | 29 20 75 70 0a 58 61 62 |t lint(1|) up.Xab|
|000006f0| 6f 75 74 20 63 61 73 74 | 69 6e 67 20 72 65 73 75 |out cast|ing resu|
|00000700| 6c 74 73 20 6f 66 20 6d | 65 6d 6f 72 79 20 61 6c |lts of m|emory al|
|00000710| 6c 6f 63 61 74 69 6f 6e | 20 66 75 6e 63 74 69 6f |location| functio|
|00000720| 6e 73 20 6d 61 6c 6c 6f | 63 28 33 29 2c 20 72 65 |ns mallo|c(3), re|
|00000730| 61 6c 6c 6f 63 28 33 29 | 2c 0a 58 61 6e 64 20 63 |alloc(3)|,.Xand c|
|00000740| 61 6c 6c 6f 63 28 33 29 | 2e 20 20 49 74 20 61 6c |alloc(3)|. It al|
|00000750| 73 6f 20 73 74 6f 70 73 | 20 63 6f 6d 70 6c 61 69 |so stops| complai|
|00000760| 6e 74 73 20 61 62 6f 75 | 74 20 74 68 65 20 61 72 |nts abou|t the ar|
|00000770| 67 75 6d 65 6e 74 20 6f | 66 20 66 72 65 65 28 33 |gument o|f free(3|
|00000780| 29 2e 0a 58 0a 58 43 4f | 4e 54 45 4e 54 53 0a 58 |)..X.XCO|NTENTS.X|
|00000790| 2d 2d 2d 2d 2d 2d 2d 2d | 0a 58 46 69 6c 65 73 20 |--------|.XFiles |
|000007a0| 69 6e 20 74 68 69 73 20 | 64 69 73 74 72 69 62 75 |in this |distribu|
|000007b0| 74 69 6f 6e 20 61 72 65 | 3a 0a 58 0a 58 52 45 41 |tion are|:.X.XREA|
|000007c0| 44 4d 45 09 09 09 79 6f | 75 27 72 65 20 72 65 61 |DME...yo|u're rea|
|000007d0| 64 69 6e 67 20 69 74 0a | 58 4d 61 6b 65 66 69 6c |ding it.|XMakefil|
|000007e0| 65 09 09 68 61 73 20 73 | 65 76 65 72 61 6c 20 75 |e..has s|everal u|
|000007f0| 73 65 66 75 6c 20 74 61 | 72 67 65 74 73 2c 20 69 |seful ta|rgets, i|
|00000800| 6e 63 6c 75 64 69 6e 67 | 20 22 69 6e 73 74 61 6c |ncluding| "instal|
|00000810| 6c 22 20 61 6e 64 20 22 | 74 65 73 74 22 0a 58 67 |l" and "|test".Xg|
|00000820| 6f 6f 64 09 09 09 67 6f | 6f 64 20 72 65 73 75 6c |ood...go|od resul|
|00000830| 74 73 20 66 6f 72 20 22 | 6d 61 6b 65 20 74 65 73 |ts for "|make tes|
|00000840| 74 22 0a 58 6d 65 6d 6c | 69 6e 74 6f 6b 2e 33 09 |t".Xmeml|intok.3.|
|00000850| 09 6d 61 6e 20 70 61 67 | 65 0a 58 6d 65 6d 6c 69 |.man pag|e.Xmemli|
|00000860| 6e 74 6f 6b 2e 68 09 09 | 74 68 65 20 68 65 61 64 |ntok.h..|the head|
|00000870| 65 72 20 66 69 6c 65 20 | 69 74 73 65 6c 66 0a 58 |er file |itself.X|
|00000880| 74 5f 6d 65 6d 6c 69 6e | 74 6f 6b 2e 63 09 61 20 |t_memlin|tok.c.a |
|00000890| 74 65 73 74 2f 64 65 6d | 6f 20 70 72 6f 67 72 61 |test/dem|o progra|
|000008a0| 6d 0a 58 0a 58 44 49 53 | 43 55 53 53 49 4f 4e 0a |m.X.XDIS|CUSSION.|
|000008b0| 58 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 0a 58 4f 6e 65 |X-------|---.XOne|
|000008c0| 20 63 6f 6d 6d 6f 6e 20 | 77 61 79 20 6f 66 20 69 | common |way of i|
|000008d0| 67 6e 6f 72 69 6e 67 20 | 6c 69 6e 74 20 65 72 72 |gnoring |lint err|
|000008e0| 6f 72 73 20 69 73 20 74 | 6f 20 64 6f 20 73 6f 6d |ors is t|o do som|
|000008f0| 65 74 68 69 6e 67 20 6c | 69 6b 65 3a 0a 58 0a 58 |ething l|ike:.X.X|
|00000900| 09 23 69 66 64 65 66 20 | 6c 69 6e 74 0a 58 09 23 |.#ifdef |lint.X.#|
|00000910| 64 65 66 69 6e 65 20 6d | 61 6c 6c 6f 63 28 61 72 |define m|alloc(ar|
|00000920| 67 29 20 4e 55 4c 4c 0a | 58 09 23 65 6e 64 69 66 |g) NULL.|X.#endif|
|00000930| 0a 58 0a 58 54 68 65 20 | 74 72 6f 75 62 6c 65 20 |.X.XThe |trouble |
|00000940| 77 69 74 68 20 64 6f 69 | 6e 67 20 74 68 69 6e 67 |with doi|ng thing|
|00000950| 73 20 74 68 69 73 20 77 | 61 79 20 69 73 20 74 68 |s this w|ay is th|
|00000960| 61 74 20 6c 69 6e 74 20 | 77 69 6c 6c 20 6e 6f 74 |at lint |will not|
|00000970| 20 74 68 65 6e 20 62 65 | 20 61 62 6c 65 20 74 6f | then be| able to|
|00000980| 0a 58 63 68 65 63 6b 20 | 6d 61 6c 6c 6f 63 27 73 |.Xcheck |malloc's|
|00000990| 20 61 72 67 75 6d 65 6e | 74 2c 20 73 6f 20 79 6f | argumen|t, so yo|
|000009a0| 75 20 63 6f 75 6c 64 20 | 67 65 74 20 61 77 61 79 |u could |get away|
|000009b0| 20 77 69 74 68 20 73 6f | 6d 65 74 68 69 6e 67 20 | with so|mething |
|000009c0| 6c 69 6b 65 3a 0a 58 0a | 58 09 63 68 61 72 20 2a |like:.X.|X.char *|
|000009d0| 70 3b 0a 58 09 63 68 61 | 72 20 2a 71 3b 0a 58 09 |p;.X.cha|r *q;.X.|
|000009e0| 2e 2e 2e 0a 58 09 70 20 | 3d 20 6d 61 6c 6c 6f 63 |....X.p |= malloc|
|000009f0| 28 71 29 3b 0a 58 0a 58 | 54 68 65 20 6d 61 63 72 |(q);.X.X|The macr|
|00000a00| 6f 73 20 68 65 72 65 20 | 61 72 65 20 61 20 62 69 |os here |are a bi|
|00000a10| 74 20 6d 6f 72 65 20 73 | 6f 70 68 69 73 74 69 63 |t more s|ophistic|
|00000a20| 61 74 65 64 2c 20 73 6f | 20 74 68 61 74 20 74 68 |ated, so| that th|
|00000a30| 65 20 6d 65 6d 6f 72 79 | 20 66 75 6e 63 74 69 6f |e memory| functio|
|00000a40| 6e 73 0a 58 67 65 74 20 | 69 6e 76 6f 6b 65 64 20 |ns.Xget |invoked |
|00000a50| 69 6e 20 61 20 73 79 6e | 74 61 63 74 69 63 61 6c |in a syn|tactical|
|00000a60| 6c 79 20 63 6f 72 72 65 | 63 74 20 61 6e 64 20 70 |ly corre|ct and p|
|00000a70| 72 6f 70 65 72 6c 79 2d | 74 79 70 65 64 20 28 61 |roperly-|typed (a|
|00000a80| 6c 74 68 6f 75 67 68 0a | 58 73 65 6d 61 6e 74 69 |lthough.|Xsemanti|
|00000a90| 63 61 6c 6c 79 20 69 6e | 63 6f 72 72 65 63 74 29 |cally in|correct)|
|00000aa0| 20 66 61 73 68 69 6f 6e | 20 61 6e 64 20 74 68 65 | fashion| and the|
|00000ab0| 20 61 72 67 75 6d 65 6e | 74 73 20 67 65 74 20 63 | argumen|ts get c|
|00000ac0| 68 65 63 6b 65 64 0a 58 | 69 6e 64 65 70 65 6e 64 |hecked.X|independ|
|00000ad0| 65 6e 74 6c 79 2e 20 20 | 54 68 65 20 6d 61 6e 20 |ently. |The man |
|00000ae0| 70 61 67 65 20 64 65 73 | 63 72 69 62 65 73 20 74 |page des|cribes t|
|00000af0| 68 65 69 72 20 75 73 65 | 2e 0a 58 0a 58 54 68 65 |heir use|..X.XThe|
|00000b00| 20 66 69 6c 65 20 61 6c | 73 6f 20 69 6e 63 6c 75 | file al|so inclu|
|00000b10| 64 65 73 20 61 20 6d 61 | 63 72 6f 20 4d 52 5f 41 |des a ma|cro MR_A|
|00000b20| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 20 74 68 61 74 |LLOC_LIN|TOK that|
|00000b30| 20 69 73 20 73 69 6d 70 | 6c 79 20 61 20 63 6f 6d | is simp|ly a com|
|00000b40| 70 61 63 74 20 66 6f 72 | 6d 0a 58 6f 66 20 74 68 |pact for|m.Xof th|
|00000b50| 65 20 63 6f 6d 6d 6f 6e | 6c 79 2d 6f 63 63 75 72 |e common|ly-occur|
|00000b60| 72 69 6e 67 20 63 6f 64 | 65 20 74 6f 20 61 6c 6c |ring cod|e to all|
|00000b70| 6f 63 61 74 65 20 6d 65 | 6d 6f 72 79 20 69 66 20 |ocate me|mory if |
|00000b80| 61 20 28 74 79 70 69 63 | 61 6c 6c 79 20 73 74 61 |a (typic|ally sta|
|00000b90| 74 69 63 29 0a 58 70 6f | 69 6e 74 65 72 20 69 73 |tic).Xpo|inter is|
|00000ba0| 20 4e 55 4c 4c 20 61 6e | 64 20 74 6f 20 72 65 61 | NULL an|d to rea|
|00000bb0| 6c 6c 6f 63 61 74 65 20 | 69 74 20 69 66 20 74 68 |llocate |it if th|
|00000bc0| 65 20 70 6f 69 6e 74 65 | 72 20 69 73 6e 27 74 20 |e pointe|r isn't |
|00000bd0| 4e 55 4c 4c 2e 0a 58 0a | 58 54 68 65 72 65 20 61 |NULL..X.|XThere a|
|00000be0| 72 65 20 61 6c 73 6f 20 | 6d 61 63 72 6f 73 20 74 |re also |macros t|
|00000bf0| 6f 20 64 6f 20 73 6f 6d | 65 20 70 72 69 6d 69 74 |o do som|e primit|
|00000c00| 69 76 65 20 65 78 63 65 | 70 74 69 6f 6e 20 68 61 |ive exce|ption ha|
|00000c10| 6e 64 6c 69 6e 67 20 6f | 66 20 74 68 65 20 6d 65 |ndling o|f the me|
|00000c20| 6d 6f 72 79 0a 58 61 6c | 6c 6f 63 61 74 69 6f 6e |mory.Xal|location|
|00000c30| 20 66 75 6e 63 74 69 6f | 6e 2e 20 20 53 65 65 20 | functio|n. See |
|00000c40| 74 68 65 20 6d 61 6e 20 | 70 61 67 65 20 66 6f 72 |the man |page for|
|00000c50| 20 6d 6f 72 65 20 6f 6e | 20 74 68 65 73 65 2e 0a | more on| these..|
|00000c60| 58 0a 58 41 73 20 49 20 | 64 65 76 65 6c 6f 70 65 |X.XAs I |develope|
|00000c70| 64 20 69 74 20 77 69 74 | 68 20 6d 79 20 6f 77 6e |d it wit|h my own|
|00000c80| 20 72 65 73 6f 75 72 63 | 65 73 2c 20 49 27 6d 20 | resourc|es, I'm |
|00000c90| 72 65 6c 65 61 73 69 6e | 67 20 74 68 69 73 20 63 |releasin|g this c|
|00000ca0| 6f 64 65 20 74 6f 20 74 | 68 65 0a 58 70 75 62 6c |ode to t|he.Xpubl|
|00000cb0| 69 63 20 64 6f 6d 61 69 | 6e 2e 20 20 49 20 68 65 |ic domai|n. I he|
|00000cc0| 72 65 62 79 20 64 65 6e | 79 20 61 6e 79 20 72 65 |reby den|y any re|
|00000cd0| 73 70 6f 6e 73 69 62 69 | 6c 69 74 79 20 66 6f 72 |sponsibi|lity for|
|00000ce0| 20 69 74 73 20 75 73 65 | 20 6f 72 20 61 6e 79 20 | its use| or any |
|00000cf0| 64 61 6d 61 67 65 73 0a | 58 72 65 73 75 6c 74 69 |damages.|Xresulti|
|00000d00| 6e 67 20 66 72 6f 6d 20 | 73 61 6d 65 2e 0a 58 0a |ng from |same..X.|
|00000d10| 58 4e 65 76 65 72 74 68 | 65 6c 65 73 73 2c 20 69 |XNeverth|eless, i|
|00000d20| 66 20 61 6e 79 6f 6e 65 | 20 68 61 73 20 61 6e 79 |f anyone| has any|
|00000d30| 20 70 72 6f 62 6c 65 6d | 73 20 77 69 74 68 20 69 | problem|s with i|
|00000d40| 74 2c 20 71 75 65 73 74 | 69 6f 6e 73 20 61 62 6f |t, quest|ions abo|
|00000d50| 75 74 20 69 74 2c 20 6f | 72 0a 58 69 6d 70 72 6f |ut it, o|r.Ximpro|
|00000d60| 76 65 6d 65 6e 74 73 20 | 74 6f 20 69 74 2c 20 70 |vements |to it, p|
|00000d70| 6c 65 61 73 65 20 6c 65 | 74 20 6d 65 20 6b 6e 6f |lease le|t me kno|
|00000d80| 77 2e 0a 58 0a 58 09 2d | 20 42 6f 62 20 4c 65 77 |w..X.X.-| Bob Lew|
|00000d90| 69 73 0a 58 09 20 20 62 | 6f 62 6c 40 74 65 73 73 |is.X. b|obl@tess|
|00000da0| 69 2e 75 75 63 70 0a 45 | 4e 44 5f 4f 46 5f 52 45 |i.uucp.E|ND_OF_RE|
|00000db0| 41 44 4d 45 0a 69 66 20 | 74 65 73 74 20 31 37 34 |ADME.if |test 174|
|00000dc0| 37 20 2d 6e 65 20 60 77 | 63 20 2d 63 20 3c 52 45 |7 -ne `w|c -c <RE|
|00000dd0| 41 44 4d 45 60 3b 20 74 | 68 65 6e 0a 20 20 20 20 |ADME`; t|hen. |
|00000de0| 65 63 68 6f 20 73 68 61 | 72 3a 20 5c 22 52 45 41 |echo sha|r: \"REA|
|00000df0| 44 4d 45 5c 22 20 75 6e | 70 61 63 6b 65 64 20 77 |DME\" un|packed w|
|00000e00| 69 74 68 20 77 72 6f 6e | 67 20 73 69 7a 65 21 0a |ith wron|g size!.|
|00000e10| 66 69 0a 23 20 65 6e 64 | 20 6f 66 20 6f 76 65 72 |fi.# end| of over|
|00000e20| 77 72 69 74 69 6e 67 20 | 63 68 65 63 6b 0a 66 69 |writing |check.fi|
|00000e30| 0a 69 66 20 74 65 73 74 | 20 2d 66 20 4d 61 6b 65 |.if test| -f Make|
|00000e40| 66 69 6c 65 20 2d 61 20 | 22 24 7b 31 7d 22 20 21 |file -a |"${1}" !|
|00000e50| 3d 20 22 2d 63 22 20 3b | 20 74 68 65 6e 20 0a 20 |= "-c" ;| then . |
|00000e60| 20 65 63 68 6f 20 73 68 | 61 72 3a 20 57 69 6c 6c | echo sh|ar: Will|
|00000e70| 20 6e 6f 74 20 6f 76 65 | 72 2d 77 72 69 74 65 20 | not ove|r-write |
|00000e80| 65 78 69 73 74 69 6e 67 | 20 66 69 6c 65 20 5c 22 |existing| file \"|
|00000e90| 4d 61 6b 65 66 69 6c 65 | 5c 22 0a 65 6c 73 65 0a |Makefile|\".else.|
|00000ea0| 65 63 68 6f 20 73 68 61 | 72 3a 20 45 78 74 72 61 |echo sha|r: Extra|
|00000eb0| 63 74 69 6e 67 20 5c 22 | 4d 61 6b 65 66 69 6c 65 |cting \"|Makefile|
|00000ec0| 5c 22 20 5c 28 39 35 34 | 20 63 68 61 72 61 63 74 |\" \(954| charact|
|00000ed0| 65 72 73 5c 29 0a 73 65 | 64 20 22 73 2f 5e 58 2f |ers\).se|d "s/^X/|
|00000ee0| 2f 22 20 3e 4d 61 6b 65 | 66 69 6c 65 20 3c 3c 27 |/" >Make|file <<'|
|00000ef0| 45 4e 44 5f 4f 46 5f 4d | 61 6b 65 66 69 6c 65 27 |END_OF_M|akefile'|
|00000f00| 0a 58 23 20 24 48 65 61 | 64 65 72 3a 20 4d 61 6b |.X# $Hea|der: Mak|
|00000f10| 65 66 69 6c 65 2c 76 20 | 31 2e 34 20 38 39 2f 30 |efile,v |1.4 89/0|
|00000f20| 35 2f 30 32 20 31 35 3a | 30 36 3a 34 38 20 62 6f |5/02 15:|06:48 bo|
|00000f30| 62 6c 20 4c 6f 63 6b 65 | 64 20 24 0a 58 0a 58 64 |bl Locke|d $.X.Xd|
|00000f40| 65 66 61 75 6c 74 3a 20 | 6e 65 77 0a 58 0a 58 23 |efault: |new.X.X#|
|00000f50| 0a 58 23 09 54 68 69 73 | 20 69 73 20 77 68 65 72 |.X#.This| is wher|
|00000f60| 65 20 79 6f 75 20 77 61 | 6e 74 20 74 68 65 20 68 |e you wa|nt the h|
|00000f70| 65 61 64 65 72 20 74 6f | 20 67 6f 2e 20 20 49 74 |eader to| go. It|
|00000f80| 20 6d 69 67 68 74 20 62 | 65 20 61 64 76 69 73 61 | might b|e advisa|
|00000f90| 62 6c 65 20 74 6f 0a 58 | 23 09 70 75 74 20 69 74 |ble to.X|#.put it|
|00000fa0| 20 69 6e 20 73 6f 6d 65 | 20 6c 6f 63 61 6c 20 64 | in some| local d|
|00000fb0| 69 72 65 63 74 6f 72 79 | 20 72 61 74 68 65 72 20 |irectory| rather |
|00000fc0| 74 68 61 6e 20 74 68 69 | 73 20 64 65 66 61 75 6c |than thi|s defaul|
|00000fd0| 74 20 6f 6e 65 2e 2e 2e | 0a 58 23 0a 58 48 44 52 |t one...|.X#.XHDR|
|00000fe0| 5f 44 45 53 54 20 3d 20 | 2f 75 73 72 2f 69 6e 63 |_DEST = |/usr/inc|
|00000ff0| 6c 75 64 65 0a 58 0a 58 | 23 0a 58 23 09 54 68 65 |lude.X.X|#.X#.The|
|00001000| 20 6d 61 6e 20 70 61 67 | 65 20 67 6f 65 73 20 68 | man pag|e goes h|
|00001010| 65 72 65 2e 20 20 41 67 | 61 69 6e 2c 20 79 6f 75 |ere. Ag|ain, you|
|00001020| 20 6d 61 79 20 68 61 76 | 65 20 73 6f 6d 65 20 6c | may hav|e some l|
|00001030| 6f 63 61 6c 20 70 6c 61 | 63 65 20 74 6f 20 70 75 |ocal pla|ce to pu|
|00001040| 74 20 69 74 2e 0a 58 23 | 0a 58 4d 41 4e 5f 44 45 |t it..X#|.XMAN_DE|
|00001050| 53 54 20 3d 20 2f 75 73 | 72 2f 6d 61 6e 2f 6d 61 |ST = /us|r/man/ma|
|00001060| 6e 33 0a 58 0a 58 46 49 | 4c 45 53 20 3d 20 5c 0a |n3.X.XFI|LES = \.|
|00001070| 58 09 52 45 41 44 4d 45 | 20 5c 0a 58 09 4d 61 6b |X.README| \.X.Mak|
|00001080| 65 66 69 6c 65 20 5c 0a | 58 09 67 6f 6f 64 20 5c |efile \.|X.good \|
|00001090| 0a 58 09 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 33 20 5c |.X.memli|ntok.3 \|
|000010a0| 0a 58 09 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 68 20 5c |.X.memli|ntok.h \|
|000010b0| 0a 58 09 74 5f 6d 65 6d | 6c 69 6e 74 6f 6b 2e 63 |.X.t_mem|lintok.c|
|000010c0| 0a 58 0a 58 63 6c 65 61 | 6e 3a 0a 58 09 72 6d 20 |.X.Xclea|n:.X.rm |
|000010d0| 2d 66 20 74 5f 6d 65 6d | 6c 69 6e 74 6f 6b 20 6e |-f t_mem|lintok n|
|000010e0| 65 77 20 63 6f 72 65 20 | 61 2e 6f 75 74 20 2a 2e |ew core |a.out *.|
|000010f0| 6f 20 6d 65 6d 6c 69 6e | 74 6f 6b 2e 73 68 61 72 |o memlin|tok.shar|
|00001100| 0a 58 0a 58 6e 65 77 3a | 09 74 5f 6d 65 6d 6c 69 |.X.Xnew:|.t_memli|
|00001110| 6e 74 6f 6b 0a 58 09 74 | 5f 6d 65 6d 6c 69 6e 74 |ntok.X.t|_memlint|
|00001120| 6f 6b 20 3e 6e 65 77 0a | 58 0a 58 74 5f 6d 65 6d |ok >new.|X.Xt_mem|
|00001130| 6c 69 6e 74 6f 6b 3a 09 | 74 5f 6d 65 6d 6c 69 6e |lintok:.|t_memlin|
|00001140| 74 6f 6b 2e 63 20 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |tok.c me|mlintok.|
|00001150| 68 0a 58 09 63 63 20 74 | 5f 6d 65 6d 6c 69 6e 74 |h.X.cc t|_memlint|
|00001160| 6f 6b 2e 63 20 2d 6f 20 | 74 5f 6d 65 6d 6c 69 6e |ok.c -o |t_memlin|
|00001170| 74 6f 6b 0a 58 0a 58 74 | 65 73 74 3a 09 6e 65 77 |tok.X.Xt|est:.new|
|00001180| 20 74 5f 6d 65 6d 6c 69 | 6e 74 6f 6b 0a 58 09 40 | t_memli|ntok.X.@|
|00001190| 65 63 68 6f 20 22 23 20 | 63 6f 6d 70 61 72 69 6e |echo "# |comparin|
|000011a0| 67 20 6e 65 77 20 72 65 | 73 75 6c 74 73 20 77 69 |g new re|sults wi|
|000011b0| 74 68 20 6b 6e 6f 77 6e | 20 67 6f 6f 64 20 6f 6e |th known| good on|
|000011c0| 65 73 3a 22 0a 58 09 64 | 69 66 66 20 6e 65 77 20 |es:".X.d|iff new |
|000011d0| 67 6f 6f 64 0a 58 09 40 | 65 63 68 6f 20 22 23 20 |good.X.@|echo "# |
|000011e0| 73 68 6f 75 6c 64 20 62 | 65 20 6e 6f 20 6c 69 6e |should b|e no lin|
|000011f0| 74 20 65 72 72 6f 72 73 | 3a 22 0a 58 09 6c 69 6e |t errors|:".X.lin|
|00001200| 74 20 2d 62 61 63 68 78 | 20 74 5f 6d 65 6d 6c 69 |t -bachx| t_memli|
|00001210| 6e 74 6f 6b 2e 63 0a 58 | 0a 58 75 70 64 61 74 65 |ntok.c.X|.Xupdate|
|00001220| 3a 09 6e 65 77 0a 58 09 | 6d 76 20 2d 66 20 6e 65 |:.new.X.|mv -f ne|
|00001230| 77 20 67 6f 6f 64 0a 58 | 0a 58 73 68 61 72 3a 20 |w good.X|.Xshar: |
|00001240| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 73 68 61 72 0a 58 |memlinto|k.shar.X|
|00001250| 0a 58 6d 65 6d 6c 69 6e | 74 6f 6b 2e 73 68 61 72 |.Xmemlin|tok.shar|
|00001260| 3a 20 24 28 46 49 4c 45 | 53 29 0a 58 09 73 68 61 |: $(FILE|S).X.sha|
|00001270| 72 20 24 28 46 49 4c 45 | 53 29 20 3e 6d 65 6d 6c |r $(FILE|S) >meml|
|00001280| 69 6e 74 6f 6b 2e 73 68 | 61 72 0a 58 0a 58 69 6e |intok.sh|ar.X.Xin|
|00001290| 73 74 61 6c 6c 3a 20 6d | 65 6d 6c 69 6e 74 6f 6b |stall: m|emlintok|
|000012a0| 2e 68 20 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 33 0a 58 |.h memli|ntok.3.X|
|000012b0| 09 63 70 20 6d 65 6d 6c | 69 6e 74 6f 6b 2e 68 20 |.cp meml|intok.h |
|000012c0| 24 28 48 44 52 5f 44 45 | 53 54 29 0a 58 09 63 70 |$(HDR_DE|ST).X.cp|
|000012d0| 20 6d 65 6d 6c 69 6e 74 | 6f 6b 2e 33 20 24 28 4d | memlint|ok.3 $(M|
|000012e0| 41 4e 5f 44 45 53 54 29 | 0a 58 0a 58 09 0a 45 4e |AN_DEST)|.X.X..EN|
|000012f0| 44 5f 4f 46 5f 4d 61 6b | 65 66 69 6c 65 0a 69 66 |D_OF_Mak|efile.if|
|00001300| 20 74 65 73 74 20 39 35 | 34 20 2d 6e 65 20 60 77 | test 95|4 -ne `w|
|00001310| 63 20 2d 63 20 3c 4d 61 | 6b 65 66 69 6c 65 60 3b |c -c <Ma|kefile`;|
|00001320| 20 74 68 65 6e 0a 20 20 | 20 20 65 63 68 6f 20 73 | then. | echo s|
|00001330| 68 61 72 3a 20 5c 22 4d | 61 6b 65 66 69 6c 65 5c |har: \"M|akefile\|
|00001340| 22 20 75 6e 70 61 63 6b | 65 64 20 77 69 74 68 20 |" unpack|ed with |
|00001350| 77 72 6f 6e 67 20 73 69 | 7a 65 21 0a 66 69 0a 23 |wrong si|ze!.fi.#|
|00001360| 20 65 6e 64 20 6f 66 20 | 6f 76 65 72 77 72 69 74 | end of |overwrit|
|00001370| 69 6e 67 20 63 68 65 63 | 6b 0a 66 69 0a 69 66 20 |ing chec|k.fi.if |
|00001380| 74 65 73 74 20 2d 66 20 | 67 6f 6f 64 20 2d 61 20 |test -f |good -a |
|00001390| 22 24 7b 31 7d 22 20 21 | 3d 20 22 2d 63 22 20 3b |"${1}" !|= "-c" ;|
|000013a0| 20 74 68 65 6e 20 0a 20 | 20 65 63 68 6f 20 73 68 | then . | echo sh|
|000013b0| 61 72 3a 20 57 69 6c 6c | 20 6e 6f 74 20 6f 76 65 |ar: Will| not ove|
|000013c0| 72 2d 77 72 69 74 65 20 | 65 78 69 73 74 69 6e 67 |r-write |existing|
|000013d0| 20 66 69 6c 65 20 5c 22 | 67 6f 6f 64 5c 22 0a 65 | file \"|good\".e|
|000013e0| 6c 73 65 0a 65 63 68 6f | 20 73 68 61 72 3a 20 45 |lse.echo| shar: E|
|000013f0| 78 74 72 61 63 74 69 6e | 67 20 5c 22 67 6f 6f 64 |xtractin|g \"good|
|00001400| 5c 22 20 5c 28 32 34 34 | 20 63 68 61 72 61 63 74 |\" \(244| charact|
|00001410| 65 72 73 5c 29 0a 73 65 | 64 20 22 73 2f 5e 58 2f |ers\).se|d "s/^X/|
|00001420| 2f 22 20 3e 67 6f 6f 64 | 20 3c 3c 27 45 4e 44 5f |/" >good| <<'END_|
|00001430| 4f 46 5f 67 6f 6f 64 27 | 0a 58 31 30 30 20 69 6e |OF_good'|.X100 in|
|00001440| 74 73 20 6d 61 6c 6c 6f | 63 27 64 0a 58 32 30 30 |ts mallo|c'd.X200|
|00001450| 20 69 6e 74 73 20 72 65 | 61 6c 6c 6f 63 27 64 0a | ints re|alloc'd.|
|00001460| 58 32 35 20 69 6e 74 73 | 20 6d 72 5f 61 6c 6c 6f |X25 ints| mr_allo|
|00001470| 63 27 64 20 28 72 65 61 | 6c 6c 6f 63 27 64 29 0a |c'd (rea|lloc'd).|
|00001480| 58 35 30 30 20 69 6e 74 | 73 20 63 61 6c 6c 6f 63 |X500 int|s calloc|
|00001490| 27 64 0a 58 31 30 30 30 | 20 69 6e 74 73 20 6d 72 |'d.X1000| ints mr|
|000014a0| 5f 61 6c 6c 6f 63 27 64 | 20 28 6d 61 6c 6c 6f 63 |_alloc'd| (malloc|
|000014b0| 27 64 29 0a 58 35 30 20 | 69 6e 74 73 20 63 61 6c |'d).X50 |ints cal|
|000014c0| 6c 6f 63 27 64 20 28 6f | 72 20 65 6c 73 65 29 0a |loc'd (o|r else).|
|000014d0| 58 31 30 30 20 69 6e 74 | 73 20 6d 61 6c 6c 6f 63 |X100 int|s malloc|
|000014e0| 27 64 20 28 6f 72 20 65 | 6c 73 65 29 0a 58 32 30 |'d (or e|lse).X20|
|000014f0| 30 20 69 6e 74 73 20 72 | 65 61 6c 6c 6f 63 27 64 |0 ints r|ealloc'd|
|00001500| 20 28 6f 72 20 65 6c 73 | 65 29 0a 58 34 30 30 20 | (or els|e).X400 |
|00001510| 69 6e 74 73 20 6d 72 5f | 61 6c 6c 6f 63 27 64 20 |ints mr_|alloc'd |
|00001520| 28 72 65 61 6c 6c 6f 63 | 27 64 29 20 28 6f 72 20 |(realloc|'d) (or |
|00001530| 65 6c 73 65 29 0a 45 4e | 44 5f 4f 46 5f 67 6f 6f |else).EN|D_OF_goo|
|00001540| 64 0a 69 66 20 74 65 73 | 74 20 32 34 34 20 2d 6e |d.if tes|t 244 -n|
|00001550| 65 20 60 77 63 20 2d 63 | 20 3c 67 6f 6f 64 60 3b |e `wc -c| <good`;|
|00001560| 20 74 68 65 6e 0a 20 20 | 20 20 65 63 68 6f 20 73 | then. | echo s|
|00001570| 68 61 72 3a 20 5c 22 67 | 6f 6f 64 5c 22 20 75 6e |har: \"g|ood\" un|
|00001580| 70 61 63 6b 65 64 20 77 | 69 74 68 20 77 72 6f 6e |packed w|ith wron|
|00001590| 67 20 73 69 7a 65 21 0a | 66 69 0a 23 20 65 6e 64 |g size!.|fi.# end|
|000015a0| 20 6f 66 20 6f 76 65 72 | 77 72 69 74 69 6e 67 20 | of over|writing |
|000015b0| 63 68 65 63 6b 0a 66 69 | 0a 69 66 20 74 65 73 74 |check.fi|.if test|
|000015c0| 20 2d 66 20 6d 65 6d 6c | 69 6e 74 6f 6b 2e 33 20 | -f meml|intok.3 |
|000015d0| 2d 61 20 22 24 7b 31 7d | 22 20 21 3d 20 22 2d 63 |-a "${1}|" != "-c|
|000015e0| 22 20 3b 20 74 68 65 6e | 20 0a 20 20 65 63 68 6f |" ; then| . echo|
|000015f0| 20 73 68 61 72 3a 20 57 | 69 6c 6c 20 6e 6f 74 20 | shar: W|ill not |
|00001600| 6f 76 65 72 2d 77 72 69 | 74 65 20 65 78 69 73 74 |over-wri|te exist|
|00001610| 69 6e 67 20 66 69 6c 65 | 20 5c 22 6d 65 6d 6c 69 |ing file| \"memli|
|00001620| 6e 74 6f 6b 2e 33 5c 22 | 0a 65 6c 73 65 0a 65 63 |ntok.3\"|.else.ec|
|00001630| 68 6f 20 73 68 61 72 3a | 20 45 78 74 72 61 63 74 |ho shar:| Extract|
|00001640| 69 6e 67 20 5c 22 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |ing \"me|mlintok.|
|00001650| 33 5c 22 20 5c 28 34 37 | 30 36 20 63 68 61 72 61 |3\" \(47|06 chara|
|00001660| 63 74 65 72 73 5c 29 0a | 73 65 64 20 22 73 2f 5e |cters\).|sed "s/^|
|00001670| 58 2f 2f 22 20 3e 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |X//" >me|mlintok.|
|00001680| 33 20 3c 3c 27 45 4e 44 | 5f 4f 46 5f 6d 65 6d 6c |3 <<'END|_OF_meml|
|00001690| 69 6e 74 6f 6b 2e 33 27 | 0a 58 2e 54 48 20 4c 49 |intok.3'|.X.TH LI|
|000016a0| 4e 54 4f 4b 20 33 20 22 | 32 20 4d 61 79 20 31 39 |NTOK 3 "|2 May 19|
|000016b0| 38 39 22 0a 58 2e 53 48 | 20 4e 41 4d 45 0a 58 6d |89".X.SH| NAME.Xm|
|000016c0| 65 6d 6c 69 6e 74 6f 6b | 20 5c 2d 20 70 61 63 6b |emlintok| \- pack|
|000016d0| 61 67 65 20 74 6f 20 73 | 74 6f 70 20 6c 69 6e 74 |age to s|top lint|
|000016e0| 20 63 6f 6d 70 6c 61 69 | 6e 74 73 20 61 62 6f 75 | complai|nts abou|
|000016f0| 74 20 6d 65 6d 6f 72 79 | 20 61 6c 6c 6f 63 61 74 |t memory| allocat|
|00001700| 69 6f 6e 0a 58 2e 53 48 | 20 53 59 4e 4f 50 53 49 |ion.X.SH| SYNOPSI|
|00001710| 53 0a 58 2e 4c 50 0a 58 | 23 69 6e 63 6c 75 64 65 |S.X.LP.X|#include|
|00001720| 20 22 6d 65 6d 6c 69 6e | 74 6f 6b 2e 68 22 0a 58 | "memlin|tok.h".X|
|00001730| 2e 53 48 20 44 45 53 43 | 52 49 50 54 49 4f 4e 0a |.SH DESC|RIPTION.|
|00001740| 58 2e 4c 50 0a 58 54 68 | 69 73 20 70 61 63 6b 61 |X.LP.XTh|is packa|
|00001750| 67 65 20 63 6f 6e 74 61 | 69 6e 73 20 63 70 70 20 |ge conta|ins cpp |
|00001760| 6d 61 63 72 6f 20 64 65 | 66 69 6e 69 74 69 6f 6e |macro de|finition|
|00001770| 73 20 74 68 61 74 0a 58 | 73 74 6f 70 20 6c 69 6e |s that.X|stop lin|
|00001780| 74 20 66 72 6f 6d 20 63 | 6f 6d 70 6c 61 69 6e 69 |t from c|omplaini|
|00001790| 6e 67 20 61 62 6f 75 74 | 20 74 68 65 20 6d 65 6d |ng about| the mem|
|000017a0| 6f 72 79 20 6d 61 6e 61 | 67 65 6d 65 6e 74 20 66 |ory mana|gement f|
|000017b0| 75 6e 63 74 69 6f 6e 73 | 0a 58 2e 49 52 20 6d 61 |unctions|.X.IR ma|
|000017c0| 6c 6c 6f 63 20 28 33 29 | 2c 0a 58 2e 49 52 20 63 |lloc (3)|,.X.IR c|
|000017d0| 61 6c 6c 6f 63 20 28 33 | 29 2c 0a 58 2e 49 52 20 |alloc (3|),.X.IR |
|000017e0| 72 65 61 6c 6c 6f 63 20 | 28 33 29 2c 0a 58 61 6e |realloc |(3),.Xan|
|000017f0| 64 0a 58 2e 49 52 20 66 | 72 65 65 20 28 33 29 0a |d.X.IR f|ree (3).|
|00001800| 58 28 68 65 72 65 61 66 | 74 65 72 2c 20 77 65 27 |X(hereaf|ter, we'|
|00001810| 6c 6c 20 63 61 6c 6c 20 | 74 68 65 73 65 20 74 68 |ll call |these th|
|00001820| 65 20 22 5c 66 49 2a 61 | 6c 6c 6f 63 5c 66 50 28 |e "\fI*a|lloc\fP(|
|00001830| 33 29 22 20 66 75 6e 63 | 74 69 6f 6e 73 29 2c 0a |3)" func|tions),.|
|00001840| 58 77 68 69 6c 65 20 61 | 74 20 74 68 65 20 73 61 |Xwhile a|t the sa|
|00001850| 6d 65 20 74 69 6d 65 20 | 70 65 72 66 6f 72 6d 69 |me time |performi|
|00001860| 6e 67 20 63 68 65 63 6b | 73 20 6f 66 20 74 68 65 |ng check|s of the|
|00001870| 69 72 20 61 72 67 75 6d | 65 6e 74 73 2e 0a 58 54 |ir argum|ents..XT|
|00001880| 68 65 72 65 20 61 72 65 | 20 74 77 6f 20 73 65 74 |here are| two set|
|00001890| 73 20 6f 66 20 6d 61 63 | 72 6f 73 20 64 65 66 69 |s of mac|ros defi|
|000018a0| 6e 65 64 20 68 65 72 65 | 3a 20 6f 6e 65 20 77 69 |ned here|: one wi|
|000018b0| 74 68 6f 75 74 20 65 78 | 63 65 70 74 69 6f 6e 20 |thout ex|ception |
|000018c0| 68 61 6e 64 6c 69 6e 67 | 0a 58 28 6c 69 6b 65 20 |handling|.X(like |
|000018d0| 74 68 65 0a 58 2e 49 52 | 20 2a 61 6c 6c 6f 63 20 |the.X.IR| *alloc |
|000018e0| 28 33 29 0a 58 66 75 6e | 63 74 69 6f 6e 73 20 74 |(3).Xfun|ctions t|
|000018f0| 68 65 6d 73 65 6c 76 65 | 73 29 20 61 6e 64 20 6f |hemselve|s) and o|
|00001900| 6e 65 20 77 69 74 68 2e | 0a 58 2e 4c 50 0a 58 54 |ne with.|.X.LP.XT|
|00001910| 68 65 20 6d 61 63 72 6f | 73 20 77 69 74 68 6f 75 |he macro|s withou|
|00001920| 74 20 65 78 63 65 70 74 | 69 6f 6e 20 68 61 6e 64 |t except|ion hand|
|00001930| 6c 69 6e 67 20 61 72 65 | 3a 0a 58 2e 49 50 20 22 |ling are|:.X.IP "|
|00001940| 22 0a 58 43 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |".XCALLO|C_LINTOK|
|00001950| 28 70 74 72 2c 20 6e 65 | 6c 65 6d 2c 20 74 79 70 |(ptr, ne|lem, typ|
|00001960| 65 29 0a 58 2e 62 72 0a | 58 4d 41 4c 4c 4f 43 5f |e).X.br.|XMALLOC_|
|00001970| 4c 49 4e 54 4f 4b 28 70 | 74 72 2c 20 6e 65 6c 65 |LINTOK(p|tr, nele|
|00001980| 6d 2c 20 74 79 70 65 29 | 0a 58 2e 62 72 0a 58 52 |m, type)|.X.br.XR|
|00001990| 45 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 28 70 74 |EALLOC_L|INTOK(pt|
|000019a0| 72 2c 20 6e 65 6c 65 6d | 2c 20 74 79 70 65 29 0a |r, nelem|, type).|
|000019b0| 58 2e 62 72 0a 58 46 52 | 45 45 5f 4c 49 4e 54 4f |X.br.XFR|EE_LINTO|
|000019c0| 4b 28 70 74 72 29 0a 58 | 2e 62 72 0a 58 2e 4c 50 |K(ptr).X|.br.X.LP|
|000019d0| 0a 58 77 68 65 72 65 20 | 22 70 74 72 22 20 69 73 |.Xwhere |"ptr" is|
|000019e0| 20 61 20 76 61 72 69 61 | 62 6c 65 20 6f 66 20 74 | a varia|ble of t|
|000019f0| 79 70 65 20 22 74 79 70 | 65 20 2a 22 2e 20 20 41 |ype "typ|e *". A|
|00001a00| 66 74 65 72 20 69 6e 76 | 6f 6b 69 6e 67 20 61 6e |fter inv|oking an|
|00001a10| 79 0a 58 6f 66 20 74 68 | 65 20 22 2a 41 4c 4c 4f |y.Xof th|e "*ALLO|
|00001a20| 43 5f 4c 49 4e 54 4f 4b | 22 20 6d 61 63 72 6f 73 |C_LINTOK|" macros|
|00001a30| 2c 20 22 70 74 72 22 20 | 77 69 6c 6c 20 65 69 74 |, "ptr" |will eit|
|00001a40| 68 65 72 20 62 65 20 4e | 55 4c 4c 20 28 69 66 20 |her be N|ULL (if |
|00001a50| 61 6e 64 0a 58 6f 6e 6c | 79 20 69 66 20 74 68 65 |and.Xonl|y if the|
|00001a60| 0a 58 75 6e 64 65 72 6c | 79 69 6e 67 20 66 75 6e |.Xunderl|ying fun|
|00001a70| 63 74 69 6f 6e 20 72 65 | 74 75 72 6e 65 64 20 69 |ction re|turned i|
|00001a80| 74 29 20 6f 72 20 69 74 | 20 77 69 6c 6c 20 70 6f |t) or it| will po|
|00001a90| 69 6e 74 20 74 6f 20 61 | 6e 20 61 72 72 61 79 20 |int to a|n array |
|00001aa0| 6f 66 0a 58 22 6e 65 6c | 65 6d 22 20 6f 62 6a 65 |of.X"nel|em" obje|
|00001ab0| 63 74 73 20 6f 66 20 74 | 79 70 65 20 22 74 79 70 |cts of t|ype "typ|
|00001ac0| 65 22 2e 0a 58 2e 4c 50 | 0a 58 4e 6f 74 65 20 74 |e"..X.LP|.XNote t|
|00001ad0| 68 61 74 20 74 68 65 20 | 75 73 61 67 65 20 6f 66 |hat the |usage of|
|00001ae0| 20 4d 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 2c 20 | MALLOC_|LINTOK, |
|00001af0| 43 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 2c 20 61 |CALLOC_L|INTOK, a|
|00001b00| 6e 64 0a 58 52 45 41 4c | 4c 4f 43 5f 4c 49 4e 54 |nd.XREAL|LOC_LINT|
|00001b10| 4f 4b 20 72 65 71 75 69 | 72 65 73 20 6d 6f 72 65 |OK requi|res more|
|00001b20| 20 74 68 61 6e 20 61 20 | 6e 61 6d 65 20 63 68 61 | than a |name cha|
|00001b30| 6e 67 65 2e 20 20 41 6e | 20 6f 72 69 67 69 6e 61 |nge. An| origina|
|00001b40| 6c 0a 58 63 61 6c 6c 20 | 6f 66 20 74 68 65 20 66 |l.Xcall |of the f|
|00001b50| 6f 72 6d 3a 0a 58 2e 49 | 50 0a 58 70 74 72 20 3d |orm:.X.I|P.Xptr =|
|00001b60| 20 28 74 79 70 65 20 2a | 29 20 6d 61 6c 6c 6f 63 | (type *|) malloc|
|00001b70| 28 6e 65 6c 65 6d 20 2a | 20 73 69 7a 65 6f 66 28 |(nelem *| sizeof(|
|00001b80| 74 79 70 65 29 29 0a 58 | 2e 4c 50 0a 58 6d 75 73 |type)).X|.LP.Xmus|
|00001b90| 74 20 62 65 20 72 65 70 | 6c 61 63 65 64 20 62 79 |t be rep|laced by|
|00001ba0| 0a 58 2e 49 50 0a 58 4d | 41 4c 4c 4f 43 5f 4c 49 |.X.IP.XM|ALLOC_LI|
|00001bb0| 4e 54 4f 4b 28 70 74 72 | 2c 20 6e 65 6c 65 6d 2c |NTOK(ptr|, nelem,|
|00001bc0| 20 74 79 70 65 29 0a 58 | 2e 4c 50 0a 58 61 6e 64 | type).X|.LP.Xand|
|00001bd0| 20 73 69 6d 69 6c 61 72 | 6c 79 20 66 6f 72 20 43 | similar|ly for C|
|00001be0| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 20 61 6e 64 |ALLOC_LI|NTOK and|
|00001bf0| 20 52 45 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 2e | REALLOC|_LINTOK.|
|00001c00| 20 20 41 6c 6c 20 74 68 | 72 65 65 0a 58 6d 61 63 | All th|ree.Xmac|
|00001c10| 72 6f 73 20 22 72 65 74 | 75 72 6e 22 20 76 61 6c |ros "ret|urn" val|
|00001c20| 75 65 73 20 61 6e 64 20 | 6d 61 79 20 74 68 65 72 |ues and |may ther|
|00001c30| 65 66 6f 72 65 20 62 65 | 20 75 73 65 64 20 61 73 |efore be| used as|
|00001c40| 20 70 61 72 74 20 6f 66 | 0a 58 65 78 70 72 65 73 | part of|.Xexpres|
|00001c50| 73 69 6f 6e 73 2e 0a 58 | 2e 4c 50 0a 58 49 66 20 |sions..X|.LP.XIf |
|00001c60| 61 20 6d 61 63 72 6f 27 | 73 20 72 65 73 75 6c 74 |a macro'|s result|
|00001c70| 20 69 73 20 63 6f 6d 70 | 61 72 65 64 20 77 69 74 | is comp|ared wit|
|00001c80| 68 20 4e 55 4c 4c 2c 20 | 6c 69 6e 74 20 77 69 6c |h NULL, |lint wil|
|00001c90| 6c 20 75 73 75 61 6c 6c | 79 20 63 6f 6d 70 6c 61 |l usuall|y compla|
|00001ca0| 69 6e 0a 58 69 66 20 4e | 55 4c 4c 20 69 73 20 63 |in.Xif N|ULL is c|
|00001cb0| 61 73 74 20 74 6f 20 61 | 6e 79 74 68 69 6e 67 2e |ast to a|nything.|
|00001cc0| 20 20 46 6f 72 20 65 78 | 61 6d 70 6c 65 2c 20 74 | For ex|ample, t|
|00001cd0| 68 69 73 20 77 69 6c 6c | 20 70 72 6f 64 75 63 65 |his will| produce|
|00001ce0| 20 61 20 6c 69 6e 74 20 | 65 72 72 6f 72 3a 0a 58 | a lint |error:.X|
|00001cf0| 2e 49 50 0a 58 69 6e 74 | 20 2a 69 61 3b 0a 58 2e |.IP.Xint| *ia;.X.|
|00001d00| 62 72 0a 58 20 2e 2e 2e | 0a 58 2e 62 72 0a 58 69 |br.X ...|.X.br.Xi|
|00001d10| 66 20 28 4d 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |f (MALLO|C_LINTOK|
|00001d20| 28 69 61 2c 20 34 32 2c | 20 69 6e 74 29 20 3d 3d |(ia, 42,| int) ==|
|00001d30| 20 28 69 6e 74 20 2a 29 | 20 4e 55 4c 4c 29 0a 58 | (int *)| NULL).X|
|00001d40| 2e 62 72 0a 58 20 2e 2e | 2e 0a 58 2e 4c 50 0a 58 |.br.X ..|..X.LP.X|
|00001d50| 42 75 74 20 73 69 6e 63 | 65 20 75 6e 63 61 73 74 |But sinc|e uncast|
|00001d60| 20 30 20 28 69 2e 65 2e | 2c 20 4e 55 4c 4c 29 20 | 0 (i.e.|, NULL) |
|00001d70| 69 73 20 61 6c 77 61 79 | 73 20 61 20 76 61 6c 69 |is alway|s a vali|
|00001d80| 64 20 70 6f 69 6e 74 65 | 72 2c 20 69 74 0a 58 69 |d pointe|r, it.Xi|
|00001d90| 73 20 75 6e 6e 65 63 65 | 73 73 61 72 79 20 74 6f |s unnece|ssary to|
|00001da0| 20 63 61 73 74 20 69 74 | 20 74 6f 20 61 6e 79 74 | cast it| to anyt|
|00001db0| 68 69 6e 67 2e 0a 58 52 | 65 6d 6f 76 69 6e 67 20 |hing..XR|emoving |
|00001dc0| 74 68 65 20 63 61 73 74 | 20 73 74 6f 70 73 20 74 |the cast| stops t|
|00001dd0| 68 65 20 6c 69 6e 74 20 | 63 6f 6d 70 6c 61 69 6e |he lint |complain|
|00001de0| 74 3a 0a 58 2e 49 50 0a | 58 20 2e 2e 2e 0a 58 2e |t:.X.IP.|X ....X.|
|00001df0| 62 72 0a 58 69 66 20 28 | 4d 41 4c 4c 4f 43 5f 4c |br.Xif (|MALLOC_L|
|00001e00| 49 4e 54 4f 4b 28 69 61 | 2c 20 34 32 2c 20 69 6e |INTOK(ia|, 42, in|
|00001e10| 74 29 20 3d 3d 20 4e 55 | 4c 4c 29 0a 58 2e 62 72 |t) == NU|LL).X.br|
|00001e20| 0a 58 20 2e 2e 2e 0a 58 | 2e 4c 50 0a 58 49 66 20 |.X ....X|.LP.XIf |
|00001e30| 74 68 65 20 6d 61 63 72 | 6f 20 69 6e 76 6f 63 61 |the macr|o invoca|
|00001e40| 74 69 6f 6e 20 64 6f 65 | 73 6e 27 74 20 61 70 70 |tion doe|sn't app|
|00001e50| 65 61 72 20 77 69 74 68 | 69 6e 20 61 6e 20 65 78 |ear with|in an ex|
|00001e60| 70 72 65 73 73 69 6f 6e | 2c 0a 58 79 6f 75 20 77 |pression|,.Xyou w|
|00001e70| 69 6c 6c 20 6e 65 65 64 | 20 74 6f 20 63 61 73 74 |ill need| to cast|
|00001e80| 20 74 68 65 20 2a 41 4c | 4c 4f 43 5f 4c 49 4e 54 | the *AL|LOC_LINT|
|00001e90| 4f 4b 28 29 0a 58 69 6e | 76 6f 63 61 74 69 6f 6e |OK().Xin|vocation|
|00001ea0| 73 20 74 6f 0a 58 2e 42 | 20 76 6f 69 64 0a 58 69 |s to.X.B| void.Xi|
|00001eb0| 66 20 79 6f 75 20 77 61 | 6e 74 20 74 6f 20 67 65 |f you wa|nt to ge|
|00001ec0| 74 20 72 69 64 20 6f 66 | 20 74 68 65 0a 58 22 2a |t rid of| the.X"*|
|00001ed0| 61 6c 6c 6f 63 20 72 65 | 74 75 72 6e 73 20 76 61 |alloc re|turns va|
|00001ee0| 6c 75 65 20 77 68 69 63 | 68 20 69 73 20 73 6f 6d |lue whic|h is som|
|00001ef0| 65 74 69 6d 65 73 20 69 | 67 6e 6f 72 65 64 22 0a |etimes i|gnored".|
|00001f00| 58 61 6e 64 0a 58 22 2a | 61 6c 6c 6f 63 20 72 65 |Xand.X"*|alloc re|
|00001f10| 74 75 72 6e 73 20 76 61 | 6c 75 65 20 77 68 69 63 |turns va|lue whic|
|00001f20| 68 20 69 73 20 61 6c 77 | 61 79 73 20 69 67 6e 6f |h is alw|ays igno|
|00001f30| 72 65 64 22 0a 58 6d 65 | 73 73 61 67 65 73 2e 0a |red".Xme|ssages..|
|00001f40| 58 2e 4c 50 0a 58 59 6f | 75 20 63 61 6e 20 6d 69 |X.LP.XYo|u can mi|
|00001f50| 78 20 69 6e 76 6f 63 61 | 74 69 6f 6e 73 20 6f 66 |x invoca|tions of|
|00001f60| 20 74 68 65 73 65 20 6d | 61 63 72 6f 73 20 77 69 | these m|acros wi|
|00001f70| 74 68 20 63 61 6c 6c 73 | 20 74 6f 20 74 68 65 20 |th calls| to the |
|00001f80| 6f 72 69 67 69 6e 61 6c | 0a 58 66 75 6e 63 74 69 |original|.Xfuncti|
|00001f90| 6f 6e 73 2e 20 20 54 68 | 65 20 6f 6e 6c 79 20 64 |ons. Th|e only d|
|00001fa0| 69 66 66 65 72 65 6e 63 | 65 20 69 73 20 69 6e 20 |ifferenc|e is in |
|00001fb0| 74 68 65 20 6c 69 6e 74 | 20 62 65 68 61 76 69 6f |the lint| behavio|
|00001fc0| 72 2e 0a 58 2e 4c 50 0a | 58 41 20 63 6f 6d 6d 6f |r..X.LP.|XA commo|
|00001fd0| 6e 20 77 61 79 20 6f 66 | 20 69 6e 76 6f 6b 69 6e |n way of| invokin|
|00001fe0| 67 20 74 68 65 20 6d 65 | 6d 6f 72 79 20 6d 61 6e |g the me|mory man|
|00001ff0| 61 67 65 6d 65 6e 74 20 | 66 75 6e 63 74 69 6f 6e |agement |function|
|00002000| 73 20 69 73 20 74 6f 20 | 63 61 6c 6c 0a 58 2e 49 |s is to |call.X.I|
|00002010| 52 20 6d 61 6c 6c 6f 63 | 20 28 29 0a 58 69 66 20 |R malloc| ().Xif |
|00002020| 61 0a 58 70 6f 69 6e 74 | 65 72 20 69 73 20 4e 55 |a.Xpoint|er is NU|
|00002030| 4c 4c 20 28 75 73 75 61 | 6c 6c 79 20 74 68 65 20 |LL (usua|lly the |
|00002040| 66 69 72 73 74 20 74 69 | 6d 65 20 69 74 27 73 20 |first ti|me it's |
|00002050| 73 65 74 29 20 61 6e 64 | 0a 58 2e 49 52 20 72 65 |set) and|.X.IR re|
|00002060| 61 6c 6c 6f 63 20 28 29 | 0a 58 69 66 20 69 74 20 |alloc ()|.Xif it |
|00002070| 69 73 6e 27 74 20 4e 55 | 4c 4c 20 28 75 73 75 61 |isn't NU|LL (usua|
|00002080| 6c 6c 79 20 6f 6e 20 73 | 75 62 73 65 71 75 65 6e |lly on s|ubsequen|
|00002090| 74 20 74 69 6d 65 73 29 | 2e 20 20 54 68 65 20 73 |t times)|. The s|
|000020a0| 69 6d 70 6c 65 20 6d 61 | 63 72 6f 0a 58 2e 49 50 |imple ma|cro.X.IP|
|000020b0| 0a 58 4d 52 5f 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f |.XMR_ALL|OC_LINTO|
|000020c0| 4b 28 70 74 72 2c 20 6e | 65 6c 65 6d 2c 20 74 79 |K(ptr, n|elem, ty|
|000020d0| 70 65 29 0a 58 2e 4c 50 | 0a 58 64 6f 65 73 20 74 |pe).X.LP|.Xdoes t|
|000020e0| 68 69 73 20 77 69 74 68 | 20 4d 41 4c 4c 4f 43 5f |his with| MALLOC_|
|000020f0| 4c 49 4e 54 4f 4b 28 29 | 20 61 6e 64 20 52 45 41 |LINTOK()| and REA|
|00002100| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 28 29 2e 0a 58 |LLOC_LIN|TOK()..X|
|00002110| 2e 4c 50 0a 58 53 69 6e | 63 65 20 6d 65 6d 6f 72 |.LP.XSin|ce memor|
|00002120| 79 20 61 6c 6c 6f 63 61 | 74 69 6f 6e 20 66 61 69 |y alloca|tion fai|
|00002130| 6c 75 72 65 20 69 73 20 | 6f 66 74 65 6e 20 61 6e |lure is |often an|
|00002140| 20 65 78 63 65 70 74 69 | 6f 6e 61 6c 20 63 6f 6e | excepti|onal con|
|00002150| 64 69 74 69 6f 6e 2c 0a | 58 22 6d 65 6d 6c 69 6e |dition,.|X"memlin|
|00002160| 74 6f 6b 2e 68 22 20 61 | 6c 73 6f 20 68 61 73 20 |tok.h" a|lso has |
|00002170| 64 65 66 69 6e 69 74 69 | 6f 6e 73 20 6f 66 20 66 |definiti|ons of f|
|00002180| 6f 75 72 20 6f 74 68 65 | 72 20 75 73 65 66 75 6c |our othe|r useful|
|00002190| 20 6d 61 63 72 6f 73 20 | 74 68 61 74 20 69 6e 63 | macros |that inc|
|000021a0| 6c 75 64 65 0a 58 65 78 | 63 65 70 74 69 6f 6e 20 |lude.Xex|ception |
|000021b0| 68 61 6e 64 6c 69 6e 67 | 3a 0a 58 2e 49 50 0a 58 |handling|:.X.IP.X|
|000021c0| 43 41 4c 4c 4f 43 5f 4f | 52 5f 45 4c 53 45 5f 4c |CALLOC_O|R_ELSE_L|
|000021d0| 49 4e 54 4f 4b 28 70 74 | 72 2c 20 6e 65 6c 65 6d |INTOK(pt|r, nelem|
|000021e0| 2c 20 74 79 70 65 29 0a | 58 2e 62 72 0a 58 4d 41 |, type).|X.br.XMA|
|000021f0| 4c 4c 4f 43 5f 4f 52 5f | 45 4c 53 45 5f 4c 49 4e |LLOC_OR_|ELSE_LIN|
|00002200| 54 4f 4b 28 70 74 72 2c | 20 6e 65 6c 65 6d 2c 20 |TOK(ptr,| nelem, |
|00002210| 74 79 70 65 29 0a 58 2e | 62 72 0a 58 52 45 41 4c |type).X.|br.XREAL|
|00002220| 4c 4f 43 5f 4f 52 5f 45 | 4c 53 45 5f 4c 49 4e 54 |LOC_OR_E|LSE_LINT|
|00002230| 4f 4b 28 70 74 72 2c 20 | 6e 65 6c 65 6d 2c 20 74 |OK(ptr, |nelem, t|
|00002240| 79 70 65 29 0a 58 2e 62 | 72 0a 58 4d 52 5f 41 4c |ype).X.b|r.XMR_AL|
|00002250| 4c 4f 43 5f 4f 52 5f 45 | 4c 53 45 5f 4c 49 4e 54 |LOC_OR_E|LSE_LINT|
|00002260| 4f 4b 28 70 74 72 2c 20 | 6e 65 6c 65 6d 2c 20 74 |OK(ptr, |nelem, t|
|00002270| 79 70 65 29 0a 58 2e 62 | 72 0a 58 2e 4c 50 0a 58 |ype).X.b|r.X.LP.X|
|00002280| 45 61 63 68 20 6f 66 20 | 74 68 65 73 65 20 6d 61 |Each of |these ma|
|00002290| 63 72 6f 73 20 69 6e 76 | 6f 6b 65 73 20 74 68 65 |cros inv|okes the|
|000022a0| 20 63 6f 72 72 65 73 70 | 6f 6e 64 69 6e 67 20 2a | corresp|onding *|
|000022b0| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 28 29 20 6d |ALLOC_LI|NTOK() m|
|000022c0| 61 63 72 6f 20 61 6e 64 | 2c 0a 58 69 66 20 74 68 |acro and|,.Xif th|
|000022d0| 61 74 20 6d 61 63 72 6f | 20 66 61 69 6c 73 2c 20 |at macro| fails, |
|000022e0| 69 6e 76 6f 6b 65 73 20 | 61 6e 6f 74 68 65 72 20 |invokes |another |
|000022f0| 6d 61 63 72 6f 3a 0a 58 | 2e 49 50 0a 58 45 52 52 |macro:.X|.IP.XERR|
|00002300| 4f 52 5f 45 58 49 54 5f | 4c 49 4e 54 4f 4b 28 6e |OR_EXIT_|LINTOK(n|
|00002310| 65 6c 65 6d 2c 20 73 69 | 7a 65 29 0a 58 2e 4c 50 |elem, si|ze).X.LP|
|00002320| 0a 58 57 68 65 72 65 20 | 22 6e 65 6c 65 6d 22 20 |.XWhere |"nelem" |
|00002330| 69 73 20 74 68 65 20 6e | 75 6d 62 65 72 20 6f 66 |is the n|umber of|
|00002340| 20 65 6c 65 6d 65 6e 74 | 73 20 6f 66 20 22 73 69 | element|s of "si|
|00002350| 7a 65 22 20 62 79 74 65 | 73 20 61 74 74 65 6d 70 |ze" byte|s attemp|
|00002360| 74 69 6e 67 20 74 6f 20 | 62 65 0a 58 61 6c 6c 6f |ting to |be.Xallo|
|00002370| 63 61 74 65 64 2e 0a 58 | 2e 4c 50 0a 58 41 20 64 |cated..X|.LP.XA d|
|00002380| 65 66 61 75 6c 74 20 45 | 52 52 4f 52 5f 45 58 49 |efault E|RROR_EXI|
|00002390| 54 5f 4c 49 4e 54 4f 4b | 28 6e 65 6c 65 6d 2c 20 |T_LINTOK|(nelem, |
|000023a0| 73 69 7a 65 29 2c 20 77 | 68 69 63 68 20 70 72 69 |size), w|hich pri|
|000023b0| 6e 74 73 20 61 6e 20 69 | 6e 66 6f 72 6d 61 74 69 |nts an i|nformati|
|000023c0| 76 65 0a 58 6d 65 73 73 | 61 67 65 20 61 6e 64 20 |ve.Xmess|age and |
|000023d0| 64 69 65 73 2c 20 69 73 | 20 61 6c 73 6f 20 64 65 |dies, is| also de|
|000023e0| 66 69 6e 65 64 2c 20 62 | 75 74 20 79 6f 75 20 61 |fined, b|ut you a|
|000023f0| 72 65 20 66 72 65 65 20 | 74 6f 20 72 65 64 65 66 |re free |to redef|
|00002400| 69 6e 65 20 69 74 0a 58 | 28 61 66 74 65 72 20 69 |ine it.X|(after i|
|00002410| 6e 63 6c 75 64 69 6e 67 | 20 22 6d 65 6d 6c 69 6e |ncluding| "memlin|
|00002420| 74 6f 6b 2e 68 22 20 61 | 6e 64 20 62 65 66 6f 72 |tok.h" a|nd befor|
|00002430| 65 20 69 6e 76 6f 6b 69 | 6e 67 20 61 6e 79 20 6f |e invoki|ng any o|
|00002440| 66 20 74 68 65 20 6d 61 | 63 72 6f 73 20 68 65 72 |f the ma|cros her|
|00002450| 65 69 6e 0a 58 2d 2d 20 | 72 65 6d 65 6d 62 65 72 |ein.X-- |remember|
|00002460| 20 74 6f 20 22 23 75 6e | 64 65 66 20 45 52 52 4f | to "#un|def ERRO|
|00002470| 52 5f 45 58 49 54 5f 4c | 49 4e 54 4f 4b 22 20 66 |R_EXIT_L|INTOK" f|
|00002480| 69 72 73 74 29 0a 58 69 | 66 20 79 6f 75 20 77 61 |irst).Xi|f you wa|
|00002490| 6e 74 20 74 6f 20 64 6f | 20 79 6f 75 72 20 6f 77 |nt to do| your ow|
|000024a0| 6e 20 65 72 72 6f 72 20 | 68 61 6e 64 6c 69 6e 67 |n error |handling|
|000024b0| 2e 0a 58 2e 53 48 20 22 | 53 45 45 20 41 4c 53 4f |..X.SH "|SEE ALSO|
|000024c0| 22 0a 58 2e 42 52 20 6d | 61 6c 6c 6f 63 20 28 33 |".X.BR m|alloc (3|
|000024d0| 29 2c 0a 58 2e 42 52 20 | 73 74 64 69 6f 20 28 33 |),.X.BR |stdio (3|
|000024e0| 53 29 0a 58 2e 53 48 20 | 4e 4f 54 45 0a 58 2e 4c |S).X.SH |NOTE.X.L|
|000024f0| 50 0a 58 22 6d 65 6d 6c | 69 6e 74 6f 6b 2e 68 22 |P.X"meml|intok.h"|
|00002500| 20 61 73 73 75 6d 65 73 | 20 4e 55 4c 4c 20 69 73 | assumes| NULL is|
|00002510| 20 64 65 66 69 6e 65 64 | 20 69 6e 20 3c 73 74 64 | defined| in <std|
|00002520| 69 6f 2e 68 3e 20 28 77 | 68 69 63 68 20 69 73 20 |io.h> (w|hich is |
|00002530| 75 73 75 61 6c 6c 79 20 | 74 68 65 20 63 61 73 65 |usually |the case|
|00002540| 29 2e 0a 58 2e 4c 50 0a | 58 49 74 20 61 6c 73 6f |)..X.LP.|XIt also|
|00002550| 20 61 73 73 75 6d 65 73 | 20 74 68 65 20 63 70 70 | assumes| the cpp|
|00002560| 20 73 79 6d 62 6f 6c 20 | 22 6c 69 6e 74 22 20 69 | symbol |"lint" i|
|00002570| 73 20 64 65 66 69 6e 65 | 64 20 77 68 65 6e 20 61 |s define|d when a|
|00002580| 6e 64 20 6f 6e 6c 79 20 | 77 68 65 6e 20 74 68 65 |nd only |when the|
|00002590| 0a 58 63 6f 64 65 20 69 | 73 20 62 65 69 6e 67 20 |.Xcode i|s being |
|000025a0| 70 61 73 73 65 64 20 74 | 68 72 6f 75 67 68 20 6c |passed t|hrough l|
|000025b0| 69 6e 74 20 61 6e 64 20 | 6e 6f 74 20 67 65 6e 65 |int and |not gene|
|000025c0| 72 61 74 69 6e 67 20 72 | 65 61 6c 20 65 78 65 63 |rating r|eal exec|
|000025d0| 75 74 61 62 6c 65 20 63 | 6f 64 65 2e 0a 58 2e 4c |utable c|ode..X.L|
|000025e0| 50 0a 58 54 68 65 73 65 | 20 6d 61 63 72 6f 73 20 |P.XThese| macros |
|000025f0| 68 61 76 65 20 62 65 65 | 6e 20 74 65 73 74 65 64 |have bee|n tested|
|00002600| 20 75 6e 64 65 72 20 53 | 75 6e 4f 53 2c 20 48 50 | under S|unOS, HP|
|00002610| 2d 55 58 2c 20 61 6e 64 | 20 41 70 6f 6c 6c 6f 20 |-UX, and| Apollo |
|00002620| 44 4f 4d 41 49 4e 2f 49 | 58 2e 0a 58 2e 53 48 20 |DOMAIN/I|X..X.SH |
|00002630| 42 55 47 53 0a 58 2e 4c | 50 0a 58 54 68 65 73 65 |BUGS.X.L|P.XThese|
|00002640| 20 6d 61 63 72 6f 73 20 | 61 72 65 20 69 6e 74 65 | macros |are inte|
|00002650| 6e 64 65 64 20 66 6f 72 | 20 75 73 65 20 77 69 74 |nded for| use wit|
|00002660| 68 20 74 68 65 20 64 79 | 6e 61 6d 69 63 0a 58 61 |h the dy|namic.Xa|
|00002670| 6c 6c 6f 63 61 74 69 6f | 6e 20 6f 66 20 73 69 6e |llocatio|n of sin|
|00002680| 67 6c 65 20 65 6c 65 6d | 65 6e 74 73 20 6f 66 20 |gle elem|ents of |
|00002690| 66 69 78 65 64 20 73 69 | 7a 65 20 28 69 2e 65 2e |fixed si|ze (i.e.|
|000026a0| 20 73 74 72 75 63 74 73 | 20 6f 72 20 74 79 70 65 | structs| or type|
|000026b0| 64 65 66 73 29 0a 58 6f | 72 20 76 61 72 69 61 62 |defs).Xo|r variab|
|000026c0| 6c 79 2d 73 69 7a 65 64 | 20 61 72 72 61 79 73 20 |ly-sized| arrays |
|000026d0| 6f 66 20 73 61 6d 65 2e | 0a 58 49 6e 20 74 68 65 |of same.|.XIn the|
|000026e0| 20 61 75 74 68 6f 72 27 | 73 20 65 78 70 65 72 69 | author'|s experi|
|000026f0| 65 6e 63 65 2c 20 74 68 | 69 73 20 63 6f 76 65 72 |ence, th|is cover|
|00002700| 73 20 6d 6f 73 74 20 75 | 73 65 73 20 6f 66 20 74 |s most u|ses of t|
|00002710| 68 65 0a 58 2e 49 52 20 | 5c 66 49 2a 61 6c 6c 6f |he.X.IR |\fI*allo|
|00002720| 63 5c 66 50 20 28 33 29 | 0a 58 66 75 6e 63 74 69 |c\fP (3)|.Xfuncti|
|00002730| 6f 6e 73 2e 0a 58 54 68 | 65 20 6d 61 63 72 6f 73 |ons..XTh|e macros|
|00002740| 20 64 6f 20 6e 6f 74 20 | 77 6f 72 6b 20 77 65 6c | do not |work wel|
|00002750| 6c 2c 20 68 6f 77 65 76 | 65 72 2c 20 77 68 65 6e |l, howev|er, when|
|00002760| 20 63 72 65 61 74 69 6e | 67 20 76 61 72 69 61 62 | creatin|g variab|
|00002770| 6c 79 2d 73 69 7a 65 64 | 20 73 69 6e 67 6c 65 0a |ly-sized| single.|
|00002780| 58 73 74 72 75 63 74 75 | 72 65 73 20 74 68 61 74 |Xstructu|res that|
|00002790| 20 61 72 65 20 6e 6f 74 | 20 61 72 72 61 79 73 2e | are not| arrays.|
|000027a0| 0a 58 2e 4c 50 0a 58 41 | 74 20 6c 65 61 73 74 20 |.X.LP.XA|t least |
|000027b0| 6f 6e 65 20 76 65 72 73 | 69 6f 6e 20 6f 66 0a 58 |one vers|ion of.X|
|000027c0| 2e 49 52 20 6c 69 6e 74 | 20 28 31 29 0a 58 28 53 |.IR lint| (1).X(S|
|000027d0| 75 6e 4f 53 20 34 2e 30 | 29 20 63 6f 6d 70 6c 61 |unOS 4.0|) compla|
|000027e0| 69 6e 73 20 77 68 65 6e | 20 74 68 65 73 65 20 6d |ins when| these m|
|000027f0| 61 63 72 6f 73 0a 58 61 | 72 65 20 75 73 65 64 20 |acros.Xa|re used |
|00002800| 77 69 74 68 20 22 76 6f | 69 64 20 2a 22 20 70 6f |with "vo|id *" po|
|00002810| 69 6e 74 65 72 73 2e 0a | 58 49 74 20 6e 65 65 64 |inters..|XIt need|
|00002820| 6e 27 74 2e 0a 58 2e 4c | 50 0a 58 41 70 6f 6c 6c |n't..X.L|P.XApoll|
|00002830| 6f 20 44 4f 4d 41 49 4e | 2f 49 58 0a 58 2e 49 52 |o DOMAIN|/IX.X.IR|
|00002840| 20 6c 69 6e 74 20 28 31 | 29 0a 58 67 65 6e 65 72 | lint (1|).Xgener|
|00002850| 61 74 65 73 20 73 65 76 | 65 72 61 6c 20 62 6f 67 |ates sev|eral bog|
|00002860| 75 73 20 28 49 20 62 65 | 6c 69 65 76 65 29 20 63 |us (I be|lieve) c|
|00002870| 6f 6d 70 6c 61 69 6e 74 | 73 20 61 62 6f 75 74 20 |omplaint|s about |
|00002880| 74 68 65 20 64 65 66 61 | 75 6c 74 20 65 78 63 65 |the defa|ult exce|
|00002890| 70 74 69 6f 6e 0a 58 68 | 61 6e 64 6c 69 6e 67 20 |ption.Xh|andling |
|000028a0| 6d 61 63 72 6f 2e 0a 58 | 2e 53 48 20 41 55 54 48 |macro..X|.SH AUTH|
|000028b0| 4f 52 0a 58 2e 4c 50 0a | 58 42 6f 62 20 4c 65 77 |OR.X.LP.|XBob Lew|
|000028c0| 69 73 20 28 62 6f 62 6c | 40 74 65 73 73 69 2e 75 |is (bobl|@tessi.u|
|000028d0| 75 63 70 29 20 70 72 6f | 64 75 63 65 64 20 74 68 |ucp) pro|duced th|
|000028e0| 65 73 65 20 6d 61 63 72 | 6f 73 20 75 73 69 6e 67 |ese macr|os using|
|000028f0| 20 68 69 73 20 6f 77 6e | 0a 58 72 65 73 6f 75 72 | his own|.Xresour|
|00002900| 63 65 73 20 61 6e 64 20 | 68 65 72 65 62 79 20 72 |ces and |hereby r|
|00002910| 65 6c 65 61 73 65 73 20 | 74 68 65 6d 20 74 6f 20 |eleases |them to |
|00002920| 74 68 65 20 70 75 62 6c | 69 63 20 64 6f 6d 61 69 |the publ|ic domai|
|00002930| 6e 2e 0a 58 54 68 65 20 | 61 75 74 68 6f 72 20 77 |n..XThe |author w|
|00002940| 69 6c 6c 20 6e 6f 74 20 | 62 65 20 68 65 6c 64 20 |ill not |be held |
|00002950| 72 65 73 70 6f 6e 73 69 | 62 6c 65 20 66 6f 72 20 |responsi|ble for |
|00002960| 74 68 65 69 72 20 75 73 | 65 2c 20 6d 69 73 75 73 |their us|e, misus|
|00002970| 65 2c 0a 58 61 62 75 73 | 65 2c 20 6f 72 20 61 6e |e,.Xabus|e, or an|
|00002980| 79 20 64 61 6d 61 67 65 | 73 20 61 72 69 73 69 6e |y damage|s arisin|
|00002990| 67 20 66 72 6f 6d 20 73 | 61 6d 65 2e 0a 45 4e 44 |g from s|ame..END|
|000029a0| 5f 4f 46 5f 6d 65 6d 6c | 69 6e 74 6f 6b 2e 33 0a |_OF_meml|intok.3.|
|000029b0| 69 66 20 74 65 73 74 20 | 34 37 30 36 20 2d 6e 65 |if test |4706 -ne|
|000029c0| 20 60 77 63 20 2d 63 20 | 3c 6d 65 6d 6c 69 6e 74 | `wc -c |<memlint|
|000029d0| 6f 6b 2e 33 60 3b 20 74 | 68 65 6e 0a 20 20 20 20 |ok.3`; t|hen. |
|000029e0| 65 63 68 6f 20 73 68 61 | 72 3a 20 5c 22 6d 65 6d |echo sha|r: \"mem|
|000029f0| 6c 69 6e 74 6f 6b 2e 33 | 5c 22 20 75 6e 70 61 63 |lintok.3|\" unpac|
|00002a00| 6b 65 64 20 77 69 74 68 | 20 77 72 6f 6e 67 20 73 |ked with| wrong s|
|00002a10| 69 7a 65 21 0a 66 69 0a | 23 20 65 6e 64 20 6f 66 |ize!.fi.|# end of|
|00002a20| 20 6f 76 65 72 77 72 69 | 74 69 6e 67 20 63 68 65 | overwri|ting che|
|00002a30| 63 6b 0a 66 69 0a 69 66 | 20 74 65 73 74 20 2d 66 |ck.fi.if| test -f|
|00002a40| 20 6d 65 6d 6c 69 6e 74 | 6f 6b 2e 68 20 2d 61 20 | memlint|ok.h -a |
|00002a50| 22 24 7b 31 7d 22 20 21 | 3d 20 22 2d 63 22 20 3b |"${1}" !|= "-c" ;|
|00002a60| 20 74 68 65 6e 20 0a 20 | 20 65 63 68 6f 20 73 68 | then . | echo sh|
|00002a70| 61 72 3a 20 57 69 6c 6c | 20 6e 6f 74 20 6f 76 65 |ar: Will| not ove|
|00002a80| 72 2d 77 72 69 74 65 20 | 65 78 69 73 74 69 6e 67 |r-write |existing|
|00002a90| 20 66 69 6c 65 20 5c 22 | 6d 65 6d 6c 69 6e 74 6f | file \"|memlinto|
|00002aa0| 6b 2e 68 5c 22 0a 65 6c | 73 65 0a 65 63 68 6f 20 |k.h\".el|se.echo |
|00002ab0| 73 68 61 72 3a 20 45 78 | 74 72 61 63 74 69 6e 67 |shar: Ex|tracting|
|00002ac0| 20 5c 22 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 68 5c 22 | \"memli|ntok.h\"|
|00002ad0| 20 5c 28 32 39 38 36 20 | 63 68 61 72 61 63 74 65 | \(2986 |characte|
|00002ae0| 72 73 5c 29 0a 73 65 64 | 20 22 73 2f 5e 58 2f 2f |rs\).sed| "s/^X//|
|00002af0| 22 20 3e 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 68 20 3c |" >memli|ntok.h <|
|00002b00| 3c 27 45 4e 44 5f 4f 46 | 5f 6d 65 6d 6c 69 6e 74 |<'END_OF|_memlint|
|00002b10| 6f 6b 2e 68 27 0a 58 23 | 69 66 6e 64 65 66 20 49 |ok.h'.X#|ifndef I|
|00002b20| 4e 43 4c 55 44 45 44 5f | 4c 49 4e 54 4f 4b 0a 58 |NCLUDED_|LINTOK.X|
|00002b30| 0a 58 2f 2a 20 24 48 65 | 61 64 65 72 3a 20 6d 65 |.X/* $He|ader: me|
|00002b40| 6d 6c 69 6e 74 6f 6b 2e | 68 2c 76 20 31 2e 33 20 |mlintok.|h,v 1.3 |
|00002b50| 38 39 2f 30 35 2f 30 32 | 20 31 35 3a 30 31 3a 34 |89/05/02| 15:01:4|
|00002b60| 33 20 62 6f 62 6c 20 4c | 6f 63 6b 65 64 20 24 20 |3 bobl L|ocked $ |
|00002b70| 2a 2f 0a 58 0a 58 2f 2a | 0a 58 20 2a 09 54 68 65 |*/.X.X/*|.X *.The|
|00002b80| 73 65 20 64 65 66 69 6e | 69 74 69 6f 6e 73 20 73 |se defin|itions s|
|00002b90| 74 6f 70 20 6c 69 6e 74 | 20 66 72 6f 6d 20 63 6f |top lint| from co|
|00002ba0| 6d 70 6c 61 69 6e 69 6e | 67 20 61 62 6f 75 74 20 |mplainin|g about |
|00002bb0| 6d 61 6c 6c 6f 63 2c 20 | 63 61 6c 6c 6f 63 2c 0a |malloc, |calloc,.|
|00002bc0| 58 20 2a 09 72 65 61 6c | 6c 6f 63 2c 20 61 6e 64 |X *.real|loc, and|
|00002bd0| 20 66 72 65 65 20 77 68 | 69 6c 65 20 61 74 20 74 | free wh|ile at t|
|00002be0| 68 65 20 73 61 6d 65 20 | 74 69 6d 65 20 70 65 72 |he same |time per|
|00002bf0| 66 6f 72 6d 69 6e 67 20 | 63 68 65 63 6b 73 20 6f |forming |checks o|
|00002c00| 66 0a 58 20 2a 09 74 68 | 65 69 72 20 61 72 67 75 |f.X *.th|eir argu|
|00002c10| 6d 65 6e 74 73 2e 20 20 | 53 65 65 20 74 68 65 20 |ments. |See the |
|00002c20| 6d 65 6d 6c 69 6e 74 6f | 6b 28 33 29 20 6d 61 6e |memlinto|k(3) man|
|00002c30| 20 70 61 67 65 20 66 6f | 72 20 6d 6f 72 65 20 64 | page fo|r more d|
|00002c40| 65 74 61 69 6c 73 2e 0a | 58 20 2a 0a 58 20 2a 09 |etails..|X *.X *.|
|00002c50| 42 6f 62 20 4c 65 77 69 | 73 20 28 62 6f 62 6c 40 |Bob Lewi|s (bobl@|
|00002c60| 74 65 73 73 69 2e 75 75 | 63 70 29 20 70 72 6f 64 |tessi.uu|cp) prod|
|00002c70| 75 63 65 64 20 74 68 65 | 73 65 20 6d 61 63 72 6f |uced the|se macro|
|00002c80| 73 20 75 73 69 6e 67 20 | 68 69 73 20 6f 77 6e 0a |s using |his own.|
|00002c90| 58 20 2a 09 72 65 73 6f | 75 72 63 65 73 20 61 6e |X *.reso|urces an|
|00002ca0| 64 20 68 65 72 65 62 79 | 20 72 65 6c 65 61 73 65 |d hereby| release|
|00002cb0| 73 20 74 68 65 6d 20 74 | 6f 20 74 68 65 20 70 75 |s them t|o the pu|
|00002cc0| 62 6c 69 63 20 64 6f 6d | 61 69 6e 2e 0a 58 20 2a |blic dom|ain..X *|
|00002cd0| 09 54 68 65 20 61 75 74 | 68 6f 72 20 77 69 6c 6c |.The aut|hor will|
|00002ce0| 20 6e 6f 74 20 62 65 20 | 68 65 6c 64 20 72 65 73 | not be |held res|
|00002cf0| 70 6f 6e 73 69 62 6c 65 | 20 66 6f 72 20 74 68 65 |ponsible| for the|
|00002d00| 69 72 20 75 73 65 2c 20 | 6d 69 73 75 73 65 2c 0a |ir use, |misuse,.|
|00002d10| 58 20 2a 09 61 62 75 73 | 65 2c 20 6f 72 20 61 6e |X *.abus|e, or an|
|00002d20| 79 20 64 61 6d 61 67 65 | 73 20 61 72 69 73 69 6e |y damage|s arisin|
|00002d30| 67 20 66 72 6f 6d 20 73 | 61 6d 65 2e 0a 58 20 2a |g from s|ame..X *|
|00002d40| 2f 0a 58 0a 58 23 69 66 | 6e 64 65 66 20 4e 55 4c |/.X.X#if|ndef NUL|
|00002d50| 4c 0a 58 23 69 6e 63 6c | 75 64 65 20 3c 73 74 64 |L.X#incl|ude <std|
|00002d60| 69 6f 2e 68 3e 0a 58 23 | 65 6e 64 69 66 0a 58 0a |io.h>.X#|endif.X.|
|00002d70| 58 65 78 74 65 72 6e 20 | 63 68 61 72 20 2a 63 61 |Xextern |char *ca|
|00002d80| 6c 6c 6f 63 28 29 3b 0a | 58 23 69 66 64 65 66 20 |lloc();.|X#ifdef |
|00002d90| 6c 69 6e 74 0a 58 23 64 | 65 66 69 6e 65 20 43 41 |lint.X#d|efine CA|
|00002da0| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 28 70 74 72 2c |LLOC_LIN|TOK(ptr,|
|00002db0| 20 6e 65 6c 65 6d 2c 20 | 74 79 70 65 29 20 5c 0a | nelem, |type) \.|
|00002dc0| 58 09 63 61 6c 6c 6f 63 | 28 28 70 74 72 20 3d 20 |X.calloc|((ptr = |
|00002dd0| 28 74 79 70 65 20 2a 29 | 20 4e 55 4c 4c 2c 20 28 |(type *)| NULL, (|
|00002de0| 75 6e 73 69 67 6e 65 64 | 29 20 28 6e 65 6c 65 6d |unsigned|) (nelem|
|00002df0| 29 29 2c 20 28 75 6e 73 | 69 67 6e 65 64 29 20 73 |)), (uns|igned) s|
|00002e00| 69 7a 65 6f 66 28 74 79 | 70 65 29 29 0a 58 23 65 |izeof(ty|pe)).X#e|
|00002e10| 6c 73 65 0a 58 23 64 65 | 66 69 6e 65 20 43 41 4c |lse.X#de|fine CAL|
|00002e20| 4c 4f 43 5f 4c 49 4e 54 | 4f 4b 28 70 74 72 2c 20 |LOC_LINT|OK(ptr, |
|00002e30| 6e 65 6c 65 6d 2c 20 74 | 79 70 65 29 20 5c 0a 58 |nelem, t|ype) \.X|
|00002e40| 09 28 70 74 72 20 3d 20 | 28 74 79 70 65 20 2a 29 |.(ptr = |(type *)|
|00002e50| 20 63 61 6c 6c 6f 63 28 | 28 75 6e 73 69 67 6e 65 | calloc(|(unsigne|
|00002e60| 64 29 20 28 6e 65 6c 65 | 6d 29 2c 20 28 75 6e 73 |d) (nele|m), (uns|
|00002e70| 69 67 6e 65 64 29 20 73 | 69 7a 65 6f 66 28 74 79 |igned) s|izeof(ty|
|00002e80| 70 65 29 29 29 0a 58 23 | 65 6e 64 69 66 0a 58 0a |pe))).X#|endif.X.|
|00002e90| 58 65 78 74 65 72 6e 20 | 63 68 61 72 20 2a 6d 61 |Xextern |char *ma|
|00002ea0| 6c 6c 6f 63 28 29 3b 0a | 58 23 69 66 64 65 66 20 |lloc();.|X#ifdef |
|00002eb0| 6c 69 6e 74 0a 58 23 64 | 65 66 69 6e 65 20 4d 41 |lint.X#d|efine MA|
|00002ec0| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 28 70 74 72 2c |LLOC_LIN|TOK(ptr,|
|00002ed0| 20 6e 65 6c 65 6d 2c 20 | 74 79 70 65 29 20 5c 0a | nelem, |type) \.|
|00002ee0| 58 09 6d 61 6c 6c 6f 63 | 28 28 70 74 72 20 3d 20 |X.malloc|((ptr = |
|00002ef0| 28 74 79 70 65 20 2a 29 | 20 4e 55 4c 4c 2c 20 28 |(type *)| NULL, (|
|00002f00| 75 6e 73 69 67 6e 65 64 | 29 20 28 28 6e 65 6c 65 |unsigned|) ((nele|
|00002f10| 6d 29 20 2a 20 73 69 7a | 65 6f 66 28 74 79 70 65 |m) * siz|eof(type|
|00002f20| 29 29 29 29 0a 58 23 65 | 6c 73 65 0a 58 23 64 65 |)))).X#e|lse.X#de|
|00002f30| 66 69 6e 65 20 4d 41 4c | 4c 4f 43 5f 4c 49 4e 54 |fine MAL|LOC_LINT|
|00002f40| 4f 4b 28 70 74 72 2c 20 | 6e 65 6c 65 6d 2c 20 74 |OK(ptr, |nelem, t|
|00002f50| 79 70 65 29 20 5c 0a 58 | 09 28 70 74 72 20 3d 20 |ype) \.X|.(ptr = |
|00002f60| 28 74 79 70 65 20 2a 29 | 20 6d 61 6c 6c 6f 63 28 |(type *)| malloc(|
|00002f70| 28 75 6e 73 69 67 6e 65 | 64 29 20 28 28 6e 65 6c |(unsigne|d) ((nel|
|00002f80| 65 6d 29 20 2a 20 73 69 | 7a 65 6f 66 28 74 79 70 |em) * si|zeof(typ|
|00002f90| 65 29 29 29 29 0a 58 23 | 65 6e 64 69 66 0a 58 0a |e)))).X#|endif.X.|
|00002fa0| 58 65 78 74 65 72 6e 20 | 63 68 61 72 20 2a 72 65 |Xextern |char *re|
|00002fb0| 61 6c 6c 6f 63 28 29 3b | 0a 58 23 69 66 64 65 66 |alloc();|.X#ifdef|
|00002fc0| 20 6c 69 6e 74 0a 58 23 | 64 65 66 69 6e 65 20 52 | lint.X#|define R|
|00002fd0| 45 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 28 70 74 |EALLOC_L|INTOK(pt|
|00002fe0| 72 2c 20 6e 65 6c 65 6d | 2c 20 74 79 70 65 29 20 |r, nelem|, type) |
|00002ff0| 5c 0a 58 09 72 65 61 6c | 6c 6f 63 28 20 5c 0a 58 |\.X.real|loc( \.X|
|00003000| 09 09 28 70 74 72 20 3d | 20 28 74 79 70 65 20 2a |..(ptr =| (type *|
|00003010| 29 20 4e 55 4c 4c 2c 20 | 28 63 68 61 72 20 2a 29 |) NULL, |(char *)|
|00003020| 20 4e 55 4c 4c 29 2c 20 | 5c 0a 58 09 09 28 75 6e | NULL), |\.X..(un|
|00003030| 73 69 67 6e 65 64 29 20 | 28 28 6e 65 6c 65 6d 29 |signed) |((nelem)|
|00003040| 20 2a 20 73 69 7a 65 6f | 66 28 74 79 70 65 29 29 | * sizeo|f(type))|
|00003050| 29 0a 58 23 65 6c 73 65 | 0a 58 23 64 65 66 69 6e |).X#else|.X#defin|
|00003060| 65 20 52 45 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |e REALLO|C_LINTOK|
|00003070| 28 70 74 72 2c 20 6e 65 | 6c 65 6d 2c 20 74 79 70 |(ptr, ne|lem, typ|
|00003080| 65 29 20 5c 0a 58 09 28 | 70 74 72 20 3d 20 28 74 |e) \.X.(|ptr = (t|
|00003090| 79 70 65 20 2a 29 20 72 | 65 61 6c 6c 6f 63 28 20 |ype *) r|ealloc( |
|000030a0| 5c 0a 58 09 09 28 63 68 | 61 72 20 2a 29 20 70 74 |\.X..(ch|ar *) pt|
|000030b0| 72 2c 20 5c 0a 58 09 09 | 28 75 6e 73 69 67 6e 65 |r, \.X..|(unsigne|
|000030c0| 64 29 20 28 28 6e 65 6c | 65 6d 29 20 2a 20 73 69 |d) ((nel|em) * si|
|000030d0| 7a 65 6f 66 28 74 79 70 | 65 29 29 29 29 0a 58 23 |zeof(typ|e)))).X#|
|000030e0| 65 6e 64 69 66 0a 58 0a | 58 2f 2a 20 63 6f 6d 6d |endif.X.|X/* comm|
|000030f0| 6f 6e 20 75 73 65 20 6f | 66 20 6d 61 6c 6c 6f 63 |on use o|f malloc|
|00003100| 2f 72 65 61 6c 6c 6f 63 | 20 2d 2d 20 75 73 65 20 |/realloc| -- use |
|00003110| 69 74 20 6f 72 20 64 6f | 6e 27 74 20 75 73 65 20 |it or do|n't use |
|00003120| 69 74 20 2a 2f 0a 58 23 | 64 65 66 69 6e 65 20 4d |it */.X#|define M|
|00003130| 52 5f 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 28 70 |R_ALLOC_|LINTOK(p|
|00003140| 74 72 2c 20 6e 65 6c 65 | 6d 2c 20 74 79 70 65 29 |tr, nele|m, type)|
|00003150| 20 5c 0a 58 09 28 20 28 | 70 74 72 29 20 3d 3d 20 | \.X.( (|ptr) == |
|00003160| 4e 55 4c 4c 20 5c 0a 58 | 09 09 3f 20 4d 41 4c 4c |NULL \.X|..? MALL|
|00003170| 4f 43 5f 4c 49 4e 54 4f | 4b 28 70 74 72 2c 20 28 |OC_LINTO|K(ptr, (|
|00003180| 6e 65 6c 65 6d 29 2c 20 | 74 79 70 65 29 20 5c 0a |nelem), |type) \.|
|00003190| 58 09 09 3a 20 52 45 41 | 4c 4c 4f 43 5f 4c 49 4e |X..: REA|LLOC_LIN|
|000031a0| 54 4f 4b 28 70 74 72 2c | 20 28 6e 65 6c 65 6d 29 |TOK(ptr,| (nelem)|
|000031b0| 2c 20 74 79 70 65 29 20 | 29 0a 58 0a 58 2f 2a 0a |, type) |).X.X/*.|
|000031c0| 58 20 2a 09 54 68 65 73 | 65 20 6e 65 78 74 20 6d |X *.Thes|e next m|
|000031d0| 61 63 72 6f 73 20 69 6e | 76 6f 6b 65 20 43 41 4c |acros in|voke CAL|
|000031e0| 4c 4f 43 5f 4c 49 4e 54 | 4f 4b 2c 20 4d 41 4c 4c |LOC_LINT|OK, MALL|
|000031f0| 4f 43 5f 4c 49 4e 54 4f | 4b 2c 20 52 45 41 4c 4c |OC_LINTO|K, REALL|
|00003200| 4f 43 5f 4c 49 4e 54 4f | 4b 2c 0a 58 20 2a 09 61 |OC_LINTO|K,.X *.a|
|00003210| 6e 64 20 4d 52 5f 41 4c | 4c 4f 43 5f 4c 49 4e 54 |nd MR_AL|LOC_LINT|
|00003220| 4f 4b 20 77 69 74 68 20 | 61 6e 20 65 72 72 6f 72 |OK with |an error|
|00003230| 20 65 78 69 74 20 69 66 | 20 74 68 65 79 20 66 61 | exit if| they fa|
|00003240| 69 6c 2e 0a 58 20 2a 0a | 58 20 2a 09 49 66 20 79 |il..X *.|X *.If y|
|00003250| 6f 75 20 77 61 6e 74 20 | 74 6f 20 68 61 6e 64 6c |ou want |to handl|
|00003260| 65 20 79 6f 75 72 20 6f | 77 6e 20 6d 65 6d 6f 72 |e your o|wn memor|
|00003270| 79 20 61 6c 6c 6f 63 61 | 74 69 6f 6e 20 65 72 72 |y alloca|tion err|
|00003280| 6f 72 73 2c 20 6a 75 73 | 74 0a 58 20 2a 09 22 23 |ors, jus|t.X *."#|
|00003290| 75 6e 64 65 66 20 45 52 | 52 4f 52 5f 45 58 49 54 |undef ER|ROR_EXIT|
|000032a0| 5f 4c 49 4e 54 4f 4b 22 | 20 61 6e 64 20 64 65 66 |_LINTOK"| and def|
|000032b0| 69 6e 65 20 79 6f 75 72 | 20 6f 77 6e 2e 0a 58 20 |ine your| own..X |
|000032c0| 2a 2f 0a 58 23 64 65 66 | 69 6e 65 20 45 52 52 4f |*/.X#def|ine ERRO|
|000032d0| 52 5f 45 58 49 54 5f 4c | 49 4e 54 4f 4b 28 6e 65 |R_EXIT_L|INTOK(ne|
|000032e0| 6c 65 6d 2c 20 73 69 7a | 65 29 20 5c 0a 58 09 7b |lem, siz|e) \.X.{|
|000032f0| 20 5c 0a 58 09 09 28 76 | 6f 69 64 29 20 66 70 72 | \.X..(v|oid) fpr|
|00003300| 69 6e 74 66 28 73 74 64 | 65 72 72 2c 20 5c 0a 58 |intf(std|err, \.X|
|00003310| 09 09 09 22 4d 65 6d 6f | 72 79 20 61 6c 6c 6f 63 |..."Memo|ry alloc|
|00003320| 61 74 69 6f 6e 20 6f 66 | 20 25 64 20 2a 20 25 64 |ation of| %d * %d|
|00003330| 20 62 79 74 65 73 20 6f | 6e 20 6c 69 6e 65 20 25 | bytes o|n line %|
|00003340| 64 20 6f 66 20 5c 22 25 | 73 5c 22 20 66 61 69 6c |d of \"%|s\" fail|
|00003350| 65 64 2e 5c 6e 22 2c 20 | 5c 0a 58 09 09 09 28 6e |ed.\n", |\.X...(n|
|00003360| 65 6c 65 6d 29 2c 20 28 | 73 69 7a 65 29 2c 20 5f |elem), (|size), _|
|00003370| 5f 4c 49 4e 45 5f 5f 2c | 20 5f 5f 46 49 4c 45 5f |_LINE__,| __FILE_|
|00003380| 5f 29 3b 20 5c 0a 58 09 | 09 65 78 69 74 28 31 29 |_); \.X.|.exit(1)|
|00003390| 3b 20 5c 0a 58 09 7d 0a | 58 0a 58 23 64 65 66 69 |; \.X.}.|X.X#defi|
|000033a0| 6e 65 20 43 41 4c 4c 4f | 43 5f 4f 52 5f 45 4c 53 |ne CALLO|C_OR_ELS|
|000033b0| 45 5f 4c 49 4e 54 4f 4b | 28 70 74 72 2c 20 6e 65 |E_LINTOK|(ptr, ne|
|000033c0| 6c 65 6d 2c 20 74 79 70 | 65 29 20 5c 0a 58 09 7b |lem, typ|e) \.X.{|
|000033d0| 20 5c 0a 58 09 09 69 66 | 20 28 43 41 4c 4c 4f 43 | \.X..if| (CALLOC|
|000033e0| 5f 4c 49 4e 54 4f 4b 28 | 70 74 72 2c 20 28 6e 65 |_LINTOK(|ptr, (ne|
|000033f0| 6c 65 6d 29 2c 20 74 79 | 70 65 29 20 3d 3d 20 4e |lem), ty|pe) == N|
|00003400| 55 4c 4c 29 20 5c 0a 58 | 09 09 09 45 52 52 4f 52 |ULL) \.X|...ERROR|
|00003410| 5f 45 58 49 54 5f 4c 49 | 4e 54 4f 4b 28 28 6e 65 |_EXIT_LI|NTOK((ne|
|00003420| 6c 65 6d 29 2c 20 73 69 | 7a 65 6f 66 28 74 79 70 |lem), si|zeof(typ|
|00003430| 65 29 29 3b 20 5c 0a 58 | 09 7d 0a 58 0a 58 23 64 |e)); \.X|.}.X.X#d|
|00003440| 65 66 69 6e 65 20 4d 41 | 4c 4c 4f 43 5f 4f 52 5f |efine MA|LLOC_OR_|
|00003450| 45 4c 53 45 5f 4c 49 4e | 54 4f 4b 28 70 74 72 2c |ELSE_LIN|TOK(ptr,|
|00003460| 20 6e 65 6c 65 6d 2c 20 | 74 79 70 65 29 20 5c 0a | nelem, |type) \.|
|00003470| 58 09 7b 20 5c 0a 58 09 | 09 69 66 20 28 4d 41 4c |X.{ \.X.|.if (MAL|
|00003480| 4c 4f 43 5f 4c 49 4e 54 | 4f 4b 28 70 74 72 2c 20 |LOC_LINT|OK(ptr, |
|00003490| 28 6e 65 6c 65 6d 29 2c | 20 74 79 70 65 29 20 3d |(nelem),| type) =|
|000034a0| 3d 20 4e 55 4c 4c 29 20 | 5c 0a 58 09 09 09 45 52 |= NULL) |\.X...ER|
|000034b0| 52 4f 52 5f 45 58 49 54 | 5f 4c 49 4e 54 4f 4b 28 |ROR_EXIT|_LINTOK(|
|000034c0| 28 6e 65 6c 65 6d 29 2c | 20 73 69 7a 65 6f 66 28 |(nelem),| sizeof(|
|000034d0| 74 79 70 65 29 29 3b 20 | 5c 0a 58 09 7d 0a 58 0a |type)); |\.X.}.X.|
|000034e0| 58 23 64 65 66 69 6e 65 | 20 52 45 41 4c 4c 4f 43 |X#define| REALLOC|
|000034f0| 5f 4f 52 5f 45 4c 53 45 | 5f 4c 49 4e 54 4f 4b 28 |_OR_ELSE|_LINTOK(|
|00003500| 70 74 72 2c 20 6e 65 6c | 65 6d 2c 20 74 79 70 65 |ptr, nel|em, type|
|00003510| 29 20 5c 0a 58 09 7b 20 | 5c 0a 58 09 09 69 66 20 |) \.X.{ |\.X..if |
|00003520| 28 52 45 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 |(REALLOC|_LINTOK(|
|00003530| 70 74 72 2c 20 28 6e 65 | 6c 65 6d 29 2c 20 74 79 |ptr, (ne|lem), ty|
|00003540| 70 65 29 20 3d 3d 20 4e | 55 4c 4c 29 20 5c 0a 58 |pe) == N|ULL) \.X|
|00003550| 09 09 09 45 52 52 4f 52 | 5f 45 58 49 54 5f 4c 49 |...ERROR|_EXIT_LI|
|00003560| 4e 54 4f 4b 28 28 6e 65 | 6c 65 6d 29 2c 20 73 69 |NTOK((ne|lem), si|
|00003570| 7a 65 6f 66 28 74 79 70 | 65 29 29 3b 20 5c 0a 58 |zeof(typ|e)); \.X|
|00003580| 09 7d 0a 58 0a 58 23 64 | 65 66 69 6e 65 20 4d 52 |.}.X.X#d|efine MR|
|00003590| 5f 41 4c 4c 4f 43 5f 4f | 52 5f 45 4c 53 45 5f 4c |_ALLOC_O|R_ELSE_L|
|000035a0| 49 4e 54 4f 4b 28 70 74 | 72 2c 20 6e 65 6c 65 6d |INTOK(pt|r, nelem|
|000035b0| 2c 20 74 79 70 65 29 20 | 5c 0a 58 09 7b 20 5c 0a |, type) |\.X.{ \.|
|000035c0| 58 09 09 69 66 20 28 4d | 52 5f 41 4c 4c 4f 43 5f |X..if (M|R_ALLOC_|
|000035d0| 4c 49 4e 54 4f 4b 28 70 | 74 72 2c 20 28 6e 65 6c |LINTOK(p|tr, (nel|
|000035e0| 65 6d 29 2c 20 74 79 70 | 65 29 20 3d 3d 20 4e 55 |em), typ|e) == NU|
|000035f0| 4c 4c 29 20 5c 0a 58 09 | 09 09 45 52 52 4f 52 5f |LL) \.X.|..ERROR_|
|00003600| 45 58 49 54 5f 4c 49 4e | 54 4f 4b 28 28 6e 65 6c |EXIT_LIN|TOK((nel|
|00003610| 65 6d 29 2c 20 73 69 7a | 65 6f 66 28 74 79 70 65 |em), siz|eof(type|
|00003620| 29 29 3b 20 5c 0a 58 09 | 7d 0a 58 0a 58 65 78 74 |)); \.X.|}.X.Xext|
|00003630| 65 72 6e 20 66 72 65 65 | 28 29 3b 0a 58 23 69 66 |ern free|();.X#if|
|00003640| 64 65 66 20 6c 69 6e 74 | 0a 58 23 64 65 66 69 6e |def lint|.X#defin|
|00003650| 65 20 46 52 45 45 5f 4c | 49 4e 54 4f 4b 28 70 74 |e FREE_L|INTOK(pt|
|00003660| 72 29 20 5c 0a 58 09 66 | 72 65 65 28 28 70 74 72 |r) \.X.f|ree((ptr|
|00003670| 20 3d 20 4e 55 4c 4c 2c | 20 28 63 68 61 72 20 2a | = NULL,| (char *|
|00003680| 29 20 4e 55 4c 4c 29 29 | 0a 58 23 65 6c 73 65 0a |) NULL))|.X#else.|
|00003690| 58 23 64 65 66 69 6e 65 | 20 46 52 45 45 5f 4c 49 |X#define| FREE_LI|
|000036a0| 4e 54 4f 4b 28 70 74 72 | 29 20 5c 0a 58 09 66 72 |NTOK(ptr|) \.X.fr|
|000036b0| 65 65 28 28 63 68 61 72 | 20 2a 29 20 70 74 72 29 |ee((char| *) ptr)|
|000036c0| 0a 58 23 65 6e 64 69 66 | 0a 58 0a 58 2f 2a 20 57 |.X#endif|.X.X/* W|
|000036d0| 65 20 63 6f 75 6c 64 20 | 68 61 76 65 20 61 20 22 |e could |have a "|
|000036e0| 43 46 52 45 45 5f 4c 49 | 4e 54 4f 4b 22 2c 20 62 |CFREE_LI|NTOK", b|
|000036f0| 75 74 20 77 68 61 74 27 | 73 20 74 68 65 20 70 6f |ut what'|s the po|
|00003700| 69 6e 74 3f 20 2a 2f 0a | 58 0a 58 23 64 65 66 69 |int? */.|X.X#defi|
|00003710| 6e 65 20 49 4e 43 4c 55 | 44 45 44 5f 4c 49 4e 54 |ne INCLU|DED_LINT|
|00003720| 4f 4b 0a 58 23 65 6e 64 | 69 66 0a 58 0a 45 4e 44 |OK.X#end|if.X.END|
|00003730| 5f 4f 46 5f 6d 65 6d 6c | 69 6e 74 6f 6b 2e 68 0a |_OF_meml|intok.h.|
|00003740| 69 66 20 74 65 73 74 20 | 32 39 38 36 20 2d 6e 65 |if test |2986 -ne|
|00003750| 20 60 77 63 20 2d 63 20 | 3c 6d 65 6d 6c 69 6e 74 | `wc -c |<memlint|
|00003760| 6f 6b 2e 68 60 3b 20 74 | 68 65 6e 0a 20 20 20 20 |ok.h`; t|hen. |
|00003770| 65 63 68 6f 20 73 68 61 | 72 3a 20 5c 22 6d 65 6d |echo sha|r: \"mem|
|00003780| 6c 69 6e 74 6f 6b 2e 68 | 5c 22 20 75 6e 70 61 63 |lintok.h|\" unpac|
|00003790| 6b 65 64 20 77 69 74 68 | 20 77 72 6f 6e 67 20 73 |ked with| wrong s|
|000037a0| 69 7a 65 21 0a 66 69 0a | 23 20 65 6e 64 20 6f 66 |ize!.fi.|# end of|
|000037b0| 20 6f 76 65 72 77 72 69 | 74 69 6e 67 20 63 68 65 | overwri|ting che|
|000037c0| 63 6b 0a 66 69 0a 69 66 | 20 74 65 73 74 20 2d 66 |ck.fi.if| test -f|
|000037d0| 20 74 5f 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 63 20 2d | t_memli|ntok.c -|
|000037e0| 61 20 22 24 7b 31 7d 22 | 20 21 3d 20 22 2d 63 22 |a "${1}"| != "-c"|
|000037f0| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|00003800| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 6f |shar: Wi|ll not o|
|00003810| 76 65 72 2d 77 72 69 74 | 65 20 65 78 69 73 74 69 |ver-writ|e existi|
|00003820| 6e 67 20 66 69 6c 65 20 | 5c 22 74 5f 6d 65 6d 6c |ng file |\"t_meml|
|00003830| 69 6e 74 6f 6b 2e 63 5c | 22 0a 65 6c 73 65 0a 65 |intok.c\|".else.e|
|00003840| 63 68 6f 20 73 68 61 72 | 3a 20 45 78 74 72 61 63 |cho shar|: Extrac|
|00003850| 74 69 6e 67 20 5c 22 74 | 5f 6d 65 6d 6c 69 6e 74 |ting \"t|_memlint|
|00003860| 6f 6b 2e 63 5c 22 20 5c | 28 31 34 33 38 20 63 68 |ok.c\" \|(1438 ch|
|00003870| 61 72 61 63 74 65 72 73 | 5c 29 0a 73 65 64 20 22 |aracters|\).sed "|
|00003880| 73 2f 5e 58 2f 2f 22 20 | 3e 74 5f 6d 65 6d 6c 69 |s/^X//" |>t_memli|
|00003890| 6e 74 6f 6b 2e 63 20 3c | 3c 27 45 4e 44 5f 4f 46 |ntok.c <|<'END_OF|
|000038a0| 5f 74 5f 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 63 27 0a |_t_memli|ntok.c'.|
|000038b0| 58 2f 2a 20 24 48 65 61 | 64 65 72 3a 20 74 5f 6d |X/* $Hea|der: t_m|
|000038c0| 65 6d 6c 69 6e 74 6f 6b | 2e 63 2c 76 20 31 2e 33 |emlintok|.c,v 1.3|
|000038d0| 20 38 39 2f 30 35 2f 30 | 32 20 31 35 3a 30 37 3a | 89/05/0|2 15:07:|
|000038e0| 30 38 20 62 6f 62 6c 20 | 45 78 70 20 24 20 2a 2f |08 bobl |Exp $ */|
|000038f0| 0a 58 0a 58 23 69 6e 63 | 6c 75 64 65 20 3c 73 74 |.X.X#inc|lude <st|
|00003900| 64 69 6f 2e 68 3e 0a 58 | 0a 58 23 69 6e 63 6c 75 |dio.h>.X|.X#inclu|
|00003910| 64 65 20 22 6d 65 6d 6c | 69 6e 74 6f 6b 2e 68 22 |de "meml|intok.h"|
|00003920| 0a 58 0a 58 6d 61 69 6e | 28 29 0a 58 7b 0a 58 09 |.X.Xmain|().X{.X.|
|00003930| 69 6e 74 20 2a 70 2c 20 | 2a 71 3b 0a 58 0a 58 09 |int *p, |*q;.X.X.|
|00003940| 69 66 20 28 4d 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f |if (MALL|OC_LINTO|
|00003950| 4b 28 70 2c 20 31 30 30 | 2c 20 69 6e 74 29 20 3d |K(p, 100|, int) =|
|00003960| 3d 20 4e 55 4c 4c 29 0a | 58 09 09 66 61 69 6c 28 |= NULL).|X..fail(|
|00003970| 22 63 61 6e 27 74 20 6d | 61 6c 6c 6f 63 20 31 30 |"can't m|alloc 10|
|00003980| 30 20 69 6e 74 73 5c 6e | 22 29 3b 0a 58 09 65 6c |0 ints\n|");.X.el|
|00003990| 73 65 0a 58 09 09 73 75 | 63 63 65 65 64 28 22 31 |se.X..su|cceed("1|
|000039a0| 30 30 20 69 6e 74 73 20 | 6d 61 6c 6c 6f 63 27 64 |00 ints |malloc'd|
|000039b0| 5c 6e 22 29 3b 0a 58 0a | 58 09 28 76 6f 69 64 29 |\n");.X.|X.(void)|
|000039c0| 20 52 45 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 | REALLOC|_LINTOK(|
|000039d0| 70 2c 20 32 30 30 2c 20 | 69 6e 74 29 3b 0a 58 09 |p, 200, |int);.X.|
|000039e0| 69 66 20 28 70 20 3d 3d | 20 4e 55 4c 4c 29 0a 58 |if (p ==| NULL).X|
|000039f0| 09 09 66 61 69 6c 28 22 | 63 61 6e 27 74 20 72 65 |..fail("|can't re|
|00003a00| 61 6c 6c 6f 63 20 32 30 | 30 20 69 6e 74 73 5c 6e |alloc 20|0 ints\n|
|00003a10| 22 29 3b 0a 58 09 65 6c | 73 65 0a 58 09 09 73 75 |");.X.el|se.X..su|
|00003a20| 63 63 65 65 64 28 22 32 | 30 30 20 69 6e 74 73 20 |cceed("2|00 ints |
|00003a30| 72 65 61 6c 6c 6f 63 27 | 64 5c 6e 22 29 3b 0a 58 |realloc'|d\n");.X|
|00003a40| 0a 58 09 69 66 20 28 4d | 52 5f 41 4c 4c 4f 43 5f |.X.if (M|R_ALLOC_|
|00003a50| 4c 49 4e 54 4f 4b 28 70 | 2c 20 32 35 2c 20 69 6e |LINTOK(p|, 25, in|
|00003a60| 74 29 20 3d 3d 20 4e 55 | 4c 4c 29 0a 58 09 09 66 |t) == NU|LL).X..f|
|00003a70| 61 69 6c 28 22 63 61 6e | 27 74 20 6d 72 5f 61 6c |ail("can|'t mr_al|
|00003a80| 6c 6f 63 20 28 72 65 61 | 6c 6c 6f 63 29 20 32 35 |loc (rea|lloc) 25|
|00003a90| 20 69 6e 74 73 5c 6e 22 | 29 3b 0a 58 09 65 6c 73 | ints\n"|);.X.els|
|00003aa0| 65 0a 58 09 09 73 75 63 | 63 65 65 64 28 22 32 35 |e.X..suc|ceed("25|
|00003ab0| 20 69 6e 74 73 20 6d 72 | 5f 61 6c 6c 6f 63 27 64 | ints mr|_alloc'd|
|00003ac0| 20 28 72 65 61 6c 6c 6f | 63 27 64 29 5c 6e 22 29 | (reallo|c'd)\n")|
|00003ad0| 3b 0a 58 0a 58 09 69 66 | 20 28 43 41 4c 4c 4f 43 |;.X.X.if| (CALLOC|
|00003ae0| 5f 4c 49 4e 54 4f 4b 28 | 71 2c 20 35 30 30 2c 20 |_LINTOK(|q, 500, |
|00003af0| 69 6e 74 29 20 3d 3d 20 | 4e 55 4c 4c 29 0a 58 09 |int) == |NULL).X.|
|00003b00| 09 66 61 69 6c 28 22 63 | 61 6e 27 74 20 63 61 6c |.fail("c|an't cal|
|00003b10| 6c 6f 63 20 35 30 30 20 | 69 6e 74 73 5c 6e 22 29 |loc 500 |ints\n")|
|00003b20| 3b 0a 58 09 65 6c 73 65 | 0a 58 09 09 73 75 63 63 |;.X.else|.X..succ|
|00003b30| 65 65 64 28 22 35 30 30 | 20 69 6e 74 73 20 63 61 |eed("500| ints ca|
|00003b40| 6c 6c 6f 63 27 64 5c 6e | 22 29 3b 0a 58 09 71 5b |lloc'd\n|");.X.q[|
|00003b50| 30 5d 20 3d 20 30 3b 0a | 58 09 46 52 45 45 5f 4c |0] = 0;.|X.FREE_L|
|00003b60| 49 4e 54 4f 4b 28 71 29 | 3b 0a 58 0a 58 09 46 52 |INTOK(q)|;.X.X.FR|
|00003b70| 45 45 5f 4c 49 4e 54 4f | 4b 28 70 29 3b 0a 58 09 |EE_LINTO|K(p);.X.|
|00003b80| 70 20 3d 20 4e 55 4c 4c | 3b 0a 58 09 69 66 20 28 |p = NULL|;.X.if (|
|00003b90| 4d 52 5f 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 |MR_ALLOC|_LINTOK(|
|00003ba0| 70 2c 20 31 30 30 30 2c | 20 69 6e 74 29 20 3d 3d |p, 1000,| int) ==|
|00003bb0| 20 4e 55 4c 4c 29 0a 58 | 09 09 66 61 69 6c 28 22 | NULL).X|..fail("|
|00003bc0| 63 61 6e 27 74 20 6d 72 | 5f 61 6c 6c 6f 63 20 28 |can't mr|_alloc (|
|00003bd0| 6d 61 6c 6c 6f 63 29 20 | 31 30 30 30 20 69 6e 74 |malloc) |1000 int|
|00003be0| 73 5c 6e 22 29 3b 0a 58 | 09 65 6c 73 65 0a 58 09 |s\n");.X|.else.X.|
|00003bf0| 09 73 75 63 63 65 65 64 | 28 22 31 30 30 30 20 69 |.succeed|("1000 i|
|00003c00| 6e 74 73 20 6d 72 5f 61 | 6c 6c 6f 63 27 64 20 28 |nts mr_a|lloc'd (|
|00003c10| 6d 61 6c 6c 6f 63 27 64 | 29 5c 6e 22 29 3b 0a 58 |malloc'd|)\n");.X|
|00003c20| 0a 58 09 43 41 4c 4c 4f | 43 5f 4f 52 5f 45 4c 53 |.X.CALLO|C_OR_ELS|
|00003c30| 45 5f 4c 49 4e 54 4f 4b | 28 70 2c 20 35 30 2c 20 |E_LINTOK|(p, 50, |
|00003c40| 69 6e 74 29 3b 0a 58 09 | 73 75 63 63 65 65 64 28 |int);.X.|succeed(|
|00003c50| 22 35 30 20 69 6e 74 73 | 20 63 61 6c 6c 6f 63 27 |"50 ints| calloc'|
|00003c60| 64 20 28 6f 72 20 65 6c | 73 65 29 5c 6e 22 29 3b |d (or el|se)\n");|
|00003c70| 0a 58 09 4d 41 4c 4c 4f | 43 5f 4f 52 5f 45 4c 53 |.X.MALLO|C_OR_ELS|
|00003c80| 45 5f 4c 49 4e 54 4f 4b | 28 70 2c 20 31 30 30 2c |E_LINTOK|(p, 100,|
|00003c90| 20 69 6e 74 29 3b 0a 58 | 09 73 75 63 63 65 65 64 | int);.X|.succeed|
|00003ca0| 28 22 31 30 30 20 69 6e | 74 73 20 6d 61 6c 6c 6f |("100 in|ts mallo|
|00003cb0| 63 27 64 20 28 6f 72 20 | 65 6c 73 65 29 5c 6e 22 |c'd (or |else)\n"|
|00003cc0| 29 3b 0a 58 09 52 45 41 | 4c 4c 4f 43 5f 4f 52 5f |);.X.REA|LLOC_OR_|
|00003cd0| 45 4c 53 45 5f 4c 49 4e | 54 4f 4b 28 70 2c 20 32 |ELSE_LIN|TOK(p, 2|
|00003ce0| 30 30 2c 20 69 6e 74 29 | 3b 0a 58 09 73 75 63 63 |00, int)|;.X.succ|
|00003cf0| 65 65 64 28 22 32 30 30 | 20 69 6e 74 73 20 72 65 |eed("200| ints re|
|00003d00| 61 6c 6c 6f 63 27 64 20 | 28 6f 72 20 65 6c 73 65 |alloc'd |(or else|
|00003d10| 29 5c 6e 22 29 3b 0a 58 | 0a 58 23 75 6e 64 65 66 |)\n");.X|.X#undef|
|00003d20| 20 45 52 52 4f 52 5f 45 | 58 49 54 5f 4c 49 4e 54 | ERROR_E|XIT_LINT|
|00003d30| 4f 4b 0a 58 23 64 65 66 | 69 6e 65 20 45 52 52 4f |OK.X#def|ine ERRO|
|00003d40| 52 5f 45 58 49 54 5f 4c | 49 4e 54 4f 4b 28 6e 65 |R_EXIT_L|INTOK(ne|
|00003d50| 6c 65 6d 2c 20 73 69 7a | 65 29 20 5c 0a 58 09 66 |lem, siz|e) \.X.f|
|00003d60| 61 69 6c 28 22 6d 65 6d | 6f 72 79 20 61 6c 6c 6f |ail("mem|ory allo|
|00003d70| 63 61 74 69 6f 6e 20 66 | 61 69 6c 65 64 5c 6e 22 |cation f|ailed\n"|
|00003d80| 29 3b 0a 58 0a 58 09 4d | 52 5f 41 4c 4c 4f 43 5f |);.X.X.M|R_ALLOC_|
|00003d90| 4f 52 5f 45 4c 53 45 5f | 4c 49 4e 54 4f 4b 28 70 |OR_ELSE_|LINTOK(p|
|00003da0| 2c 20 34 30 30 2c 20 69 | 6e 74 29 3b 0a 58 09 73 |, 400, i|nt);.X.s|
|00003db0| 75 63 63 65 65 64 28 22 | 34 30 30 20 69 6e 74 73 |ucceed("|400 ints|
|00003dc0| 20 6d 72 5f 61 6c 6c 6f | 63 27 64 20 28 72 65 61 | mr_allo|c'd (rea|
|00003dd0| 6c 6c 6f 63 27 64 29 20 | 28 6f 72 20 65 6c 73 65 |lloc'd) |(or else|
|00003de0| 29 5c 6e 22 29 3b 0a 58 | 0a 58 09 65 78 69 74 28 |)\n");.X|.X.exit(|
|00003df0| 30 29 3b 0a 58 09 72 65 | 74 75 72 6e 20 30 3b 09 |0);.X.re|turn 0;.|
|00003e00| 2f 2a 20 73 68 75 74 73 | 20 75 70 20 48 50 2d 55 |/* shuts| up HP-U|
|00003e10| 58 20 6c 69 6e 74 20 2a | 2f 0a 58 7d 0a 58 0a 58 |X lint *|/.X}.X.X|
|00003e20| 66 61 69 6c 28 73 29 0a | 58 09 63 68 61 72 20 2a |fail(s).|X.char *|
|00003e30| 73 3b 0a 58 7b 0a 58 09 | 66 70 75 74 73 28 73 2c |s;.X{.X.|fputs(s,|
|00003e40| 20 73 74 64 6f 75 74 29 | 3b 0a 58 09 65 78 69 74 | stdout)|;.X.exit|
|00003e50| 28 31 29 3b 0a 58 7d 0a | 58 0a 58 73 75 63 63 65 |(1);.X}.|X.Xsucce|
|00003e60| 65 64 28 73 29 0a 58 09 | 63 68 61 72 20 2a 73 3b |ed(s).X.|char *s;|
|00003e70| 0a 58 7b 0a 58 09 66 70 | 75 74 73 28 73 2c 20 73 |.X{.X.fp|uts(s, s|
|00003e80| 74 64 6f 75 74 29 3b 0a | 58 09 72 65 74 75 72 6e |tdout);.|X.return|
|00003e90| 3b 0a 58 7d 0a 45 4e 44 | 5f 4f 46 5f 74 5f 6d 65 |;.X}.END|_OF_t_me|
|00003ea0| 6d 6c 69 6e 74 6f 6b 2e | 63 0a 69 66 20 74 65 73 |mlintok.|c.if tes|
|00003eb0| 74 20 31 34 33 38 20 2d | 6e 65 20 60 77 63 20 2d |t 1438 -|ne `wc -|
|00003ec0| 63 20 3c 74 5f 6d 65 6d | 6c 69 6e 74 6f 6b 2e 63 |c <t_mem|lintok.c|
|00003ed0| 60 3b 20 74 68 65 6e 0a | 20 20 20 20 65 63 68 6f |`; then.| echo|
|00003ee0| 20 73 68 61 72 3a 20 5c | 22 74 5f 6d 65 6d 6c 69 | shar: \|"t_memli|
|00003ef0| 6e 74 6f 6b 2e 63 5c 22 | 20 75 6e 70 61 63 6b 65 |ntok.c\"| unpacke|
|00003f00| 64 20 77 69 74 68 20 77 | 72 6f 6e 67 20 73 69 7a |d with w|rong siz|
|00003f10| 65 21 0a 66 69 0a 23 20 | 65 6e 64 20 6f 66 20 6f |e!.fi.# |end of o|
|00003f20| 76 65 72 77 72 69 74 69 | 6e 67 20 63 68 65 63 6b |verwriti|ng check|
|00003f30| 0a 66 69 0a 65 63 68 6f | 20 73 68 61 72 3a 20 45 |.fi.echo| shar: E|
|00003f40| 6e 64 20 6f 66 20 73 68 | 65 6c 6c 20 61 72 63 68 |nd of sh|ell arch|
|00003f50| 69 76 65 2e 0a 65 78 69 | 74 20 30 0a 0a 0a |ive..exi|t 0... |
+--------+-------------------------+-------------------------+--------+--------+