home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: SHell self-extracting ARchive
(archive/shar).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| SHell self-extracting ARchive (archive/shar)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| ASCII text
| 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)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000010| 2e 73 6f 75 72 63 65 73 | 2e 6d 69 73 63 0a 6f 72 |.sources|.misc.or|
|00000020| 67 61 6e 69 7a 61 74 69 | 6f 6e 3a 20 54 53 53 49 |ganizati|on: TSSI|
|00000030| 2c 20 42 65 61 76 65 72 | 74 6f 6e 2c 20 4f 72 65 |, Beaver|ton, Ore|
|00000040| 67 6f 6e 0a 73 75 62 6a | 65 63 74 3a 20 76 30 38 |gon.subj|ect: v08|
|00000050| 69 30 32 33 3a 20 6d 65 | 6d 6c 69 6e 74 6f 6b 3a |i023: me|mlintok:|
|00000060| 20 6d 61 63 72 6f 73 20 | 74 6f 20 61 76 6f 69 64 | macros |to avoid|
|00000070| 20 6c 69 6e 74 20 63 6f | 6d 70 6c 61 69 6e 74 73 | lint co|mplaints|
|00000080| 20 61 62 6f 75 74 20 6d | 61 6c 6c 6f 63 2f 66 72 | about m|alloc/fr|
|00000090| 65 65 0a 46 72 6f 6d 3a | 20 61 6c 6c 62 65 72 79 |ee.From:| allbery|
|000000a0| 40 75 75 6e 65 74 2e 55 | 55 2e 4e 45 54 20 28 42 |@uunet.U|U.NET (B|
|000000b0| 72 61 6e 64 6f 6e 20 53 | 2e 20 41 6c 6c 62 65 72 |randon S|. Allber|
|000000c0| 79 20 2d 20 63 6f 6d 70 | 2e 73 6f 75 72 63 65 73 |y - comp|.sources|
|000000d0| 2e 6d 69 73 63 29 0a 52 | 65 70 6c 79 2d 54 6f 3a |.misc).R|eply-To:|
|000000e0| 20 62 6f 62 6c 40 74 65 | 73 73 69 2e 55 55 43 50 | bobl@te|ssi.UUCP|
|000000f0| 0a 0a 50 6f 73 74 69 6e | 67 2d 6e 75 6d 62 65 72 |..Postin|g-number|
|00000100| 3a 20 56 6f 6c 75 6d 65 | 20 38 2c 20 49 73 73 75 |: Volume| 8, Issu|
|00000110| 65 20 32 33 0a 53 75 62 | 6d 69 74 74 65 64 2d 62 |e 23.Sub|mitted-b|
|00000120| 79 3a 20 62 6f 62 6c 40 | 74 65 73 73 69 2e 55 55 |y: bobl@|tessi.UU|
|00000130| 43 50 0a 41 72 63 68 69 | 76 65 2d 6e 61 6d 65 3a |CP.Archi|ve-name:|
|00000140| 20 6d 65 6d 6c 69 6e 74 | 6f 6b 0a 0a 48 65 72 65 | memlint|ok..Here|
|00000150| 20 69 73 20 61 20 70 61 | 63 6b 61 67 65 20 77 68 | is a pa|ckage wh|
|00000160| 69 63 68 20 70 61 69 6e | 6c 65 73 73 6c 79 20 67 |ich pain|lessly g|
|00000170| 65 74 73 20 61 72 6f 75 | 6e 64 20 6c 69 6e 74 20 |ets arou|nd lint |
|00000180| 63 6f 6d 70 6c 61 69 6e | 74 73 20 61 62 6f 75 74 |complain|ts about|
|00000190| 0a 74 68 65 20 6d 65 6d | 6f 72 79 20 61 6c 6c 6f |.the mem|ory allo|
|000001a0| 63 61 74 69 6f 6e 20 66 | 75 6e 63 74 69 6f 6e 73 |cation f|unctions|
|000001b0| 2e 20 20 53 65 65 20 65 | 6e 63 6c 6f 73 65 64 20 |. See e|nclosed |
|000001c0| 74 68 65 20 22 52 45 41 | 44 4d 45 22 20 66 69 6c |the "REA|DME" fil|
|000001d0| 65 20 61 6e 64 0a 6d 61 | 6e 20 70 61 67 65 20 66 |e and.ma|n page f|
|000001e0| 6f 72 20 6d 6f 72 65 20 | 69 6e 66 6f 72 6d 61 74 |or more |informat|
|000001f0| 69 6f 6e 2e 0a 0a 09 2d | 20 42 6f 62 20 4c 65 77 |ion....-| Bob Lew|
|00000200| 69 73 0a 09 20 20 62 6f | 62 6c 40 74 65 73 73 69 |is.. bo|bl@tessi|
|00000210| 2e 75 75 63 70 0a 0a 23 | 21 20 2f 62 69 6e 2f 73 |.uucp..#|! /bin/s|
|00000220| 68 0a 23 20 54 68 69 73 | 20 69 73 20 61 20 73 68 |h.# This| is a sh|
|00000230| 65 6c 6c 20 61 72 63 68 | 69 76 65 2e 20 20 52 65 |ell arch|ive. Re|
|00000240| 6d 6f 76 65 20 61 6e 79 | 74 68 69 6e 67 20 62 65 |move any|thing be|
|00000250| 66 6f 72 65 20 74 68 69 | 73 20 6c 69 6e 65 2c 20 |fore thi|s line, |
|00000260| 74 68 65 6e 20 75 6e 70 | 61 63 6b 0a 23 20 69 74 |then unp|ack.# it|
|00000270| 20 62 79 20 73 61 76 69 | 6e 67 20 69 74 20 69 6e | by savi|ng it in|
|00000280| 74 6f 20 61 20 66 69 6c | 65 20 61 6e 64 20 74 79 |to a fil|e and ty|
|00000290| 70 69 6e 67 20 22 73 68 | 20 66 69 6c 65 22 2e 20 |ping "sh| file". |
|000002a0| 20 54 6f 20 6f 76 65 72 | 77 72 69 74 65 20 65 78 | To over|write ex|
|000002b0| 69 73 74 69 6e 67 0a 23 | 20 66 69 6c 65 73 2c 20 |isting.#| files, |
|000002c0| 74 79 70 65 20 22 73 68 | 20 66 69 6c 65 20 2d 63 |type "sh| file -c|
|000002d0| 22 2e 20 20 59 6f 75 20 | 63 61 6e 20 61 6c 73 6f |". You |can also|
|000002e0| 20 66 65 65 64 20 74 68 | 69 73 20 61 73 20 73 74 | feed th|is as st|
|000002f0| 61 6e 64 61 72 64 20 69 | 6e 70 75 74 20 76 69 61 |andard i|nput via|
|00000300| 0a 23 20 75 6e 73 68 61 | 72 2c 20 6f 72 20 62 79 |.# unsha|r, or by|
|00000310| 20 74 79 70 69 6e 67 20 | 22 73 68 20 3c 66 69 6c | typing |"sh <fil|
|00000320| 65 22 2c 20 65 2e 67 2e | 2e 20 20 49 66 20 74 68 |e", e.g.|. If th|
|00000330| 69 73 20 61 72 63 68 69 | 76 65 20 69 73 20 63 6f |is archi|ve is co|
|00000340| 6d 70 6c 65 74 65 2c 20 | 79 6f 75 0a 23 20 77 69 |mplete, |you.# wi|
|00000350| 6c 6c 20 73 65 65 20 74 | 68 65 20 66 6f 6c 6c 6f |ll see t|he follo|
|00000360| 77 69 6e 67 20 6d 65 73 | 73 61 67 65 20 61 74 20 |wing mes|sage at |
|00000370| 74 68 65 20 65 6e 64 3a | 0a 23 09 09 22 45 6e 64 |the end:|.#.."End|
|00000380| 20 6f 66 20 73 68 65 6c | 6c 20 61 72 63 68 69 76 | of shel|l archiv|
|00000390| 65 2e 22 0a 23 20 43 6f | 6e 74 65 6e 74 73 3a 20 |e.".# Co|ntents: |
|000003a0| 20 52 45 41 44 4d 45 20 | 4d 61 6b 65 66 69 6c 65 | README |Makefile|
|000003b0| 20 67 6f 6f 64 20 6d 65 | 6d 6c 69 6e 74 6f 6b 2e | good me|mlintok.|
|000003c0| 33 20 6d 65 6d 6c 69 6e | 74 6f 6b 2e 68 20 74 5f |3 memlin|tok.h t_|
|000003d0| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 63 0a 23 20 57 72 |memlinto|k.c.# Wr|
|000003e0| 61 70 70 65 64 20 62 79 | 20 62 6f 62 6c 40 67 68 |apped by| bobl@gh|
|000003f0| 69 64 72 61 68 20 6f 6e | 20 4d 6f 6e 20 41 75 67 |idrah on| Mon Aug|
|00000400| 20 32 38 20 31 30 3a 34 | 39 3a 33 33 20 31 39 38 | 28 10:4|9:33 198|
|00000410| 39 0a 50 41 54 48 3d 2f | 62 69 6e 3a 2f 75 73 72 |9.PATH=/|bin:/usr|
|00000420| 2f 62 69 6e 3a 2f 75 73 | 72 2f 75 63 62 20 3b 20 |/bin:/us|r/ucb ; |
|00000430| 65 78 70 6f 72 74 20 50 | 41 54 48 0a 69 66 20 74 |export P|ATH.if t|
|00000440| 65 73 74 20 2d 66 20 52 | 45 41 44 4d 45 20 2d 61 |est -f R|EADME -a|
|00000450| 20 22 24 7b 31 7d 22 20 | 21 3d 20 22 2d 63 22 20 | "${1}" |!= "-c" |
|00000460| 3b 20 74 68 65 6e 20 0a | 20 20 65 63 68 6f 20 73 |; then .| echo s|
|00000470| 68 61 72 3a 20 57 69 6c | 6c 20 6e 6f 74 20 6f 76 |har: Wil|l not ov|
|00000480| 65 72 2d 77 72 69 74 65 | 20 65 78 69 73 74 69 6e |er-write| existin|
|00000490| 67 20 66 69 6c 65 20 5c | 22 52 45 41 44 4d 45 5c |g file \|"README\|
|000004a0| 22 0a 65 6c 73 65 0a 65 | 63 68 6f 20 73 68 61 72 |".else.e|cho shar|
|000004b0| 3a 20 45 78 74 72 61 63 | 74 69 6e 67 20 5c 22 52 |: Extrac|ting \"R|
|000004c0| 45 41 44 4d 45 5c 22 20 | 5c 28 31 37 34 37 20 63 |EADME\" |\(1747 c|
|000004d0| 68 61 72 61 63 74 65 72 | 73 5c 29 0a 73 65 64 20 |haracter|s\).sed |
|000004e0| 22 73 2f 5e 58 2f 2f 22 | 20 3e 52 45 41 44 4d 45 |"s/^X//"| >README|
|000004f0| 20 3c 3c 27 45 4e 44 5f | 4f 46 5f 52 45 41 44 4d | <<'END_|OF_READM|
|00000500| 45 27 0a 58 22 6d 65 6d | 6c 69 6e 74 6f 6b 2e 68 |E'.X"mem|lintok.h|
|00000510| 22 20 69 73 20 61 20 68 | 65 61 64 65 72 20 66 69 |" is a h|eader fi|
|00000520| 6c 65 20 74 68 61 74 20 | 63 61 6e 20 62 65 20 75 |le that |can be u|
|00000530| 73 65 64 20 74 6f 20 70 | 6f 6c 69 74 65 6c 79 20 |sed to p|olitely |
|00000540| 73 68 75 74 20 6c 69 6e | 74 28 31 29 20 75 70 0a |shut lin|t(1) up.|
|00000550| 58 61 62 6f 75 74 20 63 | 61 73 74 69 6e 67 20 72 |Xabout c|asting r|
|00000560| 65 73 75 6c 74 73 20 6f | 66 20 6d 65 6d 6f 72 79 |esults o|f memory|
|00000570| 20 61 6c 6c 6f 63 61 74 | 69 6f 6e 20 66 75 6e 63 | allocat|ion func|
|00000580| 74 69 6f 6e 73 20 6d 61 | 6c 6c 6f 63 28 33 29 2c |tions ma|lloc(3),|
|00000590| 20 72 65 61 6c 6c 6f 63 | 28 33 29 2c 0a 58 61 6e | realloc|(3),.Xan|
|000005a0| 64 20 63 61 6c 6c 6f 63 | 28 33 29 2e 20 20 49 74 |d calloc|(3). It|
|000005b0| 20 61 6c 73 6f 20 73 74 | 6f 70 73 20 63 6f 6d 70 | also st|ops comp|
|000005c0| 6c 61 69 6e 74 73 20 61 | 62 6f 75 74 20 74 68 65 |laints a|bout the|
|000005d0| 20 61 72 67 75 6d 65 6e | 74 20 6f 66 20 66 72 65 | argumen|t of fre|
|000005e0| 65 28 33 29 2e 0a 58 0a | 58 43 4f 4e 54 45 4e 54 |e(3)..X.|XCONTENT|
|000005f0| 53 0a 58 2d 2d 2d 2d 2d | 2d 2d 2d 0a 58 46 69 6c |S.X-----|---.XFil|
|00000600| 65 73 20 69 6e 20 74 68 | 69 73 20 64 69 73 74 72 |es in th|is distr|
|00000610| 69 62 75 74 69 6f 6e 20 | 61 72 65 3a 0a 58 0a 58 |ibution |are:.X.X|
|00000620| 52 45 41 44 4d 45 09 09 | 09 79 6f 75 27 72 65 20 |README..|.you're |
|00000630| 72 65 61 64 69 6e 67 20 | 69 74 0a 58 4d 61 6b 65 |reading |it.XMake|
|00000640| 66 69 6c 65 09 09 68 61 | 73 20 73 65 76 65 72 61 |file..ha|s severa|
|00000650| 6c 20 75 73 65 66 75 6c | 20 74 61 72 67 65 74 73 |l useful| targets|
|00000660| 2c 20 69 6e 63 6c 75 64 | 69 6e 67 20 22 69 6e 73 |, includ|ing "ins|
|00000670| 74 61 6c 6c 22 20 61 6e | 64 20 22 74 65 73 74 22 |tall" an|d "test"|
|00000680| 0a 58 67 6f 6f 64 09 09 | 09 67 6f 6f 64 20 72 65 |.Xgood..|.good re|
|00000690| 73 75 6c 74 73 20 66 6f | 72 20 22 6d 61 6b 65 20 |sults fo|r "make |
|000006a0| 74 65 73 74 22 0a 58 6d | 65 6d 6c 69 6e 74 6f 6b |test".Xm|emlintok|
|000006b0| 2e 33 09 09 6d 61 6e 20 | 70 61 67 65 0a 58 6d 65 |.3..man |page.Xme|
|000006c0| 6d 6c 69 6e 74 6f 6b 2e | 68 09 09 74 68 65 20 68 |mlintok.|h..the h|
|000006d0| 65 61 64 65 72 20 66 69 | 6c 65 20 69 74 73 65 6c |eader fi|le itsel|
|000006e0| 66 0a 58 74 5f 6d 65 6d | 6c 69 6e 74 6f 6b 2e 63 |f.Xt_mem|lintok.c|
|000006f0| 09 61 20 74 65 73 74 2f | 64 65 6d 6f 20 70 72 6f |.a test/|demo pro|
|00000700| 67 72 61 6d 0a 58 0a 58 | 44 49 53 43 55 53 53 49 |gram.X.X|DISCUSSI|
|00000710| 4f 4e 0a 58 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 0a 58 |ON.X----|------.X|
|00000720| 4f 6e 65 20 63 6f 6d 6d | 6f 6e 20 77 61 79 20 6f |One comm|on way o|
|00000730| 66 20 69 67 6e 6f 72 69 | 6e 67 20 6c 69 6e 74 20 |f ignori|ng lint |
|00000740| 65 72 72 6f 72 73 20 69 | 73 20 74 6f 20 64 6f 20 |errors i|s to do |
|00000750| 73 6f 6d 65 74 68 69 6e | 67 20 6c 69 6b 65 3a 0a |somethin|g like:.|
|00000760| 58 0a 58 09 23 69 66 64 | 65 66 20 6c 69 6e 74 0a |X.X.#ifd|ef lint.|
|00000770| 58 09 23 64 65 66 69 6e | 65 20 6d 61 6c 6c 6f 63 |X.#defin|e malloc|
|00000780| 28 61 72 67 29 20 4e 55 | 4c 4c 0a 58 09 23 65 6e |(arg) NU|LL.X.#en|
|00000790| 64 69 66 0a 58 0a 58 54 | 68 65 20 74 72 6f 75 62 |dif.X.XT|he troub|
|000007a0| 6c 65 20 77 69 74 68 20 | 64 6f 69 6e 67 20 74 68 |le with |doing th|
|000007b0| 69 6e 67 73 20 74 68 69 | 73 20 77 61 79 20 69 73 |ings thi|s way is|
|000007c0| 20 74 68 61 74 20 6c 69 | 6e 74 20 77 69 6c 6c 20 | that li|nt will |
|000007d0| 6e 6f 74 20 74 68 65 6e | 20 62 65 20 61 62 6c 65 |not then| be able|
|000007e0| 20 74 6f 0a 58 63 68 65 | 63 6b 20 6d 61 6c 6c 6f | to.Xche|ck mallo|
|000007f0| 63 27 73 20 61 72 67 75 | 6d 65 6e 74 2c 20 73 6f |c's argu|ment, so|
|00000800| 20 79 6f 75 20 63 6f 75 | 6c 64 20 67 65 74 20 61 | you cou|ld get a|
|00000810| 77 61 79 20 77 69 74 68 | 20 73 6f 6d 65 74 68 69 |way with| somethi|
|00000820| 6e 67 20 6c 69 6b 65 3a | 0a 58 0a 58 09 63 68 61 |ng like:|.X.X.cha|
|00000830| 72 20 2a 70 3b 0a 58 09 | 63 68 61 72 20 2a 71 3b |r *p;.X.|char *q;|
|00000840| 0a 58 09 2e 2e 2e 0a 58 | 09 70 20 3d 20 6d 61 6c |.X.....X|.p = mal|
|00000850| 6c 6f 63 28 71 29 3b 0a | 58 0a 58 54 68 65 20 6d |loc(q);.|X.XThe m|
|00000860| 61 63 72 6f 73 20 68 65 | 72 65 20 61 72 65 20 61 |acros he|re are a|
|00000870| 20 62 69 74 20 6d 6f 72 | 65 20 73 6f 70 68 69 73 | bit mor|e sophis|
|00000880| 74 69 63 61 74 65 64 2c | 20 73 6f 20 74 68 61 74 |ticated,| so that|
|00000890| 20 74 68 65 20 6d 65 6d | 6f 72 79 20 66 75 6e 63 | the mem|ory func|
|000008a0| 74 69 6f 6e 73 0a 58 67 | 65 74 20 69 6e 76 6f 6b |tions.Xg|et invok|
|000008b0| 65 64 20 69 6e 20 61 20 | 73 79 6e 74 61 63 74 69 |ed in a |syntacti|
|000008c0| 63 61 6c 6c 79 20 63 6f | 72 72 65 63 74 20 61 6e |cally co|rrect an|
|000008d0| 64 20 70 72 6f 70 65 72 | 6c 79 2d 74 79 70 65 64 |d proper|ly-typed|
|000008e0| 20 28 61 6c 74 68 6f 75 | 67 68 0a 58 73 65 6d 61 | (althou|gh.Xsema|
|000008f0| 6e 74 69 63 61 6c 6c 79 | 20 69 6e 63 6f 72 72 65 |ntically| incorre|
|00000900| 63 74 29 20 66 61 73 68 | 69 6f 6e 20 61 6e 64 20 |ct) fash|ion and |
|00000910| 74 68 65 20 61 72 67 75 | 6d 65 6e 74 73 20 67 65 |the argu|ments ge|
|00000920| 74 20 63 68 65 63 6b 65 | 64 0a 58 69 6e 64 65 70 |t checke|d.Xindep|
|00000930| 65 6e 64 65 6e 74 6c 79 | 2e 20 20 54 68 65 20 6d |endently|. The m|
|00000940| 61 6e 20 70 61 67 65 20 | 64 65 73 63 72 69 62 65 |an page |describe|
|00000950| 73 20 74 68 65 69 72 20 | 75 73 65 2e 0a 58 0a 58 |s their |use..X.X|
|00000960| 54 68 65 20 66 69 6c 65 | 20 61 6c 73 6f 20 69 6e |The file| also in|
|00000970| 63 6c 75 64 65 73 20 61 | 20 6d 61 63 72 6f 20 4d |cludes a| macro M|
|00000980| 52 5f 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 20 74 |R_ALLOC_|LINTOK t|
|00000990| 68 61 74 20 69 73 20 73 | 69 6d 70 6c 79 20 61 20 |hat is s|imply a |
|000009a0| 63 6f 6d 70 61 63 74 20 | 66 6f 72 6d 0a 58 6f 66 |compact |form.Xof|
|000009b0| 20 74 68 65 20 63 6f 6d | 6d 6f 6e 6c 79 2d 6f 63 | the com|monly-oc|
|000009c0| 63 75 72 72 69 6e 67 20 | 63 6f 64 65 20 74 6f 20 |curring |code to |
|000009d0| 61 6c 6c 6f 63 61 74 65 | 20 6d 65 6d 6f 72 79 20 |allocate| memory |
|000009e0| 69 66 20 61 20 28 74 79 | 70 69 63 61 6c 6c 79 20 |if a (ty|pically |
|000009f0| 73 74 61 74 69 63 29 0a | 58 70 6f 69 6e 74 65 72 |static).|Xpointer|
|00000a00| 20 69 73 20 4e 55 4c 4c | 20 61 6e 64 20 74 6f 20 | is NULL| and to |
|00000a10| 72 65 61 6c 6c 6f 63 61 | 74 65 20 69 74 20 69 66 |realloca|te it if|
|00000a20| 20 74 68 65 20 70 6f 69 | 6e 74 65 72 20 69 73 6e | the poi|nter isn|
|00000a30| 27 74 20 4e 55 4c 4c 2e | 0a 58 0a 58 54 68 65 72 |'t NULL.|.X.XTher|
|00000a40| 65 20 61 72 65 20 61 6c | 73 6f 20 6d 61 63 72 6f |e are al|so macro|
|00000a50| 73 20 74 6f 20 64 6f 20 | 73 6f 6d 65 20 70 72 69 |s to do |some pri|
|00000a60| 6d 69 74 69 76 65 20 65 | 78 63 65 70 74 69 6f 6e |mitive e|xception|
|00000a70| 20 68 61 6e 64 6c 69 6e | 67 20 6f 66 20 74 68 65 | handlin|g of the|
|00000a80| 20 6d 65 6d 6f 72 79 0a | 58 61 6c 6c 6f 63 61 74 | memory.|Xallocat|
|00000a90| 69 6f 6e 20 66 75 6e 63 | 74 69 6f 6e 2e 20 20 53 |ion func|tion. S|
|00000aa0| 65 65 20 74 68 65 20 6d | 61 6e 20 70 61 67 65 20 |ee the m|an page |
|00000ab0| 66 6f 72 20 6d 6f 72 65 | 20 6f 6e 20 74 68 65 73 |for more| on thes|
|00000ac0| 65 2e 0a 58 0a 58 41 73 | 20 49 20 64 65 76 65 6c |e..X.XAs| I devel|
|00000ad0| 6f 70 65 64 20 69 74 20 | 77 69 74 68 20 6d 79 20 |oped it |with my |
|00000ae0| 6f 77 6e 20 72 65 73 6f | 75 72 63 65 73 2c 20 49 |own reso|urces, I|
|00000af0| 27 6d 20 72 65 6c 65 61 | 73 69 6e 67 20 74 68 69 |'m relea|sing thi|
|00000b00| 73 20 63 6f 64 65 20 74 | 6f 20 74 68 65 0a 58 70 |s code t|o the.Xp|
|00000b10| 75 62 6c 69 63 20 64 6f | 6d 61 69 6e 2e 20 20 49 |ublic do|main. I|
|00000b20| 20 68 65 72 65 62 79 20 | 64 65 6e 79 20 61 6e 79 | hereby |deny any|
|00000b30| 20 72 65 73 70 6f 6e 73 | 69 62 69 6c 69 74 79 20 | respons|ibility |
|00000b40| 66 6f 72 20 69 74 73 20 | 75 73 65 20 6f 72 20 61 |for its |use or a|
|00000b50| 6e 79 20 64 61 6d 61 67 | 65 73 0a 58 72 65 73 75 |ny damag|es.Xresu|
|00000b60| 6c 74 69 6e 67 20 66 72 | 6f 6d 20 73 61 6d 65 2e |lting fr|om same.|
|00000b70| 0a 58 0a 58 4e 65 76 65 | 72 74 68 65 6c 65 73 73 |.X.XNeve|rtheless|
|00000b80| 2c 20 69 66 20 61 6e 79 | 6f 6e 65 20 68 61 73 20 |, if any|one has |
|00000b90| 61 6e 79 20 70 72 6f 62 | 6c 65 6d 73 20 77 69 74 |any prob|lems wit|
|00000ba0| 68 20 69 74 2c 20 71 75 | 65 73 74 69 6f 6e 73 20 |h it, qu|estions |
|00000bb0| 61 62 6f 75 74 20 69 74 | 2c 20 6f 72 0a 58 69 6d |about it|, or.Xim|
|00000bc0| 70 72 6f 76 65 6d 65 6e | 74 73 20 74 6f 20 69 74 |provemen|ts to it|
|00000bd0| 2c 20 70 6c 65 61 73 65 | 20 6c 65 74 20 6d 65 20 |, please| let me |
|00000be0| 6b 6e 6f 77 2e 0a 58 0a | 58 09 2d 20 42 6f 62 20 |know..X.|X.- Bob |
|00000bf0| 4c 65 77 69 73 0a 58 09 | 20 20 62 6f 62 6c 40 74 |Lewis.X.| bobl@t|
|00000c00| 65 73 73 69 2e 75 75 63 | 70 0a 45 4e 44 5f 4f 46 |essi.uuc|p.END_OF|
|00000c10| 5f 52 45 41 44 4d 45 0a | 69 66 20 74 65 73 74 20 |_README.|if test |
|00000c20| 31 37 34 37 20 2d 6e 65 | 20 60 77 63 20 2d 63 20 |1747 -ne| `wc -c |
|00000c30| 3c 52 45 41 44 4d 45 60 | 3b 20 74 68 65 6e 0a 20 |<README`|; then. |
|00000c40| 20 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 5c 22 | echo |shar: \"|
|00000c50| 52 45 41 44 4d 45 5c 22 | 20 75 6e 70 61 63 6b 65 |README\"| unpacke|
|00000c60| 64 20 77 69 74 68 20 77 | 72 6f 6e 67 20 73 69 7a |d with w|rong siz|
|00000c70| 65 21 0a 66 69 0a 23 20 | 65 6e 64 20 6f 66 20 6f |e!.fi.# |end of o|
|00000c80| 76 65 72 77 72 69 74 69 | 6e 67 20 63 68 65 63 6b |verwriti|ng check|
|00000c90| 0a 66 69 0a 69 66 20 74 | 65 73 74 20 2d 66 20 4d |.fi.if t|est -f M|
|00000ca0| 61 6b 65 66 69 6c 65 20 | 2d 61 20 22 24 7b 31 7d |akefile |-a "${1}|
|00000cb0| 22 20 21 3d 20 22 2d 63 | 22 20 3b 20 74 68 65 6e |" != "-c|" ; then|
|00000cc0| 20 0a 20 20 65 63 68 6f | 20 73 68 61 72 3a 20 57 | . echo| shar: W|
|00000cd0| 69 6c 6c 20 6e 6f 74 20 | 6f 76 65 72 2d 77 72 69 |ill not |over-wri|
|00000ce0| 74 65 20 65 78 69 73 74 | 69 6e 67 20 66 69 6c 65 |te exist|ing file|
|00000cf0| 20 5c 22 4d 61 6b 65 66 | 69 6c 65 5c 22 0a 65 6c | \"Makef|ile\".el|
|00000d00| 73 65 0a 65 63 68 6f 20 | 73 68 61 72 3a 20 45 78 |se.echo |shar: Ex|
|00000d10| 74 72 61 63 74 69 6e 67 | 20 5c 22 4d 61 6b 65 66 |tracting| \"Makef|
|00000d20| 69 6c 65 5c 22 20 5c 28 | 39 35 34 20 63 68 61 72 |ile\" \(|954 char|
|00000d30| 61 63 74 65 72 73 5c 29 | 0a 73 65 64 20 22 73 2f |acters\)|.sed "s/|
|00000d40| 5e 58 2f 2f 22 20 3e 4d | 61 6b 65 66 69 6c 65 20 |^X//" >M|akefile |
|00000d50| 3c 3c 27 45 4e 44 5f 4f | 46 5f 4d 61 6b 65 66 69 |<<'END_O|F_Makefi|
|00000d60| 6c 65 27 0a 58 23 20 24 | 48 65 61 64 65 72 3a 20 |le'.X# $|Header: |
|00000d70| 4d 61 6b 65 66 69 6c 65 | 2c 76 20 31 2e 34 20 38 |Makefile|,v 1.4 8|
|00000d80| 39 2f 30 35 2f 30 32 20 | 31 35 3a 30 36 3a 34 38 |9/05/02 |15:06:48|
|00000d90| 20 62 6f 62 6c 20 4c 6f | 63 6b 65 64 20 24 0a 58 | bobl Lo|cked $.X|
|00000da0| 0a 58 64 65 66 61 75 6c | 74 3a 20 6e 65 77 0a 58 |.Xdefaul|t: new.X|
|00000db0| 0a 58 23 0a 58 23 09 54 | 68 69 73 20 69 73 20 77 |.X#.X#.T|his is w|
|00000dc0| 68 65 72 65 20 79 6f 75 | 20 77 61 6e 74 20 74 68 |here you| want th|
|00000dd0| 65 20 68 65 61 64 65 72 | 20 74 6f 20 67 6f 2e 20 |e header| to go. |
|00000de0| 20 49 74 20 6d 69 67 68 | 74 20 62 65 20 61 64 76 | It migh|t be adv|
|00000df0| 69 73 61 62 6c 65 20 74 | 6f 0a 58 23 09 70 75 74 |isable t|o.X#.put|
|00000e00| 20 69 74 20 69 6e 20 73 | 6f 6d 65 20 6c 6f 63 61 | it in s|ome loca|
|00000e10| 6c 20 64 69 72 65 63 74 | 6f 72 79 20 72 61 74 68 |l direct|ory rath|
|00000e20| 65 72 20 74 68 61 6e 20 | 74 68 69 73 20 64 65 66 |er than |this def|
|00000e30| 61 75 6c 74 20 6f 6e 65 | 2e 2e 2e 0a 58 23 0a 58 |ault one|....X#.X|
|00000e40| 48 44 52 5f 44 45 53 54 | 20 3d 20 2f 75 73 72 2f |HDR_DEST| = /usr/|
|00000e50| 69 6e 63 6c 75 64 65 0a | 58 0a 58 23 0a 58 23 09 |include.|X.X#.X#.|
|00000e60| 54 68 65 20 6d 61 6e 20 | 70 61 67 65 20 67 6f 65 |The man |page goe|
|00000e70| 73 20 68 65 72 65 2e 20 | 20 41 67 61 69 6e 2c 20 |s here. | Again, |
|00000e80| 79 6f 75 20 6d 61 79 20 | 68 61 76 65 20 73 6f 6d |you may |have som|
|00000e90| 65 20 6c 6f 63 61 6c 20 | 70 6c 61 63 65 20 74 6f |e local |place to|
|00000ea0| 20 70 75 74 20 69 74 2e | 0a 58 23 0a 58 4d 41 4e | put it.|.X#.XMAN|
|00000eb0| 5f 44 45 53 54 20 3d 20 | 2f 75 73 72 2f 6d 61 6e |_DEST = |/usr/man|
|00000ec0| 2f 6d 61 6e 33 0a 58 0a | 58 46 49 4c 45 53 20 3d |/man3.X.|XFILES =|
|00000ed0| 20 5c 0a 58 09 52 45 41 | 44 4d 45 20 5c 0a 58 09 | \.X.REA|DME \.X.|
|00000ee0| 4d 61 6b 65 66 69 6c 65 | 20 5c 0a 58 09 67 6f 6f |Makefile| \.X.goo|
|00000ef0| 64 20 5c 0a 58 09 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |d \.X.me|mlintok.|
|00000f00| 33 20 5c 0a 58 09 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |3 \.X.me|mlintok.|
|00000f10| 68 20 5c 0a 58 09 74 5f | 6d 65 6d 6c 69 6e 74 6f |h \.X.t_|memlinto|
|00000f20| 6b 2e 63 0a 58 0a 58 63 | 6c 65 61 6e 3a 0a 58 09 |k.c.X.Xc|lean:.X.|
|00000f30| 72 6d 20 2d 66 20 74 5f | 6d 65 6d 6c 69 6e 74 6f |rm -f t_|memlinto|
|00000f40| 6b 20 6e 65 77 20 63 6f | 72 65 20 61 2e 6f 75 74 |k new co|re a.out|
|00000f50| 20 2a 2e 6f 20 6d 65 6d | 6c 69 6e 74 6f 6b 2e 73 | *.o mem|lintok.s|
|00000f60| 68 61 72 0a 58 0a 58 6e | 65 77 3a 09 74 5f 6d 65 |har.X.Xn|ew:.t_me|
|00000f70| 6d 6c 69 6e 74 6f 6b 0a | 58 09 74 5f 6d 65 6d 6c |mlintok.|X.t_meml|
|00000f80| 69 6e 74 6f 6b 20 3e 6e | 65 77 0a 58 0a 58 74 5f |intok >n|ew.X.Xt_|
|00000f90| 6d 65 6d 6c 69 6e 74 6f | 6b 3a 09 74 5f 6d 65 6d |memlinto|k:.t_mem|
|00000fa0| 6c 69 6e 74 6f 6b 2e 63 | 20 6d 65 6d 6c 69 6e 74 |lintok.c| memlint|
|00000fb0| 6f 6b 2e 68 0a 58 09 63 | 63 20 74 5f 6d 65 6d 6c |ok.h.X.c|c t_meml|
|00000fc0| 69 6e 74 6f 6b 2e 63 20 | 2d 6f 20 74 5f 6d 65 6d |intok.c |-o t_mem|
|00000fd0| 6c 69 6e 74 6f 6b 0a 58 | 0a 58 74 65 73 74 3a 09 |lintok.X|.Xtest:.|
|00000fe0| 6e 65 77 20 74 5f 6d 65 | 6d 6c 69 6e 74 6f 6b 0a |new t_me|mlintok.|
|00000ff0| 58 09 40 65 63 68 6f 20 | 22 23 20 63 6f 6d 70 61 |X.@echo |"# compa|
|00001000| 72 69 6e 67 20 6e 65 77 | 20 72 65 73 75 6c 74 73 |ring new| results|
|00001010| 20 77 69 74 68 20 6b 6e | 6f 77 6e 20 67 6f 6f 64 | with kn|own good|
|00001020| 20 6f 6e 65 73 3a 22 0a | 58 09 64 69 66 66 20 6e | ones:".|X.diff n|
|00001030| 65 77 20 67 6f 6f 64 0a | 58 09 40 65 63 68 6f 20 |ew good.|X.@echo |
|00001040| 22 23 20 73 68 6f 75 6c | 64 20 62 65 20 6e 6f 20 |"# shoul|d be no |
|00001050| 6c 69 6e 74 20 65 72 72 | 6f 72 73 3a 22 0a 58 09 |lint err|ors:".X.|
|00001060| 6c 69 6e 74 20 2d 62 61 | 63 68 78 20 74 5f 6d 65 |lint -ba|chx t_me|
|00001070| 6d 6c 69 6e 74 6f 6b 2e | 63 0a 58 0a 58 75 70 64 |mlintok.|c.X.Xupd|
|00001080| 61 74 65 3a 09 6e 65 77 | 0a 58 09 6d 76 20 2d 66 |ate:.new|.X.mv -f|
|00001090| 20 6e 65 77 20 67 6f 6f | 64 0a 58 0a 58 73 68 61 | new goo|d.X.Xsha|
|000010a0| 72 3a 20 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 73 68 61 |r: memli|ntok.sha|
|000010b0| 72 0a 58 0a 58 6d 65 6d | 6c 69 6e 74 6f 6b 2e 73 |r.X.Xmem|lintok.s|
|000010c0| 68 61 72 3a 20 24 28 46 | 49 4c 45 53 29 0a 58 09 |har: $(F|ILES).X.|
|000010d0| 73 68 61 72 20 24 28 46 | 49 4c 45 53 29 20 3e 6d |shar $(F|ILES) >m|
|000010e0| 65 6d 6c 69 6e 74 6f 6b | 2e 73 68 61 72 0a 58 0a |emlintok|.shar.X.|
|000010f0| 58 69 6e 73 74 61 6c 6c | 3a 20 6d 65 6d 6c 69 6e |Xinstall|: memlin|
|00001100| 74 6f 6b 2e 68 20 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |tok.h me|mlintok.|
|00001110| 33 0a 58 09 63 70 20 6d | 65 6d 6c 69 6e 74 6f 6b |3.X.cp m|emlintok|
|00001120| 2e 68 20 24 28 48 44 52 | 5f 44 45 53 54 29 0a 58 |.h $(HDR|_DEST).X|
|00001130| 09 63 70 20 6d 65 6d 6c | 69 6e 74 6f 6b 2e 33 20 |.cp meml|intok.3 |
|00001140| 24 28 4d 41 4e 5f 44 45 | 53 54 29 0a 58 0a 58 09 |$(MAN_DE|ST).X.X.|
|00001150| 0a 45 4e 44 5f 4f 46 5f | 4d 61 6b 65 66 69 6c 65 |.END_OF_|Makefile|
|00001160| 0a 69 66 20 74 65 73 74 | 20 39 35 34 20 2d 6e 65 |.if test| 954 -ne|
|00001170| 20 60 77 63 20 2d 63 20 | 3c 4d 61 6b 65 66 69 6c | `wc -c |<Makefil|
|00001180| 65 60 3b 20 74 68 65 6e | 0a 20 20 20 20 65 63 68 |e`; then|. ech|
|00001190| 6f 20 73 68 61 72 3a 20 | 5c 22 4d 61 6b 65 66 69 |o shar: |\"Makefi|
|000011a0| 6c 65 5c 22 20 75 6e 70 | 61 63 6b 65 64 20 77 69 |le\" unp|acked wi|
|000011b0| 74 68 20 77 72 6f 6e 67 | 20 73 69 7a 65 21 0a 66 |th wrong| size!.f|
|000011c0| 69 0a 23 20 65 6e 64 20 | 6f 66 20 6f 76 65 72 77 |i.# end |of overw|
|000011d0| 72 69 74 69 6e 67 20 63 | 68 65 63 6b 0a 66 69 0a |riting c|heck.fi.|
|000011e0| 69 66 20 74 65 73 74 20 | 2d 66 20 67 6f 6f 64 20 |if test |-f good |
|000011f0| 2d 61 20 22 24 7b 31 7d | 22 20 21 3d 20 22 2d 63 |-a "${1}|" != "-c|
|00001200| 22 20 3b 20 74 68 65 6e | 20 0a 20 20 65 63 68 6f |" ; then| . echo|
|00001210| 20 73 68 61 72 3a 20 57 | 69 6c 6c 20 6e 6f 74 20 | shar: W|ill not |
|00001220| 6f 76 65 72 2d 77 72 69 | 74 65 20 65 78 69 73 74 |over-wri|te exist|
|00001230| 69 6e 67 20 66 69 6c 65 | 20 5c 22 67 6f 6f 64 5c |ing file| \"good\|
|00001240| 22 0a 65 6c 73 65 0a 65 | 63 68 6f 20 73 68 61 72 |".else.e|cho shar|
|00001250| 3a 20 45 78 74 72 61 63 | 74 69 6e 67 20 5c 22 67 |: Extrac|ting \"g|
|00001260| 6f 6f 64 5c 22 20 5c 28 | 32 34 34 20 63 68 61 72 |ood\" \(|244 char|
|00001270| 61 63 74 65 72 73 5c 29 | 0a 73 65 64 20 22 73 2f |acters\)|.sed "s/|
|00001280| 5e 58 2f 2f 22 20 3e 67 | 6f 6f 64 20 3c 3c 27 45 |^X//" >g|ood <<'E|
|00001290| 4e 44 5f 4f 46 5f 67 6f | 6f 64 27 0a 58 31 30 30 |ND_OF_go|od'.X100|
|000012a0| 20 69 6e 74 73 20 6d 61 | 6c 6c 6f 63 27 64 0a 58 | ints ma|lloc'd.X|
|000012b0| 32 30 30 20 69 6e 74 73 | 20 72 65 61 6c 6c 6f 63 |200 ints| realloc|
|000012c0| 27 64 0a 58 32 35 20 69 | 6e 74 73 20 6d 72 5f 61 |'d.X25 i|nts mr_a|
|000012d0| 6c 6c 6f 63 27 64 20 28 | 72 65 61 6c 6c 6f 63 27 |lloc'd (|realloc'|
|000012e0| 64 29 0a 58 35 30 30 20 | 69 6e 74 73 20 63 61 6c |d).X500 |ints cal|
|000012f0| 6c 6f 63 27 64 0a 58 31 | 30 30 30 20 69 6e 74 73 |loc'd.X1|000 ints|
|00001300| 20 6d 72 5f 61 6c 6c 6f | 63 27 64 20 28 6d 61 6c | mr_allo|c'd (mal|
|00001310| 6c 6f 63 27 64 29 0a 58 | 35 30 20 69 6e 74 73 20 |loc'd).X|50 ints |
|00001320| 63 61 6c 6c 6f 63 27 64 | 20 28 6f 72 20 65 6c 73 |calloc'd| (or els|
|00001330| 65 29 0a 58 31 30 30 20 | 69 6e 74 73 20 6d 61 6c |e).X100 |ints mal|
|00001340| 6c 6f 63 27 64 20 28 6f | 72 20 65 6c 73 65 29 0a |loc'd (o|r else).|
|00001350| 58 32 30 30 20 69 6e 74 | 73 20 72 65 61 6c 6c 6f |X200 int|s reallo|
|00001360| 63 27 64 20 28 6f 72 20 | 65 6c 73 65 29 0a 58 34 |c'd (or |else).X4|
|00001370| 30 30 20 69 6e 74 73 20 | 6d 72 5f 61 6c 6c 6f 63 |00 ints |mr_alloc|
|00001380| 27 64 20 28 72 65 61 6c | 6c 6f 63 27 64 29 20 28 |'d (real|loc'd) (|
|00001390| 6f 72 20 65 6c 73 65 29 | 0a 45 4e 44 5f 4f 46 5f |or else)|.END_OF_|
|000013a0| 67 6f 6f 64 0a 69 66 20 | 74 65 73 74 20 32 34 34 |good.if |test 244|
|000013b0| 20 2d 6e 65 20 60 77 63 | 20 2d 63 20 3c 67 6f 6f | -ne `wc| -c <goo|
|000013c0| 64 60 3b 20 74 68 65 6e | 0a 20 20 20 20 65 63 68 |d`; then|. ech|
|000013d0| 6f 20 73 68 61 72 3a 20 | 5c 22 67 6f 6f 64 5c 22 |o shar: |\"good\"|
|000013e0| 20 75 6e 70 61 63 6b 65 | 64 20 77 69 74 68 20 77 | unpacke|d with w|
|000013f0| 72 6f 6e 67 20 73 69 7a | 65 21 0a 66 69 0a 23 20 |rong siz|e!.fi.# |
|00001400| 65 6e 64 20 6f 66 20 6f | 76 65 72 77 72 69 74 69 |end of o|verwriti|
|00001410| 6e 67 20 63 68 65 63 6b | 0a 66 69 0a 69 66 20 74 |ng check|.fi.if t|
|00001420| 65 73 74 20 2d 66 20 6d | 65 6d 6c 69 6e 74 6f 6b |est -f m|emlintok|
|00001430| 2e 33 20 2d 61 20 22 24 | 7b 31 7d 22 20 21 3d 20 |.3 -a "$|{1}" != |
|00001440| 22 2d 63 22 20 3b 20 74 | 68 65 6e 20 0a 20 20 65 |"-c" ; t|hen . e|
|00001450| 63 68 6f 20 73 68 61 72 | 3a 20 57 69 6c 6c 20 6e |cho shar|: Will n|
|00001460| 6f 74 20 6f 76 65 72 2d | 77 72 69 74 65 20 65 78 |ot over-|write ex|
|00001470| 69 73 74 69 6e 67 20 66 | 69 6c 65 20 5c 22 6d 65 |isting f|ile \"me|
|00001480| 6d 6c 69 6e 74 6f 6b 2e | 33 5c 22 0a 65 6c 73 65 |mlintok.|3\".else|
|00001490| 0a 65 63 68 6f 20 73 68 | 61 72 3a 20 45 78 74 72 |.echo sh|ar: Extr|
|000014a0| 61 63 74 69 6e 67 20 5c | 22 6d 65 6d 6c 69 6e 74 |acting \|"memlint|
|000014b0| 6f 6b 2e 33 5c 22 20 5c | 28 34 37 30 36 20 63 68 |ok.3\" \|(4706 ch|
|000014c0| 61 72 61 63 74 65 72 73 | 5c 29 0a 73 65 64 20 22 |aracters|\).sed "|
|000014d0| 73 2f 5e 58 2f 2f 22 20 | 3e 6d 65 6d 6c 69 6e 74 |s/^X//" |>memlint|
|000014e0| 6f 6b 2e 33 20 3c 3c 27 | 45 4e 44 5f 4f 46 5f 6d |ok.3 <<'|END_OF_m|
|000014f0| 65 6d 6c 69 6e 74 6f 6b | 2e 33 27 0a 58 2e 54 48 |emlintok|.3'.X.TH|
|00001500| 20 4c 49 4e 54 4f 4b 20 | 33 20 22 32 20 4d 61 79 | LINTOK |3 "2 May|
|00001510| 20 31 39 38 39 22 0a 58 | 2e 53 48 20 4e 41 4d 45 | 1989".X|.SH NAME|
|00001520| 0a 58 6d 65 6d 6c 69 6e | 74 6f 6b 20 5c 2d 20 70 |.Xmemlin|tok \- p|
|00001530| 61 63 6b 61 67 65 20 74 | 6f 20 73 74 6f 70 20 6c |ackage t|o stop l|
|00001540| 69 6e 74 20 63 6f 6d 70 | 6c 61 69 6e 74 73 20 61 |int comp|laints a|
|00001550| 62 6f 75 74 20 6d 65 6d | 6f 72 79 20 61 6c 6c 6f |bout mem|ory allo|
|00001560| 63 61 74 69 6f 6e 0a 58 | 2e 53 48 20 53 59 4e 4f |cation.X|.SH SYNO|
|00001570| 50 53 49 53 0a 58 2e 4c | 50 0a 58 23 69 6e 63 6c |PSIS.X.L|P.X#incl|
|00001580| 75 64 65 20 22 6d 65 6d | 6c 69 6e 74 6f 6b 2e 68 |ude "mem|lintok.h|
|00001590| 22 0a 58 2e 53 48 20 44 | 45 53 43 52 49 50 54 49 |".X.SH D|ESCRIPTI|
|000015a0| 4f 4e 0a 58 2e 4c 50 0a | 58 54 68 69 73 20 70 61 |ON.X.LP.|XThis pa|
|000015b0| 63 6b 61 67 65 20 63 6f | 6e 74 61 69 6e 73 20 63 |ckage co|ntains c|
|000015c0| 70 70 20 6d 61 63 72 6f | 20 64 65 66 69 6e 69 74 |pp macro| definit|
|000015d0| 69 6f 6e 73 20 74 68 61 | 74 0a 58 73 74 6f 70 20 |ions tha|t.Xstop |
|000015e0| 6c 69 6e 74 20 66 72 6f | 6d 20 63 6f 6d 70 6c 61 |lint fro|m compla|
|000015f0| 69 6e 69 6e 67 20 61 62 | 6f 75 74 20 74 68 65 20 |ining ab|out the |
|00001600| 6d 65 6d 6f 72 79 20 6d | 61 6e 61 67 65 6d 65 6e |memory m|anagemen|
|00001610| 74 20 66 75 6e 63 74 69 | 6f 6e 73 0a 58 2e 49 52 |t functi|ons.X.IR|
|00001620| 20 6d 61 6c 6c 6f 63 20 | 28 33 29 2c 0a 58 2e 49 | malloc |(3),.X.I|
|00001630| 52 20 63 61 6c 6c 6f 63 | 20 28 33 29 2c 0a 58 2e |R calloc| (3),.X.|
|00001640| 49 52 20 72 65 61 6c 6c | 6f 63 20 28 33 29 2c 0a |IR reall|oc (3),.|
|00001650| 58 61 6e 64 0a 58 2e 49 | 52 20 66 72 65 65 20 28 |Xand.X.I|R free (|
|00001660| 33 29 0a 58 28 68 65 72 | 65 61 66 74 65 72 2c 20 |3).X(her|eafter, |
|00001670| 77 65 27 6c 6c 20 63 61 | 6c 6c 20 74 68 65 73 65 |we'll ca|ll these|
|00001680| 20 74 68 65 20 22 5c 66 | 49 2a 61 6c 6c 6f 63 5c | the "\f|I*alloc\|
|00001690| 66 50 28 33 29 22 20 66 | 75 6e 63 74 69 6f 6e 73 |fP(3)" f|unctions|
|000016a0| 29 2c 0a 58 77 68 69 6c | 65 20 61 74 20 74 68 65 |),.Xwhil|e at the|
|000016b0| 20 73 61 6d 65 20 74 69 | 6d 65 20 70 65 72 66 6f | same ti|me perfo|
|000016c0| 72 6d 69 6e 67 20 63 68 | 65 63 6b 73 20 6f 66 20 |rming ch|ecks of |
|000016d0| 74 68 65 69 72 20 61 72 | 67 75 6d 65 6e 74 73 2e |their ar|guments.|
|000016e0| 0a 58 54 68 65 72 65 20 | 61 72 65 20 74 77 6f 20 |.XThere |are two |
|000016f0| 73 65 74 73 20 6f 66 20 | 6d 61 63 72 6f 73 20 64 |sets of |macros d|
|00001700| 65 66 69 6e 65 64 20 68 | 65 72 65 3a 20 6f 6e 65 |efined h|ere: one|
|00001710| 20 77 69 74 68 6f 75 74 | 20 65 78 63 65 70 74 69 | without| excepti|
|00001720| 6f 6e 20 68 61 6e 64 6c | 69 6e 67 0a 58 28 6c 69 |on handl|ing.X(li|
|00001730| 6b 65 20 74 68 65 0a 58 | 2e 49 52 20 2a 61 6c 6c |ke the.X|.IR *all|
|00001740| 6f 63 20 28 33 29 0a 58 | 66 75 6e 63 74 69 6f 6e |oc (3).X|function|
|00001750| 73 20 74 68 65 6d 73 65 | 6c 76 65 73 29 20 61 6e |s themse|lves) an|
|00001760| 64 20 6f 6e 65 20 77 69 | 74 68 2e 0a 58 2e 4c 50 |d one wi|th..X.LP|
|00001770| 0a 58 54 68 65 20 6d 61 | 63 72 6f 73 20 77 69 74 |.XThe ma|cros wit|
|00001780| 68 6f 75 74 20 65 78 63 | 65 70 74 69 6f 6e 20 68 |hout exc|eption h|
|00001790| 61 6e 64 6c 69 6e 67 20 | 61 72 65 3a 0a 58 2e 49 |andling |are:.X.I|
|000017a0| 50 20 22 22 0a 58 43 41 | 4c 4c 4f 43 5f 4c 49 4e |P "".XCA|LLOC_LIN|
|000017b0| 54 4f 4b 28 70 74 72 2c | 20 6e 65 6c 65 6d 2c 20 |TOK(ptr,| nelem, |
|000017c0| 74 79 70 65 29 0a 58 2e | 62 72 0a 58 4d 41 4c 4c |type).X.|br.XMALL|
|000017d0| 4f 43 5f 4c 49 4e 54 4f | 4b 28 70 74 72 2c 20 6e |OC_LINTO|K(ptr, n|
|000017e0| 65 6c 65 6d 2c 20 74 79 | 70 65 29 0a 58 2e 62 72 |elem, ty|pe).X.br|
|000017f0| 0a 58 52 45 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |.XREALLO|C_LINTOK|
|00001800| 28 70 74 72 2c 20 6e 65 | 6c 65 6d 2c 20 74 79 70 |(ptr, ne|lem, typ|
|00001810| 65 29 0a 58 2e 62 72 0a | 58 46 52 45 45 5f 4c 49 |e).X.br.|XFREE_LI|
|00001820| 4e 54 4f 4b 28 70 74 72 | 29 0a 58 2e 62 72 0a 58 |NTOK(ptr|).X.br.X|
|00001830| 2e 4c 50 0a 58 77 68 65 | 72 65 20 22 70 74 72 22 |.LP.Xwhe|re "ptr"|
|00001840| 20 69 73 20 61 20 76 61 | 72 69 61 62 6c 65 20 6f | is a va|riable o|
|00001850| 66 20 74 79 70 65 20 22 | 74 79 70 65 20 2a 22 2e |f type "|type *".|
|00001860| 20 20 41 66 74 65 72 20 | 69 6e 76 6f 6b 69 6e 67 | After |invoking|
|00001870| 20 61 6e 79 0a 58 6f 66 | 20 74 68 65 20 22 2a 41 | any.Xof| the "*A|
|00001880| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 22 20 6d 61 63 |LLOC_LIN|TOK" mac|
|00001890| 72 6f 73 2c 20 22 70 74 | 72 22 20 77 69 6c 6c 20 |ros, "pt|r" will |
|000018a0| 65 69 74 68 65 72 20 62 | 65 20 4e 55 4c 4c 20 28 |either b|e NULL (|
|000018b0| 69 66 20 61 6e 64 0a 58 | 6f 6e 6c 79 20 69 66 20 |if and.X|only if |
|000018c0| 74 68 65 0a 58 75 6e 64 | 65 72 6c 79 69 6e 67 20 |the.Xund|erlying |
|000018d0| 66 75 6e 63 74 69 6f 6e | 20 72 65 74 75 72 6e 65 |function| returne|
|000018e0| 64 20 69 74 29 20 6f 72 | 20 69 74 20 77 69 6c 6c |d it) or| it will|
|000018f0| 20 70 6f 69 6e 74 20 74 | 6f 20 61 6e 20 61 72 72 | point t|o an arr|
|00001900| 61 79 20 6f 66 0a 58 22 | 6e 65 6c 65 6d 22 20 6f |ay of.X"|nelem" o|
|00001910| 62 6a 65 63 74 73 20 6f | 66 20 74 79 70 65 20 22 |bjects o|f type "|
|00001920| 74 79 70 65 22 2e 0a 58 | 2e 4c 50 0a 58 4e 6f 74 |type"..X|.LP.XNot|
|00001930| 65 20 74 68 61 74 20 74 | 68 65 20 75 73 61 67 65 |e that t|he usage|
|00001940| 20 6f 66 20 4d 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f | of MALL|OC_LINTO|
|00001950| 4b 2c 20 43 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |K, CALLO|C_LINTOK|
|00001960| 2c 20 61 6e 64 0a 58 52 | 45 41 4c 4c 4f 43 5f 4c |, and.XR|EALLOC_L|
|00001970| 49 4e 54 4f 4b 20 72 65 | 71 75 69 72 65 73 20 6d |INTOK re|quires m|
|00001980| 6f 72 65 20 74 68 61 6e | 20 61 20 6e 61 6d 65 20 |ore than| a name |
|00001990| 63 68 61 6e 67 65 2e 20 | 20 41 6e 20 6f 72 69 67 |change. | An orig|
|000019a0| 69 6e 61 6c 0a 58 63 61 | 6c 6c 20 6f 66 20 74 68 |inal.Xca|ll of th|
|000019b0| 65 20 66 6f 72 6d 3a 0a | 58 2e 49 50 0a 58 70 74 |e form:.|X.IP.Xpt|
|000019c0| 72 20 3d 20 28 74 79 70 | 65 20 2a 29 20 6d 61 6c |r = (typ|e *) mal|
|000019d0| 6c 6f 63 28 6e 65 6c 65 | 6d 20 2a 20 73 69 7a 65 |loc(nele|m * size|
|000019e0| 6f 66 28 74 79 70 65 29 | 29 0a 58 2e 4c 50 0a 58 |of(type)|).X.LP.X|
|000019f0| 6d 75 73 74 20 62 65 20 | 72 65 70 6c 61 63 65 64 |must be |replaced|
|00001a00| 20 62 79 0a 58 2e 49 50 | 0a 58 4d 41 4c 4c 4f 43 | by.X.IP|.XMALLOC|
|00001a10| 5f 4c 49 4e 54 4f 4b 28 | 70 74 72 2c 20 6e 65 6c |_LINTOK(|ptr, nel|
|00001a20| 65 6d 2c 20 74 79 70 65 | 29 0a 58 2e 4c 50 0a 58 |em, type|).X.LP.X|
|00001a30| 61 6e 64 20 73 69 6d 69 | 6c 61 72 6c 79 20 66 6f |and simi|larly fo|
|00001a40| 72 20 43 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 20 |r CALLOC|_LINTOK |
|00001a50| 61 6e 64 20 52 45 41 4c | 4c 4f 43 5f 4c 49 4e 54 |and REAL|LOC_LINT|
|00001a60| 4f 4b 2e 20 20 41 6c 6c | 20 74 68 72 65 65 0a 58 |OK. All| three.X|
|00001a70| 6d 61 63 72 6f 73 20 22 | 72 65 74 75 72 6e 22 20 |macros "|return" |
|00001a80| 76 61 6c 75 65 73 20 61 | 6e 64 20 6d 61 79 20 74 |values a|nd may t|
|00001a90| 68 65 72 65 66 6f 72 65 | 20 62 65 20 75 73 65 64 |herefore| be used|
|00001aa0| 20 61 73 20 70 61 72 74 | 20 6f 66 0a 58 65 78 70 | as part| of.Xexp|
|00001ab0| 72 65 73 73 69 6f 6e 73 | 2e 0a 58 2e 4c 50 0a 58 |ressions|..X.LP.X|
|00001ac0| 49 66 20 61 20 6d 61 63 | 72 6f 27 73 20 72 65 73 |If a mac|ro's res|
|00001ad0| 75 6c 74 20 69 73 20 63 | 6f 6d 70 61 72 65 64 20 |ult is c|ompared |
|00001ae0| 77 69 74 68 20 4e 55 4c | 4c 2c 20 6c 69 6e 74 20 |with NUL|L, lint |
|00001af0| 77 69 6c 6c 20 75 73 75 | 61 6c 6c 79 20 63 6f 6d |will usu|ally com|
|00001b00| 70 6c 61 69 6e 0a 58 69 | 66 20 4e 55 4c 4c 20 69 |plain.Xi|f NULL i|
|00001b10| 73 20 63 61 73 74 20 74 | 6f 20 61 6e 79 74 68 69 |s cast t|o anythi|
|00001b20| 6e 67 2e 20 20 46 6f 72 | 20 65 78 61 6d 70 6c 65 |ng. For| example|
|00001b30| 2c 20 74 68 69 73 20 77 | 69 6c 6c 20 70 72 6f 64 |, this w|ill prod|
|00001b40| 75 63 65 20 61 20 6c 69 | 6e 74 20 65 72 72 6f 72 |uce a li|nt error|
|00001b50| 3a 0a 58 2e 49 50 0a 58 | 69 6e 74 20 2a 69 61 3b |:.X.IP.X|int *ia;|
|00001b60| 0a 58 2e 62 72 0a 58 20 | 2e 2e 2e 0a 58 2e 62 72 |.X.br.X |....X.br|
|00001b70| 0a 58 69 66 20 28 4d 41 | 4c 4c 4f 43 5f 4c 49 4e |.Xif (MA|LLOC_LIN|
|00001b80| 54 4f 4b 28 69 61 2c 20 | 34 32 2c 20 69 6e 74 29 |TOK(ia, |42, int)|
|00001b90| 20 3d 3d 20 28 69 6e 74 | 20 2a 29 20 4e 55 4c 4c | == (int| *) NULL|
|00001ba0| 29 0a 58 2e 62 72 0a 58 | 20 2e 2e 2e 0a 58 2e 4c |).X.br.X| ....X.L|
|00001bb0| 50 0a 58 42 75 74 20 73 | 69 6e 63 65 20 75 6e 63 |P.XBut s|ince unc|
|00001bc0| 61 73 74 20 30 20 28 69 | 2e 65 2e 2c 20 4e 55 4c |ast 0 (i|.e., NUL|
|00001bd0| 4c 29 20 69 73 20 61 6c | 77 61 79 73 20 61 20 76 |L) is al|ways a v|
|00001be0| 61 6c 69 64 20 70 6f 69 | 6e 74 65 72 2c 20 69 74 |alid poi|nter, it|
|00001bf0| 0a 58 69 73 20 75 6e 6e | 65 63 65 73 73 61 72 79 |.Xis unn|ecessary|
|00001c00| 20 74 6f 20 63 61 73 74 | 20 69 74 20 74 6f 20 61 | to cast| it to a|
|00001c10| 6e 79 74 68 69 6e 67 2e | 0a 58 52 65 6d 6f 76 69 |nything.|.XRemovi|
|00001c20| 6e 67 20 74 68 65 20 63 | 61 73 74 20 73 74 6f 70 |ng the c|ast stop|
|00001c30| 73 20 74 68 65 20 6c 69 | 6e 74 20 63 6f 6d 70 6c |s the li|nt compl|
|00001c40| 61 69 6e 74 3a 0a 58 2e | 49 50 0a 58 20 2e 2e 2e |aint:.X.|IP.X ...|
|00001c50| 0a 58 2e 62 72 0a 58 69 | 66 20 28 4d 41 4c 4c 4f |.X.br.Xi|f (MALLO|
|00001c60| 43 5f 4c 49 4e 54 4f 4b | 28 69 61 2c 20 34 32 2c |C_LINTOK|(ia, 42,|
|00001c70| 20 69 6e 74 29 20 3d 3d | 20 4e 55 4c 4c 29 0a 58 | int) ==| NULL).X|
|00001c80| 2e 62 72 0a 58 20 2e 2e | 2e 0a 58 2e 4c 50 0a 58 |.br.X ..|..X.LP.X|
|00001c90| 49 66 20 74 68 65 20 6d | 61 63 72 6f 20 69 6e 76 |If the m|acro inv|
|00001ca0| 6f 63 61 74 69 6f 6e 20 | 64 6f 65 73 6e 27 74 20 |ocation |doesn't |
|00001cb0| 61 70 70 65 61 72 20 77 | 69 74 68 69 6e 20 61 6e |appear w|ithin an|
|00001cc0| 20 65 78 70 72 65 73 73 | 69 6f 6e 2c 0a 58 79 6f | express|ion,.Xyo|
|00001cd0| 75 20 77 69 6c 6c 20 6e | 65 65 64 20 74 6f 20 63 |u will n|eed to c|
|00001ce0| 61 73 74 20 74 68 65 20 | 2a 41 4c 4c 4f 43 5f 4c |ast the |*ALLOC_L|
|00001cf0| 49 4e 54 4f 4b 28 29 0a | 58 69 6e 76 6f 63 61 74 |INTOK().|Xinvocat|
|00001d00| 69 6f 6e 73 20 74 6f 0a | 58 2e 42 20 76 6f 69 64 |ions to.|X.B void|
|00001d10| 0a 58 69 66 20 79 6f 75 | 20 77 61 6e 74 20 74 6f |.Xif you| want to|
|00001d20| 20 67 65 74 20 72 69 64 | 20 6f 66 20 74 68 65 0a | get rid| of the.|
|00001d30| 58 22 2a 61 6c 6c 6f 63 | 20 72 65 74 75 72 6e 73 |X"*alloc| returns|
|00001d40| 20 76 61 6c 75 65 20 77 | 68 69 63 68 20 69 73 20 | value w|hich is |
|00001d50| 73 6f 6d 65 74 69 6d 65 | 73 20 69 67 6e 6f 72 65 |sometime|s ignore|
|00001d60| 64 22 0a 58 61 6e 64 0a | 58 22 2a 61 6c 6c 6f 63 |d".Xand.|X"*alloc|
|00001d70| 20 72 65 74 75 72 6e 73 | 20 76 61 6c 75 65 20 77 | returns| value w|
|00001d80| 68 69 63 68 20 69 73 20 | 61 6c 77 61 79 73 20 69 |hich is |always i|
|00001d90| 67 6e 6f 72 65 64 22 0a | 58 6d 65 73 73 61 67 65 |gnored".|Xmessage|
|00001da0| 73 2e 0a 58 2e 4c 50 0a | 58 59 6f 75 20 63 61 6e |s..X.LP.|XYou can|
|00001db0| 20 6d 69 78 20 69 6e 76 | 6f 63 61 74 69 6f 6e 73 | mix inv|ocations|
|00001dc0| 20 6f 66 20 74 68 65 73 | 65 20 6d 61 63 72 6f 73 | of thes|e macros|
|00001dd0| 20 77 69 74 68 20 63 61 | 6c 6c 73 20 74 6f 20 74 | with ca|lls to t|
|00001de0| 68 65 20 6f 72 69 67 69 | 6e 61 6c 0a 58 66 75 6e |he origi|nal.Xfun|
|00001df0| 63 74 69 6f 6e 73 2e 20 | 20 54 68 65 20 6f 6e 6c |ctions. | The onl|
|00001e00| 79 20 64 69 66 66 65 72 | 65 6e 63 65 20 69 73 20 |y differ|ence is |
|00001e10| 69 6e 20 74 68 65 20 6c | 69 6e 74 20 62 65 68 61 |in the l|int beha|
|00001e20| 76 69 6f 72 2e 0a 58 2e | 4c 50 0a 58 41 20 63 6f |vior..X.|LP.XA co|
|00001e30| 6d 6d 6f 6e 20 77 61 79 | 20 6f 66 20 69 6e 76 6f |mmon way| of invo|
|00001e40| 6b 69 6e 67 20 74 68 65 | 20 6d 65 6d 6f 72 79 20 |king the| memory |
|00001e50| 6d 61 6e 61 67 65 6d 65 | 6e 74 20 66 75 6e 63 74 |manageme|nt funct|
|00001e60| 69 6f 6e 73 20 69 73 20 | 74 6f 20 63 61 6c 6c 0a |ions is |to call.|
|00001e70| 58 2e 49 52 20 6d 61 6c | 6c 6f 63 20 28 29 0a 58 |X.IR mal|loc ().X|
|00001e80| 69 66 20 61 0a 58 70 6f | 69 6e 74 65 72 20 69 73 |if a.Xpo|inter is|
|00001e90| 20 4e 55 4c 4c 20 28 75 | 73 75 61 6c 6c 79 20 74 | NULL (u|sually t|
|00001ea0| 68 65 20 66 69 72 73 74 | 20 74 69 6d 65 20 69 74 |he first| time it|
|00001eb0| 27 73 20 73 65 74 29 20 | 61 6e 64 0a 58 2e 49 52 |'s set) |and.X.IR|
|00001ec0| 20 72 65 61 6c 6c 6f 63 | 20 28 29 0a 58 69 66 20 | realloc| ().Xif |
|00001ed0| 69 74 20 69 73 6e 27 74 | 20 4e 55 4c 4c 20 28 75 |it isn't| NULL (u|
|00001ee0| 73 75 61 6c 6c 79 20 6f | 6e 20 73 75 62 73 65 71 |sually o|n subseq|
|00001ef0| 75 65 6e 74 20 74 69 6d | 65 73 29 2e 20 20 54 68 |uent tim|es). Th|
|00001f00| 65 20 73 69 6d 70 6c 65 | 20 6d 61 63 72 6f 0a 58 |e simple| macro.X|
|00001f10| 2e 49 50 0a 58 4d 52 5f | 41 4c 4c 4f 43 5f 4c 49 |.IP.XMR_|ALLOC_LI|
|00001f20| 4e 54 4f 4b 28 70 74 72 | 2c 20 6e 65 6c 65 6d 2c |NTOK(ptr|, nelem,|
|00001f30| 20 74 79 70 65 29 0a 58 | 2e 4c 50 0a 58 64 6f 65 | type).X|.LP.Xdoe|
|00001f40| 73 20 74 68 69 73 20 77 | 69 74 68 20 4d 41 4c 4c |s this w|ith MALL|
|00001f50| 4f 43 5f 4c 49 4e 54 4f | 4b 28 29 20 61 6e 64 20 |OC_LINTO|K() and |
|00001f60| 52 45 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 28 29 |REALLOC_|LINTOK()|
|00001f70| 2e 0a 58 2e 4c 50 0a 58 | 53 69 6e 63 65 20 6d 65 |..X.LP.X|Since me|
|00001f80| 6d 6f 72 79 20 61 6c 6c | 6f 63 61 74 69 6f 6e 20 |mory all|ocation |
|00001f90| 66 61 69 6c 75 72 65 20 | 69 73 20 6f 66 74 65 6e |failure |is often|
|00001fa0| 20 61 6e 20 65 78 63 65 | 70 74 69 6f 6e 61 6c 20 | an exce|ptional |
|00001fb0| 63 6f 6e 64 69 74 69 6f | 6e 2c 0a 58 22 6d 65 6d |conditio|n,.X"mem|
|00001fc0| 6c 69 6e 74 6f 6b 2e 68 | 22 20 61 6c 73 6f 20 68 |lintok.h|" also h|
|00001fd0| 61 73 20 64 65 66 69 6e | 69 74 69 6f 6e 73 20 6f |as defin|itions o|
|00001fe0| 66 20 66 6f 75 72 20 6f | 74 68 65 72 20 75 73 65 |f four o|ther use|
|00001ff0| 66 75 6c 20 6d 61 63 72 | 6f 73 20 74 68 61 74 20 |ful macr|os that |
|00002000| 69 6e 63 6c 75 64 65 0a | 58 65 78 63 65 70 74 69 |include.|Xexcepti|
|00002010| 6f 6e 20 68 61 6e 64 6c | 69 6e 67 3a 0a 58 2e 49 |on handl|ing:.X.I|
|00002020| 50 0a 58 43 41 4c 4c 4f | 43 5f 4f 52 5f 45 4c 53 |P.XCALLO|C_OR_ELS|
|00002030| 45 5f 4c 49 4e 54 4f 4b | 28 70 74 72 2c 20 6e 65 |E_LINTOK|(ptr, ne|
|00002040| 6c 65 6d 2c 20 74 79 70 | 65 29 0a 58 2e 62 72 0a |lem, typ|e).X.br.|
|00002050| 58 4d 41 4c 4c 4f 43 5f | 4f 52 5f 45 4c 53 45 5f |XMALLOC_|OR_ELSE_|
|00002060| 4c 49 4e 54 4f 4b 28 70 | 74 72 2c 20 6e 65 6c 65 |LINTOK(p|tr, nele|
|00002070| 6d 2c 20 74 79 70 65 29 | 0a 58 2e 62 72 0a 58 52 |m, type)|.X.br.XR|
|00002080| 45 41 4c 4c 4f 43 5f 4f | 52 5f 45 4c 53 45 5f 4c |EALLOC_O|R_ELSE_L|
|00002090| 49 4e 54 4f 4b 28 70 74 | 72 2c 20 6e 65 6c 65 6d |INTOK(pt|r, nelem|
|000020a0| 2c 20 74 79 70 65 29 0a | 58 2e 62 72 0a 58 4d 52 |, type).|X.br.XMR|
|000020b0| 5f 41 4c 4c 4f 43 5f 4f | 52 5f 45 4c 53 45 5f 4c |_ALLOC_O|R_ELSE_L|
|000020c0| 49 4e 54 4f 4b 28 70 74 | 72 2c 20 6e 65 6c 65 6d |INTOK(pt|r, nelem|
|000020d0| 2c 20 74 79 70 65 29 0a | 58 2e 62 72 0a 58 2e 4c |, type).|X.br.X.L|
|000020e0| 50 0a 58 45 61 63 68 20 | 6f 66 20 74 68 65 73 65 |P.XEach |of these|
|000020f0| 20 6d 61 63 72 6f 73 20 | 69 6e 76 6f 6b 65 73 20 | macros |invokes |
|00002100| 74 68 65 20 63 6f 72 72 | 65 73 70 6f 6e 64 69 6e |the corr|espondin|
|00002110| 67 20 2a 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 |g *ALLOC|_LINTOK(|
|00002120| 29 20 6d 61 63 72 6f 20 | 61 6e 64 2c 0a 58 69 66 |) macro |and,.Xif|
|00002130| 20 74 68 61 74 20 6d 61 | 63 72 6f 20 66 61 69 6c | that ma|cro fail|
|00002140| 73 2c 20 69 6e 76 6f 6b | 65 73 20 61 6e 6f 74 68 |s, invok|es anoth|
|00002150| 65 72 20 6d 61 63 72 6f | 3a 0a 58 2e 49 50 0a 58 |er macro|:.X.IP.X|
|00002160| 45 52 52 4f 52 5f 45 58 | 49 54 5f 4c 49 4e 54 4f |ERROR_EX|IT_LINTO|
|00002170| 4b 28 6e 65 6c 65 6d 2c | 20 73 69 7a 65 29 0a 58 |K(nelem,| size).X|
|00002180| 2e 4c 50 0a 58 57 68 65 | 72 65 20 22 6e 65 6c 65 |.LP.XWhe|re "nele|
|00002190| 6d 22 20 69 73 20 74 68 | 65 20 6e 75 6d 62 65 72 |m" is th|e number|
|000021a0| 20 6f 66 20 65 6c 65 6d | 65 6e 74 73 20 6f 66 20 | of elem|ents of |
|000021b0| 22 73 69 7a 65 22 20 62 | 79 74 65 73 20 61 74 74 |"size" b|ytes att|
|000021c0| 65 6d 70 74 69 6e 67 20 | 74 6f 20 62 65 0a 58 61 |empting |to be.Xa|
|000021d0| 6c 6c 6f 63 61 74 65 64 | 2e 0a 58 2e 4c 50 0a 58 |llocated|..X.LP.X|
|000021e0| 41 20 64 65 66 61 75 6c | 74 20 45 52 52 4f 52 5f |A defaul|t ERROR_|
|000021f0| 45 58 49 54 5f 4c 49 4e | 54 4f 4b 28 6e 65 6c 65 |EXIT_LIN|TOK(nele|
|00002200| 6d 2c 20 73 69 7a 65 29 | 2c 20 77 68 69 63 68 20 |m, size)|, which |
|00002210| 70 72 69 6e 74 73 20 61 | 6e 20 69 6e 66 6f 72 6d |prints a|n inform|
|00002220| 61 74 69 76 65 0a 58 6d | 65 73 73 61 67 65 20 61 |ative.Xm|essage a|
|00002230| 6e 64 20 64 69 65 73 2c | 20 69 73 20 61 6c 73 6f |nd dies,| is also|
|00002240| 20 64 65 66 69 6e 65 64 | 2c 20 62 75 74 20 79 6f | defined|, but yo|
|00002250| 75 20 61 72 65 20 66 72 | 65 65 20 74 6f 20 72 65 |u are fr|ee to re|
|00002260| 64 65 66 69 6e 65 20 69 | 74 0a 58 28 61 66 74 65 |define i|t.X(afte|
|00002270| 72 20 69 6e 63 6c 75 64 | 69 6e 67 20 22 6d 65 6d |r includ|ing "mem|
|00002280| 6c 69 6e 74 6f 6b 2e 68 | 22 20 61 6e 64 20 62 65 |lintok.h|" and be|
|00002290| 66 6f 72 65 20 69 6e 76 | 6f 6b 69 6e 67 20 61 6e |fore inv|oking an|
|000022a0| 79 20 6f 66 20 74 68 65 | 20 6d 61 63 72 6f 73 20 |y of the| macros |
|000022b0| 68 65 72 65 69 6e 0a 58 | 2d 2d 20 72 65 6d 65 6d |herein.X|-- remem|
|000022c0| 62 65 72 20 74 6f 20 22 | 23 75 6e 64 65 66 20 45 |ber to "|#undef E|
|000022d0| 52 52 4f 52 5f 45 58 49 | 54 5f 4c 49 4e 54 4f 4b |RROR_EXI|T_LINTOK|
|000022e0| 22 20 66 69 72 73 74 29 | 0a 58 69 66 20 79 6f 75 |" first)|.Xif you|
|000022f0| 20 77 61 6e 74 20 74 6f | 20 64 6f 20 79 6f 75 72 | want to| do your|
|00002300| 20 6f 77 6e 20 65 72 72 | 6f 72 20 68 61 6e 64 6c | own err|or handl|
|00002310| 69 6e 67 2e 0a 58 2e 53 | 48 20 22 53 45 45 20 41 |ing..X.S|H "SEE A|
|00002320| 4c 53 4f 22 0a 58 2e 42 | 52 20 6d 61 6c 6c 6f 63 |LSO".X.B|R malloc|
|00002330| 20 28 33 29 2c 0a 58 2e | 42 52 20 73 74 64 69 6f | (3),.X.|BR stdio|
|00002340| 20 28 33 53 29 0a 58 2e | 53 48 20 4e 4f 54 45 0a | (3S).X.|SH NOTE.|
|00002350| 58 2e 4c 50 0a 58 22 6d | 65 6d 6c 69 6e 74 6f 6b |X.LP.X"m|emlintok|
|00002360| 2e 68 22 20 61 73 73 75 | 6d 65 73 20 4e 55 4c 4c |.h" assu|mes NULL|
|00002370| 20 69 73 20 64 65 66 69 | 6e 65 64 20 69 6e 20 3c | is defi|ned in <|
|00002380| 73 74 64 69 6f 2e 68 3e | 20 28 77 68 69 63 68 20 |stdio.h>| (which |
|00002390| 69 73 20 75 73 75 61 6c | 6c 79 20 74 68 65 20 63 |is usual|ly the c|
|000023a0| 61 73 65 29 2e 0a 58 2e | 4c 50 0a 58 49 74 20 61 |ase)..X.|LP.XIt a|
|000023b0| 6c 73 6f 20 61 73 73 75 | 6d 65 73 20 74 68 65 20 |lso assu|mes the |
|000023c0| 63 70 70 20 73 79 6d 62 | 6f 6c 20 22 6c 69 6e 74 |cpp symb|ol "lint|
|000023d0| 22 20 69 73 20 64 65 66 | 69 6e 65 64 20 77 68 65 |" is def|ined whe|
|000023e0| 6e 20 61 6e 64 20 6f 6e | 6c 79 20 77 68 65 6e 20 |n and on|ly when |
|000023f0| 74 68 65 0a 58 63 6f 64 | 65 20 69 73 20 62 65 69 |the.Xcod|e is bei|
|00002400| 6e 67 20 70 61 73 73 65 | 64 20 74 68 72 6f 75 67 |ng passe|d throug|
|00002410| 68 20 6c 69 6e 74 20 61 | 6e 64 20 6e 6f 74 20 67 |h lint a|nd not g|
|00002420| 65 6e 65 72 61 74 69 6e | 67 20 72 65 61 6c 20 65 |eneratin|g real e|
|00002430| 78 65 63 75 74 61 62 6c | 65 20 63 6f 64 65 2e 0a |xecutabl|e code..|
|00002440| 58 2e 4c 50 0a 58 54 68 | 65 73 65 20 6d 61 63 72 |X.LP.XTh|ese macr|
|00002450| 6f 73 20 68 61 76 65 20 | 62 65 65 6e 20 74 65 73 |os have |been tes|
|00002460| 74 65 64 20 75 6e 64 65 | 72 20 53 75 6e 4f 53 2c |ted unde|r SunOS,|
|00002470| 20 48 50 2d 55 58 2c 20 | 61 6e 64 20 41 70 6f 6c | HP-UX, |and Apol|
|00002480| 6c 6f 20 44 4f 4d 41 49 | 4e 2f 49 58 2e 0a 58 2e |lo DOMAI|N/IX..X.|
|00002490| 53 48 20 42 55 47 53 0a | 58 2e 4c 50 0a 58 54 68 |SH BUGS.|X.LP.XTh|
|000024a0| 65 73 65 20 6d 61 63 72 | 6f 73 20 61 72 65 20 69 |ese macr|os are i|
|000024b0| 6e 74 65 6e 64 65 64 20 | 66 6f 72 20 75 73 65 20 |ntended |for use |
|000024c0| 77 69 74 68 20 74 68 65 | 20 64 79 6e 61 6d 69 63 |with the| dynamic|
|000024d0| 0a 58 61 6c 6c 6f 63 61 | 74 69 6f 6e 20 6f 66 20 |.Xalloca|tion of |
|000024e0| 73 69 6e 67 6c 65 20 65 | 6c 65 6d 65 6e 74 73 20 |single e|lements |
|000024f0| 6f 66 20 66 69 78 65 64 | 20 73 69 7a 65 20 28 69 |of fixed| size (i|
|00002500| 2e 65 2e 20 73 74 72 75 | 63 74 73 20 6f 72 20 74 |.e. stru|cts or t|
|00002510| 79 70 65 64 65 66 73 29 | 0a 58 6f 72 20 76 61 72 |ypedefs)|.Xor var|
|00002520| 69 61 62 6c 79 2d 73 69 | 7a 65 64 20 61 72 72 61 |iably-si|zed arra|
|00002530| 79 73 20 6f 66 20 73 61 | 6d 65 2e 0a 58 49 6e 20 |ys of sa|me..XIn |
|00002540| 74 68 65 20 61 75 74 68 | 6f 72 27 73 20 65 78 70 |the auth|or's exp|
|00002550| 65 72 69 65 6e 63 65 2c | 20 74 68 69 73 20 63 6f |erience,| this co|
|00002560| 76 65 72 73 20 6d 6f 73 | 74 20 75 73 65 73 20 6f |vers mos|t uses o|
|00002570| 66 20 74 68 65 0a 58 2e | 49 52 20 5c 66 49 2a 61 |f the.X.|IR \fI*a|
|00002580| 6c 6c 6f 63 5c 66 50 20 | 28 33 29 0a 58 66 75 6e |lloc\fP |(3).Xfun|
|00002590| 63 74 69 6f 6e 73 2e 0a | 58 54 68 65 20 6d 61 63 |ctions..|XThe mac|
|000025a0| 72 6f 73 20 64 6f 20 6e | 6f 74 20 77 6f 72 6b 20 |ros do n|ot work |
|000025b0| 77 65 6c 6c 2c 20 68 6f | 77 65 76 65 72 2c 20 77 |well, ho|wever, w|
|000025c0| 68 65 6e 20 63 72 65 61 | 74 69 6e 67 20 76 61 72 |hen crea|ting var|
|000025d0| 69 61 62 6c 79 2d 73 69 | 7a 65 64 20 73 69 6e 67 |iably-si|zed sing|
|000025e0| 6c 65 0a 58 73 74 72 75 | 63 74 75 72 65 73 20 74 |le.Xstru|ctures t|
|000025f0| 68 61 74 20 61 72 65 20 | 6e 6f 74 20 61 72 72 61 |hat are |not arra|
|00002600| 79 73 2e 0a 58 2e 4c 50 | 0a 58 41 74 20 6c 65 61 |ys..X.LP|.XAt lea|
|00002610| 73 74 20 6f 6e 65 20 76 | 65 72 73 69 6f 6e 20 6f |st one v|ersion o|
|00002620| 66 0a 58 2e 49 52 20 6c | 69 6e 74 20 28 31 29 0a |f.X.IR l|int (1).|
|00002630| 58 28 53 75 6e 4f 53 20 | 34 2e 30 29 20 63 6f 6d |X(SunOS |4.0) com|
|00002640| 70 6c 61 69 6e 73 20 77 | 68 65 6e 20 74 68 65 73 |plains w|hen thes|
|00002650| 65 20 6d 61 63 72 6f 73 | 0a 58 61 72 65 20 75 73 |e macros|.Xare us|
|00002660| 65 64 20 77 69 74 68 20 | 22 76 6f 69 64 20 2a 22 |ed with |"void *"|
|00002670| 20 70 6f 69 6e 74 65 72 | 73 2e 0a 58 49 74 20 6e | pointer|s..XIt n|
|00002680| 65 65 64 6e 27 74 2e 0a | 58 2e 4c 50 0a 58 41 70 |eedn't..|X.LP.XAp|
|00002690| 6f 6c 6c 6f 20 44 4f 4d | 41 49 4e 2f 49 58 0a 58 |ollo DOM|AIN/IX.X|
|000026a0| 2e 49 52 20 6c 69 6e 74 | 20 28 31 29 0a 58 67 65 |.IR lint| (1).Xge|
|000026b0| 6e 65 72 61 74 65 73 20 | 73 65 76 65 72 61 6c 20 |nerates |several |
|000026c0| 62 6f 67 75 73 20 28 49 | 20 62 65 6c 69 65 76 65 |bogus (I| believe|
|000026d0| 29 20 63 6f 6d 70 6c 61 | 69 6e 74 73 20 61 62 6f |) compla|ints abo|
|000026e0| 75 74 20 74 68 65 20 64 | 65 66 61 75 6c 74 20 65 |ut the d|efault e|
|000026f0| 78 63 65 70 74 69 6f 6e | 0a 58 68 61 6e 64 6c 69 |xception|.Xhandli|
|00002700| 6e 67 20 6d 61 63 72 6f | 2e 0a 58 2e 53 48 20 41 |ng macro|..X.SH A|
|00002710| 55 54 48 4f 52 0a 58 2e | 4c 50 0a 58 42 6f 62 20 |UTHOR.X.|LP.XBob |
|00002720| 4c 65 77 69 73 20 28 62 | 6f 62 6c 40 74 65 73 73 |Lewis (b|obl@tess|
|00002730| 69 2e 75 75 63 70 29 20 | 70 72 6f 64 75 63 65 64 |i.uucp) |produced|
|00002740| 20 74 68 65 73 65 20 6d | 61 63 72 6f 73 20 75 73 | these m|acros us|
|00002750| 69 6e 67 20 68 69 73 20 | 6f 77 6e 0a 58 72 65 73 |ing his |own.Xres|
|00002760| 6f 75 72 63 65 73 20 61 | 6e 64 20 68 65 72 65 62 |ources a|nd hereb|
|00002770| 79 20 72 65 6c 65 61 73 | 65 73 20 74 68 65 6d 20 |y releas|es them |
|00002780| 74 6f 20 74 68 65 20 70 | 75 62 6c 69 63 20 64 6f |to the p|ublic do|
|00002790| 6d 61 69 6e 2e 0a 58 54 | 68 65 20 61 75 74 68 6f |main..XT|he autho|
|000027a0| 72 20 77 69 6c 6c 20 6e | 6f 74 20 62 65 20 68 65 |r will n|ot be he|
|000027b0| 6c 64 20 72 65 73 70 6f | 6e 73 69 62 6c 65 20 66 |ld respo|nsible f|
|000027c0| 6f 72 20 74 68 65 69 72 | 20 75 73 65 2c 20 6d 69 |or their| use, mi|
|000027d0| 73 75 73 65 2c 0a 58 61 | 62 75 73 65 2c 20 6f 72 |suse,.Xa|buse, or|
|000027e0| 20 61 6e 79 20 64 61 6d | 61 67 65 73 20 61 72 69 | any dam|ages ari|
|000027f0| 73 69 6e 67 20 66 72 6f | 6d 20 73 61 6d 65 2e 0a |sing fro|m same..|
|00002800| 45 4e 44 5f 4f 46 5f 6d | 65 6d 6c 69 6e 74 6f 6b |END_OF_m|emlintok|
|00002810| 2e 33 0a 69 66 20 74 65 | 73 74 20 34 37 30 36 20 |.3.if te|st 4706 |
|00002820| 2d 6e 65 20 60 77 63 20 | 2d 63 20 3c 6d 65 6d 6c |-ne `wc |-c <meml|
|00002830| 69 6e 74 6f 6b 2e 33 60 | 3b 20 74 68 65 6e 0a 20 |intok.3`|; then. |
|00002840| 20 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 5c 22 | echo |shar: \"|
|00002850| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 33 5c 22 20 75 6e |memlinto|k.3\" un|
|00002860| 70 61 63 6b 65 64 20 77 | 69 74 68 20 77 72 6f 6e |packed w|ith wron|
|00002870| 67 20 73 69 7a 65 21 0a | 66 69 0a 23 20 65 6e 64 |g size!.|fi.# end|
|00002880| 20 6f 66 20 6f 76 65 72 | 77 72 69 74 69 6e 67 20 | of over|writing |
|00002890| 63 68 65 63 6b 0a 66 69 | 0a 69 66 20 74 65 73 74 |check.fi|.if test|
|000028a0| 20 2d 66 20 6d 65 6d 6c | 69 6e 74 6f 6b 2e 68 20 | -f meml|intok.h |
|000028b0| 2d 61 20 22 24 7b 31 7d | 22 20 21 3d 20 22 2d 63 |-a "${1}|" != "-c|
|000028c0| 22 20 3b 20 74 68 65 6e | 20 0a 20 20 65 63 68 6f |" ; then| . echo|
|000028d0| 20 73 68 61 72 3a 20 57 | 69 6c 6c 20 6e 6f 74 20 | shar: W|ill not |
|000028e0| 6f 76 65 72 2d 77 72 69 | 74 65 20 65 78 69 73 74 |over-wri|te exist|
|000028f0| 69 6e 67 20 66 69 6c 65 | 20 5c 22 6d 65 6d 6c 69 |ing file| \"memli|
|00002900| 6e 74 6f 6b 2e 68 5c 22 | 0a 65 6c 73 65 0a 65 63 |ntok.h\"|.else.ec|
|00002910| 68 6f 20 73 68 61 72 3a | 20 45 78 74 72 61 63 74 |ho shar:| Extract|
|00002920| 69 6e 67 20 5c 22 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |ing \"me|mlintok.|
|00002930| 68 5c 22 20 5c 28 32 39 | 38 36 20 63 68 61 72 61 |h\" \(29|86 chara|
|00002940| 63 74 65 72 73 5c 29 0a | 73 65 64 20 22 73 2f 5e |cters\).|sed "s/^|
|00002950| 58 2f 2f 22 20 3e 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |X//" >me|mlintok.|
|00002960| 68 20 3c 3c 27 45 4e 44 | 5f 4f 46 5f 6d 65 6d 6c |h <<'END|_OF_meml|
|00002970| 69 6e 74 6f 6b 2e 68 27 | 0a 58 23 69 66 6e 64 65 |intok.h'|.X#ifnde|
|00002980| 66 20 49 4e 43 4c 55 44 | 45 44 5f 4c 49 4e 54 4f |f INCLUD|ED_LINTO|
|00002990| 4b 0a 58 0a 58 2f 2a 20 | 24 48 65 61 64 65 72 3a |K.X.X/* |$Header:|
|000029a0| 20 6d 65 6d 6c 69 6e 74 | 6f 6b 2e 68 2c 76 20 31 | memlint|ok.h,v 1|
|000029b0| 2e 33 20 38 39 2f 30 35 | 2f 30 32 20 31 35 3a 30 |.3 89/05|/02 15:0|
|000029c0| 31 3a 34 33 20 62 6f 62 | 6c 20 4c 6f 63 6b 65 64 |1:43 bob|l Locked|
|000029d0| 20 24 20 2a 2f 0a 58 0a | 58 2f 2a 0a 58 20 2a 09 | $ */.X.|X/*.X *.|
|000029e0| 54 68 65 73 65 20 64 65 | 66 69 6e 69 74 69 6f 6e |These de|finition|
|000029f0| 73 20 73 74 6f 70 20 6c | 69 6e 74 20 66 72 6f 6d |s stop l|int from|
|00002a00| 20 63 6f 6d 70 6c 61 69 | 6e 69 6e 67 20 61 62 6f | complai|ning abo|
|00002a10| 75 74 20 6d 61 6c 6c 6f | 63 2c 20 63 61 6c 6c 6f |ut mallo|c, callo|
|00002a20| 63 2c 0a 58 20 2a 09 72 | 65 61 6c 6c 6f 63 2c 20 |c,.X *.r|ealloc, |
|00002a30| 61 6e 64 20 66 72 65 65 | 20 77 68 69 6c 65 20 61 |and free| while a|
|00002a40| 74 20 74 68 65 20 73 61 | 6d 65 20 74 69 6d 65 20 |t the sa|me time |
|00002a50| 70 65 72 66 6f 72 6d 69 | 6e 67 20 63 68 65 63 6b |performi|ng check|
|00002a60| 73 20 6f 66 0a 58 20 2a | 09 74 68 65 69 72 20 61 |s of.X *|.their a|
|00002a70| 72 67 75 6d 65 6e 74 73 | 2e 20 20 53 65 65 20 74 |rguments|. See t|
|00002a80| 68 65 20 6d 65 6d 6c 69 | 6e 74 6f 6b 28 33 29 20 |he memli|ntok(3) |
|00002a90| 6d 61 6e 20 70 61 67 65 | 20 66 6f 72 20 6d 6f 72 |man page| for mor|
|00002aa0| 65 20 64 65 74 61 69 6c | 73 2e 0a 58 20 2a 0a 58 |e detail|s..X *.X|
|00002ab0| 20 2a 09 42 6f 62 20 4c | 65 77 69 73 20 28 62 6f | *.Bob L|ewis (bo|
|00002ac0| 62 6c 40 74 65 73 73 69 | 2e 75 75 63 70 29 20 70 |bl@tessi|.uucp) p|
|00002ad0| 72 6f 64 75 63 65 64 20 | 74 68 65 73 65 20 6d 61 |roduced |these ma|
|00002ae0| 63 72 6f 73 20 75 73 69 | 6e 67 20 68 69 73 20 6f |cros usi|ng his o|
|00002af0| 77 6e 0a 58 20 2a 09 72 | 65 73 6f 75 72 63 65 73 |wn.X *.r|esources|
|00002b00| 20 61 6e 64 20 68 65 72 | 65 62 79 20 72 65 6c 65 | and her|eby rele|
|00002b10| 61 73 65 73 20 74 68 65 | 6d 20 74 6f 20 74 68 65 |ases the|m to the|
|00002b20| 20 70 75 62 6c 69 63 20 | 64 6f 6d 61 69 6e 2e 0a | public |domain..|
|00002b30| 58 20 2a 09 54 68 65 20 | 61 75 74 68 6f 72 20 77 |X *.The |author w|
|00002b40| 69 6c 6c 20 6e 6f 74 20 | 62 65 20 68 65 6c 64 20 |ill not |be held |
|00002b50| 72 65 73 70 6f 6e 73 69 | 62 6c 65 20 66 6f 72 20 |responsi|ble for |
|00002b60| 74 68 65 69 72 20 75 73 | 65 2c 20 6d 69 73 75 73 |their us|e, misus|
|00002b70| 65 2c 0a 58 20 2a 09 61 | 62 75 73 65 2c 20 6f 72 |e,.X *.a|buse, or|
|00002b80| 20 61 6e 79 20 64 61 6d | 61 67 65 73 20 61 72 69 | any dam|ages ari|
|00002b90| 73 69 6e 67 20 66 72 6f | 6d 20 73 61 6d 65 2e 0a |sing fro|m same..|
|00002ba0| 58 20 2a 2f 0a 58 0a 58 | 23 69 66 6e 64 65 66 20 |X */.X.X|#ifndef |
|00002bb0| 4e 55 4c 4c 0a 58 23 69 | 6e 63 6c 75 64 65 20 3c |NULL.X#i|nclude <|
|00002bc0| 73 74 64 69 6f 2e 68 3e | 0a 58 23 65 6e 64 69 66 |stdio.h>|.X#endif|
|00002bd0| 0a 58 0a 58 65 78 74 65 | 72 6e 20 63 68 61 72 20 |.X.Xexte|rn char |
|00002be0| 2a 63 61 6c 6c 6f 63 28 | 29 3b 0a 58 23 69 66 64 |*calloc(|);.X#ifd|
|00002bf0| 65 66 20 6c 69 6e 74 0a | 58 23 64 65 66 69 6e 65 |ef lint.|X#define|
|00002c00| 20 43 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 28 70 | CALLOC_|LINTOK(p|
|00002c10| 74 72 2c 20 6e 65 6c 65 | 6d 2c 20 74 79 70 65 29 |tr, nele|m, type)|
|00002c20| 20 5c 0a 58 09 63 61 6c | 6c 6f 63 28 28 70 74 72 | \.X.cal|loc((ptr|
|00002c30| 20 3d 20 28 74 79 70 65 | 20 2a 29 20 4e 55 4c 4c | = (type| *) NULL|
|00002c40| 2c 20 28 75 6e 73 69 67 | 6e 65 64 29 20 28 6e 65 |, (unsig|ned) (ne|
|00002c50| 6c 65 6d 29 29 2c 20 28 | 75 6e 73 69 67 6e 65 64 |lem)), (|unsigned|
|00002c60| 29 20 73 69 7a 65 6f 66 | 28 74 79 70 65 29 29 0a |) sizeof|(type)).|
|00002c70| 58 23 65 6c 73 65 0a 58 | 23 64 65 66 69 6e 65 20 |X#else.X|#define |
|00002c80| 43 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 28 70 74 |CALLOC_L|INTOK(pt|
|00002c90| 72 2c 20 6e 65 6c 65 6d | 2c 20 74 79 70 65 29 20 |r, nelem|, type) |
|00002ca0| 5c 0a 58 09 28 70 74 72 | 20 3d 20 28 74 79 70 65 |\.X.(ptr| = (type|
|00002cb0| 20 2a 29 20 63 61 6c 6c | 6f 63 28 28 75 6e 73 69 | *) call|oc((unsi|
|00002cc0| 67 6e 65 64 29 20 28 6e | 65 6c 65 6d 29 2c 20 28 |gned) (n|elem), (|
|00002cd0| 75 6e 73 69 67 6e 65 64 | 29 20 73 69 7a 65 6f 66 |unsigned|) sizeof|
|00002ce0| 28 74 79 70 65 29 29 29 | 0a 58 23 65 6e 64 69 66 |(type)))|.X#endif|
|00002cf0| 0a 58 0a 58 65 78 74 65 | 72 6e 20 63 68 61 72 20 |.X.Xexte|rn char |
|00002d00| 2a 6d 61 6c 6c 6f 63 28 | 29 3b 0a 58 23 69 66 64 |*malloc(|);.X#ifd|
|00002d10| 65 66 20 6c 69 6e 74 0a | 58 23 64 65 66 69 6e 65 |ef lint.|X#define|
|00002d20| 20 4d 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 28 70 | MALLOC_|LINTOK(p|
|00002d30| 74 72 2c 20 6e 65 6c 65 | 6d 2c 20 74 79 70 65 29 |tr, nele|m, type)|
|00002d40| 20 5c 0a 58 09 6d 61 6c | 6c 6f 63 28 28 70 74 72 | \.X.mal|loc((ptr|
|00002d50| 20 3d 20 28 74 79 70 65 | 20 2a 29 20 4e 55 4c 4c | = (type| *) NULL|
|00002d60| 2c 20 28 75 6e 73 69 67 | 6e 65 64 29 20 28 28 6e |, (unsig|ned) ((n|
|00002d70| 65 6c 65 6d 29 20 2a 20 | 73 69 7a 65 6f 66 28 74 |elem) * |sizeof(t|
|00002d80| 79 70 65 29 29 29 29 0a | 58 23 65 6c 73 65 0a 58 |ype)))).|X#else.X|
|00002d90| 23 64 65 66 69 6e 65 20 | 4d 41 4c 4c 4f 43 5f 4c |#define |MALLOC_L|
|00002da0| 49 4e 54 4f 4b 28 70 74 | 72 2c 20 6e 65 6c 65 6d |INTOK(pt|r, nelem|
|00002db0| 2c 20 74 79 70 65 29 20 | 5c 0a 58 09 28 70 74 72 |, type) |\.X.(ptr|
|00002dc0| 20 3d 20 28 74 79 70 65 | 20 2a 29 20 6d 61 6c 6c | = (type| *) mall|
|00002dd0| 6f 63 28 28 75 6e 73 69 | 67 6e 65 64 29 20 28 28 |oc((unsi|gned) ((|
|00002de0| 6e 65 6c 65 6d 29 20 2a | 20 73 69 7a 65 6f 66 28 |nelem) *| sizeof(|
|00002df0| 74 79 70 65 29 29 29 29 | 0a 58 23 65 6e 64 69 66 |type))))|.X#endif|
|00002e00| 0a 58 0a 58 65 78 74 65 | 72 6e 20 63 68 61 72 20 |.X.Xexte|rn char |
|00002e10| 2a 72 65 61 6c 6c 6f 63 | 28 29 3b 0a 58 23 69 66 |*realloc|();.X#if|
|00002e20| 64 65 66 20 6c 69 6e 74 | 0a 58 23 64 65 66 69 6e |def lint|.X#defin|
|00002e30| 65 20 52 45 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |e REALLO|C_LINTOK|
|00002e40| 28 70 74 72 2c 20 6e 65 | 6c 65 6d 2c 20 74 79 70 |(ptr, ne|lem, typ|
|00002e50| 65 29 20 5c 0a 58 09 72 | 65 61 6c 6c 6f 63 28 20 |e) \.X.r|ealloc( |
|00002e60| 5c 0a 58 09 09 28 70 74 | 72 20 3d 20 28 74 79 70 |\.X..(pt|r = (typ|
|00002e70| 65 20 2a 29 20 4e 55 4c | 4c 2c 20 28 63 68 61 72 |e *) NUL|L, (char|
|00002e80| 20 2a 29 20 4e 55 4c 4c | 29 2c 20 5c 0a 58 09 09 | *) NULL|), \.X..|
|00002e90| 28 75 6e 73 69 67 6e 65 | 64 29 20 28 28 6e 65 6c |(unsigne|d) ((nel|
|00002ea0| 65 6d 29 20 2a 20 73 69 | 7a 65 6f 66 28 74 79 70 |em) * si|zeof(typ|
|00002eb0| 65 29 29 29 0a 58 23 65 | 6c 73 65 0a 58 23 64 65 |e))).X#e|lse.X#de|
|00002ec0| 66 69 6e 65 20 52 45 41 | 4c 4c 4f 43 5f 4c 49 4e |fine REA|LLOC_LIN|
|00002ed0| 54 4f 4b 28 70 74 72 2c | 20 6e 65 6c 65 6d 2c 20 |TOK(ptr,| nelem, |
|00002ee0| 74 79 70 65 29 20 5c 0a | 58 09 28 70 74 72 20 3d |type) \.|X.(ptr =|
|00002ef0| 20 28 74 79 70 65 20 2a | 29 20 72 65 61 6c 6c 6f | (type *|) reallo|
|00002f00| 63 28 20 5c 0a 58 09 09 | 28 63 68 61 72 20 2a 29 |c( \.X..|(char *)|
|00002f10| 20 70 74 72 2c 20 5c 0a | 58 09 09 28 75 6e 73 69 | ptr, \.|X..(unsi|
|00002f20| 67 6e 65 64 29 20 28 28 | 6e 65 6c 65 6d 29 20 2a |gned) ((|nelem) *|
|00002f30| 20 73 69 7a 65 6f 66 28 | 74 79 70 65 29 29 29 29 | sizeof(|type))))|
|00002f40| 0a 58 23 65 6e 64 69 66 | 0a 58 0a 58 2f 2a 20 63 |.X#endif|.X.X/* c|
|00002f50| 6f 6d 6d 6f 6e 20 75 73 | 65 20 6f 66 20 6d 61 6c |ommon us|e of mal|
|00002f60| 6c 6f 63 2f 72 65 61 6c | 6c 6f 63 20 2d 2d 20 75 |loc/real|loc -- u|
|00002f70| 73 65 20 69 74 20 6f 72 | 20 64 6f 6e 27 74 20 75 |se it or| don't u|
|00002f80| 73 65 20 69 74 20 2a 2f | 0a 58 23 64 65 66 69 6e |se it */|.X#defin|
|00002f90| 65 20 4d 52 5f 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f |e MR_ALL|OC_LINTO|
|00002fa0| 4b 28 70 74 72 2c 20 6e | 65 6c 65 6d 2c 20 74 79 |K(ptr, n|elem, ty|
|00002fb0| 70 65 29 20 5c 0a 58 09 | 28 20 28 70 74 72 29 20 |pe) \.X.|( (ptr) |
|00002fc0| 3d 3d 20 4e 55 4c 4c 20 | 5c 0a 58 09 09 3f 20 4d |== NULL |\.X..? M|
|00002fd0| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 28 70 74 72 |ALLOC_LI|NTOK(ptr|
|00002fe0| 2c 20 28 6e 65 6c 65 6d | 29 2c 20 74 79 70 65 29 |, (nelem|), type)|
|00002ff0| 20 5c 0a 58 09 09 3a 20 | 52 45 41 4c 4c 4f 43 5f | \.X..: |REALLOC_|
|00003000| 4c 49 4e 54 4f 4b 28 70 | 74 72 2c 20 28 6e 65 6c |LINTOK(p|tr, (nel|
|00003010| 65 6d 29 2c 20 74 79 70 | 65 29 20 29 0a 58 0a 58 |em), typ|e) ).X.X|
|00003020| 2f 2a 0a 58 20 2a 09 54 | 68 65 73 65 20 6e 65 78 |/*.X *.T|hese nex|
|00003030| 74 20 6d 61 63 72 6f 73 | 20 69 6e 76 6f 6b 65 20 |t macros| invoke |
|00003040| 43 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 2c 20 4d |CALLOC_L|INTOK, M|
|00003050| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 2c 20 52 45 |ALLOC_LI|NTOK, RE|
|00003060| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 2c 0a 58 20 |ALLOC_LI|NTOK,.X |
|00003070| 2a 09 61 6e 64 20 4d 52 | 5f 41 4c 4c 4f 43 5f 4c |*.and MR|_ALLOC_L|
|00003080| 49 4e 54 4f 4b 20 77 69 | 74 68 20 61 6e 20 65 72 |INTOK wi|th an er|
|00003090| 72 6f 72 20 65 78 69 74 | 20 69 66 20 74 68 65 79 |ror exit| if they|
|000030a0| 20 66 61 69 6c 2e 0a 58 | 20 2a 0a 58 20 2a 09 49 | fail..X| *.X *.I|
|000030b0| 66 20 79 6f 75 20 77 61 | 6e 74 20 74 6f 20 68 61 |f you wa|nt to ha|
|000030c0| 6e 64 6c 65 20 79 6f 75 | 72 20 6f 77 6e 20 6d 65 |ndle you|r own me|
|000030d0| 6d 6f 72 79 20 61 6c 6c | 6f 63 61 74 69 6f 6e 20 |mory all|ocation |
|000030e0| 65 72 72 6f 72 73 2c 20 | 6a 75 73 74 0a 58 20 2a |errors, |just.X *|
|000030f0| 09 22 23 75 6e 64 65 66 | 20 45 52 52 4f 52 5f 45 |."#undef| ERROR_E|
|00003100| 58 49 54 5f 4c 49 4e 54 | 4f 4b 22 20 61 6e 64 20 |XIT_LINT|OK" and |
|00003110| 64 65 66 69 6e 65 20 79 | 6f 75 72 20 6f 77 6e 2e |define y|our own.|
|00003120| 0a 58 20 2a 2f 0a 58 23 | 64 65 66 69 6e 65 20 45 |.X */.X#|define E|
|00003130| 52 52 4f 52 5f 45 58 49 | 54 5f 4c 49 4e 54 4f 4b |RROR_EXI|T_LINTOK|
|00003140| 28 6e 65 6c 65 6d 2c 20 | 73 69 7a 65 29 20 5c 0a |(nelem, |size) \.|
|00003150| 58 09 7b 20 5c 0a 58 09 | 09 28 76 6f 69 64 29 20 |X.{ \.X.|.(void) |
|00003160| 66 70 72 69 6e 74 66 28 | 73 74 64 65 72 72 2c 20 |fprintf(|stderr, |
|00003170| 5c 0a 58 09 09 09 22 4d | 65 6d 6f 72 79 20 61 6c |\.X..."M|emory al|
|00003180| 6c 6f 63 61 74 69 6f 6e | 20 6f 66 20 25 64 20 2a |location| of %d *|
|00003190| 20 25 64 20 62 79 74 65 | 73 20 6f 6e 20 6c 69 6e | %d byte|s on lin|
|000031a0| 65 20 25 64 20 6f 66 20 | 5c 22 25 73 5c 22 20 66 |e %d of |\"%s\" f|
|000031b0| 61 69 6c 65 64 2e 5c 6e | 22 2c 20 5c 0a 58 09 09 |ailed.\n|", \.X..|
|000031c0| 09 28 6e 65 6c 65 6d 29 | 2c 20 28 73 69 7a 65 29 |.(nelem)|, (size)|
|000031d0| 2c 20 5f 5f 4c 49 4e 45 | 5f 5f 2c 20 5f 5f 46 49 |, __LINE|__, __FI|
|000031e0| 4c 45 5f 5f 29 3b 20 5c | 0a 58 09 09 65 78 69 74 |LE__); \|.X..exit|
|000031f0| 28 31 29 3b 20 5c 0a 58 | 09 7d 0a 58 0a 58 23 64 |(1); \.X|.}.X.X#d|
|00003200| 65 66 69 6e 65 20 43 41 | 4c 4c 4f 43 5f 4f 52 5f |efine CA|LLOC_OR_|
|00003210| 45 4c 53 45 5f 4c 49 4e | 54 4f 4b 28 70 74 72 2c |ELSE_LIN|TOK(ptr,|
|00003220| 20 6e 65 6c 65 6d 2c 20 | 74 79 70 65 29 20 5c 0a | nelem, |type) \.|
|00003230| 58 09 7b 20 5c 0a 58 09 | 09 69 66 20 28 43 41 4c |X.{ \.X.|.if (CAL|
|00003240| 4c 4f 43 5f 4c 49 4e 54 | 4f 4b 28 70 74 72 2c 20 |LOC_LINT|OK(ptr, |
|00003250| 28 6e 65 6c 65 6d 29 2c | 20 74 79 70 65 29 20 3d |(nelem),| type) =|
|00003260| 3d 20 4e 55 4c 4c 29 20 | 5c 0a 58 09 09 09 45 52 |= NULL) |\.X...ER|
|00003270| 52 4f 52 5f 45 58 49 54 | 5f 4c 49 4e 54 4f 4b 28 |ROR_EXIT|_LINTOK(|
|00003280| 28 6e 65 6c 65 6d 29 2c | 20 73 69 7a 65 6f 66 28 |(nelem),| sizeof(|
|00003290| 74 79 70 65 29 29 3b 20 | 5c 0a 58 09 7d 0a 58 0a |type)); |\.X.}.X.|
|000032a0| 58 23 64 65 66 69 6e 65 | 20 4d 41 4c 4c 4f 43 5f |X#define| MALLOC_|
|000032b0| 4f 52 5f 45 4c 53 45 5f | 4c 49 4e 54 4f 4b 28 70 |OR_ELSE_|LINTOK(p|
|000032c0| 74 72 2c 20 6e 65 6c 65 | 6d 2c 20 74 79 70 65 29 |tr, nele|m, type)|
|000032d0| 20 5c 0a 58 09 7b 20 5c | 0a 58 09 09 69 66 20 28 | \.X.{ \|.X..if (|
|000032e0| 4d 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 28 70 74 |MALLOC_L|INTOK(pt|
|000032f0| 72 2c 20 28 6e 65 6c 65 | 6d 29 2c 20 74 79 70 65 |r, (nele|m), type|
|00003300| 29 20 3d 3d 20 4e 55 4c | 4c 29 20 5c 0a 58 09 09 |) == NUL|L) \.X..|
|00003310| 09 45 52 52 4f 52 5f 45 | 58 49 54 5f 4c 49 4e 54 |.ERROR_E|XIT_LINT|
|00003320| 4f 4b 28 28 6e 65 6c 65 | 6d 29 2c 20 73 69 7a 65 |OK((nele|m), size|
|00003330| 6f 66 28 74 79 70 65 29 | 29 3b 20 5c 0a 58 09 7d |of(type)|); \.X.}|
|00003340| 0a 58 0a 58 23 64 65 66 | 69 6e 65 20 52 45 41 4c |.X.X#def|ine REAL|
|00003350| 4c 4f 43 5f 4f 52 5f 45 | 4c 53 45 5f 4c 49 4e 54 |LOC_OR_E|LSE_LINT|
|00003360| 4f 4b 28 70 74 72 2c 20 | 6e 65 6c 65 6d 2c 20 74 |OK(ptr, |nelem, t|
|00003370| 79 70 65 29 20 5c 0a 58 | 09 7b 20 5c 0a 58 09 09 |ype) \.X|.{ \.X..|
|00003380| 69 66 20 28 52 45 41 4c | 4c 4f 43 5f 4c 49 4e 54 |if (REAL|LOC_LINT|
|00003390| 4f 4b 28 70 74 72 2c 20 | 28 6e 65 6c 65 6d 29 2c |OK(ptr, |(nelem),|
|000033a0| 20 74 79 70 65 29 20 3d | 3d 20 4e 55 4c 4c 29 20 | type) =|= NULL) |
|000033b0| 5c 0a 58 09 09 09 45 52 | 52 4f 52 5f 45 58 49 54 |\.X...ER|ROR_EXIT|
|000033c0| 5f 4c 49 4e 54 4f 4b 28 | 28 6e 65 6c 65 6d 29 2c |_LINTOK(|(nelem),|
|000033d0| 20 73 69 7a 65 6f 66 28 | 74 79 70 65 29 29 3b 20 | sizeof(|type)); |
|000033e0| 5c 0a 58 09 7d 0a 58 0a | 58 23 64 65 66 69 6e 65 |\.X.}.X.|X#define|
|000033f0| 20 4d 52 5f 41 4c 4c 4f | 43 5f 4f 52 5f 45 4c 53 | MR_ALLO|C_OR_ELS|
|00003400| 45 5f 4c 49 4e 54 4f 4b | 28 70 74 72 2c 20 6e 65 |E_LINTOK|(ptr, ne|
|00003410| 6c 65 6d 2c 20 74 79 70 | 65 29 20 5c 0a 58 09 7b |lem, typ|e) \.X.{|
|00003420| 20 5c 0a 58 09 09 69 66 | 20 28 4d 52 5f 41 4c 4c | \.X..if| (MR_ALL|
|00003430| 4f 43 5f 4c 49 4e 54 4f | 4b 28 70 74 72 2c 20 28 |OC_LINTO|K(ptr, (|
|00003440| 6e 65 6c 65 6d 29 2c 20 | 74 79 70 65 29 20 3d 3d |nelem), |type) ==|
|00003450| 20 4e 55 4c 4c 29 20 5c | 0a 58 09 09 09 45 52 52 | NULL) \|.X...ERR|
|00003460| 4f 52 5f 45 58 49 54 5f | 4c 49 4e 54 4f 4b 28 28 |OR_EXIT_|LINTOK((|
|00003470| 6e 65 6c 65 6d 29 2c 20 | 73 69 7a 65 6f 66 28 74 |nelem), |sizeof(t|
|00003480| 79 70 65 29 29 3b 20 5c | 0a 58 09 7d 0a 58 0a 58 |ype)); \|.X.}.X.X|
|00003490| 65 78 74 65 72 6e 20 66 | 72 65 65 28 29 3b 0a 58 |extern f|ree();.X|
|000034a0| 23 69 66 64 65 66 20 6c | 69 6e 74 0a 58 23 64 65 |#ifdef l|int.X#de|
|000034b0| 66 69 6e 65 20 46 52 45 | 45 5f 4c 49 4e 54 4f 4b |fine FRE|E_LINTOK|
|000034c0| 28 70 74 72 29 20 5c 0a | 58 09 66 72 65 65 28 28 |(ptr) \.|X.free((|
|000034d0| 70 74 72 20 3d 20 4e 55 | 4c 4c 2c 20 28 63 68 61 |ptr = NU|LL, (cha|
|000034e0| 72 20 2a 29 20 4e 55 4c | 4c 29 29 0a 58 23 65 6c |r *) NUL|L)).X#el|
|000034f0| 73 65 0a 58 23 64 65 66 | 69 6e 65 20 46 52 45 45 |se.X#def|ine FREE|
|00003500| 5f 4c 49 4e 54 4f 4b 28 | 70 74 72 29 20 5c 0a 58 |_LINTOK(|ptr) \.X|
|00003510| 09 66 72 65 65 28 28 63 | 68 61 72 20 2a 29 20 70 |.free((c|har *) p|
|00003520| 74 72 29 0a 58 23 65 6e | 64 69 66 0a 58 0a 58 2f |tr).X#en|dif.X.X/|
|00003530| 2a 20 57 65 20 63 6f 75 | 6c 64 20 68 61 76 65 20 |* We cou|ld have |
|00003540| 61 20 22 43 46 52 45 45 | 5f 4c 49 4e 54 4f 4b 22 |a "CFREE|_LINTOK"|
|00003550| 2c 20 62 75 74 20 77 68 | 61 74 27 73 20 74 68 65 |, but wh|at's the|
|00003560| 20 70 6f 69 6e 74 3f 20 | 2a 2f 0a 58 0a 58 23 64 | point? |*/.X.X#d|
|00003570| 65 66 69 6e 65 20 49 4e | 43 4c 55 44 45 44 5f 4c |efine IN|CLUDED_L|
|00003580| 49 4e 54 4f 4b 0a 58 23 | 65 6e 64 69 66 0a 58 0a |INTOK.X#|endif.X.|
|00003590| 45 4e 44 5f 4f 46 5f 6d | 65 6d 6c 69 6e 74 6f 6b |END_OF_m|emlintok|
|000035a0| 2e 68 0a 69 66 20 74 65 | 73 74 20 32 39 38 36 20 |.h.if te|st 2986 |
|000035b0| 2d 6e 65 20 60 77 63 20 | 2d 63 20 3c 6d 65 6d 6c |-ne `wc |-c <meml|
|000035c0| 69 6e 74 6f 6b 2e 68 60 | 3b 20 74 68 65 6e 0a 20 |intok.h`|; then. |
|000035d0| 20 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 5c 22 | echo |shar: \"|
|000035e0| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 68 5c 22 20 75 6e |memlinto|k.h\" un|
|000035f0| 70 61 63 6b 65 64 20 77 | 69 74 68 20 77 72 6f 6e |packed w|ith wron|
|00003600| 67 20 73 69 7a 65 21 0a | 66 69 0a 23 20 65 6e 64 |g size!.|fi.# end|
|00003610| 20 6f 66 20 6f 76 65 72 | 77 72 69 74 69 6e 67 20 | of over|writing |
|00003620| 63 68 65 63 6b 0a 66 69 | 0a 69 66 20 74 65 73 74 |check.fi|.if test|
|00003630| 20 2d 66 20 74 5f 6d 65 | 6d 6c 69 6e 74 6f 6b 2e | -f t_me|mlintok.|
|00003640| 63 20 2d 61 20 22 24 7b | 31 7d 22 20 21 3d 20 22 |c -a "${|1}" != "|
|00003650| 2d 63 22 20 3b 20 74 68 | 65 6e 20 0a 20 20 65 63 |-c" ; th|en . ec|
|00003660| 68 6f 20 73 68 61 72 3a | 20 57 69 6c 6c 20 6e 6f |ho shar:| Will no|
|00003670| 74 20 6f 76 65 72 2d 77 | 72 69 74 65 20 65 78 69 |t over-w|rite exi|
|00003680| 73 74 69 6e 67 20 66 69 | 6c 65 20 5c 22 74 5f 6d |sting fi|le \"t_m|
|00003690| 65 6d 6c 69 6e 74 6f 6b | 2e 63 5c 22 0a 65 6c 73 |emlintok|.c\".els|
|000036a0| 65 0a 65 63 68 6f 20 73 | 68 61 72 3a 20 45 78 74 |e.echo s|har: Ext|
|000036b0| 72 61 63 74 69 6e 67 20 | 5c 22 74 5f 6d 65 6d 6c |racting |\"t_meml|
|000036c0| 69 6e 74 6f 6b 2e 63 5c | 22 20 5c 28 31 34 33 38 |intok.c\|" \(1438|
|000036d0| 20 63 68 61 72 61 63 74 | 65 72 73 5c 29 0a 73 65 | charact|ers\).se|
|000036e0| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 74 5f 6d 65 |d "s/^X/|/" >t_me|
|000036f0| 6d 6c 69 6e 74 6f 6b 2e | 63 20 3c 3c 27 45 4e 44 |mlintok.|c <<'END|
|00003700| 5f 4f 46 5f 74 5f 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |_OF_t_me|mlintok.|
|00003710| 63 27 0a 58 2f 2a 20 24 | 48 65 61 64 65 72 3a 20 |c'.X/* $|Header: |
|00003720| 74 5f 6d 65 6d 6c 69 6e | 74 6f 6b 2e 63 2c 76 20 |t_memlin|tok.c,v |
|00003730| 31 2e 33 20 38 39 2f 30 | 35 2f 30 32 20 31 35 3a |1.3 89/0|5/02 15:|
|00003740| 30 37 3a 30 38 20 62 6f | 62 6c 20 45 78 70 20 24 |07:08 bo|bl Exp $|
|00003750| 20 2a 2f 0a 58 0a 58 23 | 69 6e 63 6c 75 64 65 20 | */.X.X#|include |
|00003760| 3c 73 74 64 69 6f 2e 68 | 3e 0a 58 0a 58 23 69 6e |<stdio.h|>.X.X#in|
|00003770| 63 6c 75 64 65 20 22 6d | 65 6d 6c 69 6e 74 6f 6b |clude "m|emlintok|
|00003780| 2e 68 22 0a 58 0a 58 6d | 61 69 6e 28 29 0a 58 7b |.h".X.Xm|ain().X{|
|00003790| 0a 58 09 69 6e 74 20 2a | 70 2c 20 2a 71 3b 0a 58 |.X.int *|p, *q;.X|
|000037a0| 0a 58 09 69 66 20 28 4d | 41 4c 4c 4f 43 5f 4c 49 |.X.if (M|ALLOC_LI|
|000037b0| 4e 54 4f 4b 28 70 2c 20 | 31 30 30 2c 20 69 6e 74 |NTOK(p, |100, int|
|000037c0| 29 20 3d 3d 20 4e 55 4c | 4c 29 0a 58 09 09 66 61 |) == NUL|L).X..fa|
|000037d0| 69 6c 28 22 63 61 6e 27 | 74 20 6d 61 6c 6c 6f 63 |il("can'|t malloc|
|000037e0| 20 31 30 30 20 69 6e 74 | 73 5c 6e 22 29 3b 0a 58 | 100 int|s\n");.X|
|000037f0| 09 65 6c 73 65 0a 58 09 | 09 73 75 63 63 65 65 64 |.else.X.|.succeed|
|00003800| 28 22 31 30 30 20 69 6e | 74 73 20 6d 61 6c 6c 6f |("100 in|ts mallo|
|00003810| 63 27 64 5c 6e 22 29 3b | 0a 58 0a 58 09 28 76 6f |c'd\n");|.X.X.(vo|
|00003820| 69 64 29 20 52 45 41 4c | 4c 4f 43 5f 4c 49 4e 54 |id) REAL|LOC_LINT|
|00003830| 4f 4b 28 70 2c 20 32 30 | 30 2c 20 69 6e 74 29 3b |OK(p, 20|0, int);|
|00003840| 0a 58 09 69 66 20 28 70 | 20 3d 3d 20 4e 55 4c 4c |.X.if (p| == NULL|
|00003850| 29 0a 58 09 09 66 61 69 | 6c 28 22 63 61 6e 27 74 |).X..fai|l("can't|
|00003860| 20 72 65 61 6c 6c 6f 63 | 20 32 30 30 20 69 6e 74 | realloc| 200 int|
|00003870| 73 5c 6e 22 29 3b 0a 58 | 09 65 6c 73 65 0a 58 09 |s\n");.X|.else.X.|
|00003880| 09 73 75 63 63 65 65 64 | 28 22 32 30 30 20 69 6e |.succeed|("200 in|
|00003890| 74 73 20 72 65 61 6c 6c | 6f 63 27 64 5c 6e 22 29 |ts reall|oc'd\n")|
|000038a0| 3b 0a 58 0a 58 09 69 66 | 20 28 4d 52 5f 41 4c 4c |;.X.X.if| (MR_ALL|
|000038b0| 4f 43 5f 4c 49 4e 54 4f | 4b 28 70 2c 20 32 35 2c |OC_LINTO|K(p, 25,|
|000038c0| 20 69 6e 74 29 20 3d 3d | 20 4e 55 4c 4c 29 0a 58 | int) ==| NULL).X|
|000038d0| 09 09 66 61 69 6c 28 22 | 63 61 6e 27 74 20 6d 72 |..fail("|can't mr|
|000038e0| 5f 61 6c 6c 6f 63 20 28 | 72 65 61 6c 6c 6f 63 29 |_alloc (|realloc)|
|000038f0| 20 32 35 20 69 6e 74 73 | 5c 6e 22 29 3b 0a 58 09 | 25 ints|\n");.X.|
|00003900| 65 6c 73 65 0a 58 09 09 | 73 75 63 63 65 65 64 28 |else.X..|succeed(|
|00003910| 22 32 35 20 69 6e 74 73 | 20 6d 72 5f 61 6c 6c 6f |"25 ints| mr_allo|
|00003920| 63 27 64 20 28 72 65 61 | 6c 6c 6f 63 27 64 29 5c |c'd (rea|lloc'd)\|
|00003930| 6e 22 29 3b 0a 58 0a 58 | 09 69 66 20 28 43 41 4c |n");.X.X|.if (CAL|
|00003940| 4c 4f 43 5f 4c 49 4e 54 | 4f 4b 28 71 2c 20 35 30 |LOC_LINT|OK(q, 50|
|00003950| 30 2c 20 69 6e 74 29 20 | 3d 3d 20 4e 55 4c 4c 29 |0, int) |== NULL)|
|00003960| 0a 58 09 09 66 61 69 6c | 28 22 63 61 6e 27 74 20 |.X..fail|("can't |
|00003970| 63 61 6c 6c 6f 63 20 35 | 30 30 20 69 6e 74 73 5c |calloc 5|00 ints\|
|00003980| 6e 22 29 3b 0a 58 09 65 | 6c 73 65 0a 58 09 09 73 |n");.X.e|lse.X..s|
|00003990| 75 63 63 65 65 64 28 22 | 35 30 30 20 69 6e 74 73 |ucceed("|500 ints|
|000039a0| 20 63 61 6c 6c 6f 63 27 | 64 5c 6e 22 29 3b 0a 58 | calloc'|d\n");.X|
|000039b0| 09 71 5b 30 5d 20 3d 20 | 30 3b 0a 58 09 46 52 45 |.q[0] = |0;.X.FRE|
|000039c0| 45 5f 4c 49 4e 54 4f 4b | 28 71 29 3b 0a 58 0a 58 |E_LINTOK|(q);.X.X|
|000039d0| 09 46 52 45 45 5f 4c 49 | 4e 54 4f 4b 28 70 29 3b |.FREE_LI|NTOK(p);|
|000039e0| 0a 58 09 70 20 3d 20 4e | 55 4c 4c 3b 0a 58 09 69 |.X.p = N|ULL;.X.i|
|000039f0| 66 20 28 4d 52 5f 41 4c | 4c 4f 43 5f 4c 49 4e 54 |f (MR_AL|LOC_LINT|
|00003a00| 4f 4b 28 70 2c 20 31 30 | 30 30 2c 20 69 6e 74 29 |OK(p, 10|00, int)|
|00003a10| 20 3d 3d 20 4e 55 4c 4c | 29 0a 58 09 09 66 61 69 | == NULL|).X..fai|
|00003a20| 6c 28 22 63 61 6e 27 74 | 20 6d 72 5f 61 6c 6c 6f |l("can't| mr_allo|
|00003a30| 63 20 28 6d 61 6c 6c 6f | 63 29 20 31 30 30 30 20 |c (mallo|c) 1000 |
|00003a40| 69 6e 74 73 5c 6e 22 29 | 3b 0a 58 09 65 6c 73 65 |ints\n")|;.X.else|
|00003a50| 0a 58 09 09 73 75 63 63 | 65 65 64 28 22 31 30 30 |.X..succ|eed("100|
|00003a60| 30 20 69 6e 74 73 20 6d | 72 5f 61 6c 6c 6f 63 27 |0 ints m|r_alloc'|
|00003a70| 64 20 28 6d 61 6c 6c 6f | 63 27 64 29 5c 6e 22 29 |d (mallo|c'd)\n")|
|00003a80| 3b 0a 58 0a 58 09 43 41 | 4c 4c 4f 43 5f 4f 52 5f |;.X.X.CA|LLOC_OR_|
|00003a90| 45 4c 53 45 5f 4c 49 4e | 54 4f 4b 28 70 2c 20 35 |ELSE_LIN|TOK(p, 5|
|00003aa0| 30 2c 20 69 6e 74 29 3b | 0a 58 09 73 75 63 63 65 |0, int);|.X.succe|
|00003ab0| 65 64 28 22 35 30 20 69 | 6e 74 73 20 63 61 6c 6c |ed("50 i|nts call|
|00003ac0| 6f 63 27 64 20 28 6f 72 | 20 65 6c 73 65 29 5c 6e |oc'd (or| else)\n|
|00003ad0| 22 29 3b 0a 58 09 4d 41 | 4c 4c 4f 43 5f 4f 52 5f |");.X.MA|LLOC_OR_|
|00003ae0| 45 4c 53 45 5f 4c 49 4e | 54 4f 4b 28 70 2c 20 31 |ELSE_LIN|TOK(p, 1|
|00003af0| 30 30 2c 20 69 6e 74 29 | 3b 0a 58 09 73 75 63 63 |00, int)|;.X.succ|
|00003b00| 65 65 64 28 22 31 30 30 | 20 69 6e 74 73 20 6d 61 |eed("100| ints ma|
|00003b10| 6c 6c 6f 63 27 64 20 28 | 6f 72 20 65 6c 73 65 29 |lloc'd (|or else)|
|00003b20| 5c 6e 22 29 3b 0a 58 09 | 52 45 41 4c 4c 4f 43 5f |\n");.X.|REALLOC_|
|00003b30| 4f 52 5f 45 4c 53 45 5f | 4c 49 4e 54 4f 4b 28 70 |OR_ELSE_|LINTOK(p|
|00003b40| 2c 20 32 30 30 2c 20 69 | 6e 74 29 3b 0a 58 09 73 |, 200, i|nt);.X.s|
|00003b50| 75 63 63 65 65 64 28 22 | 32 30 30 20 69 6e 74 73 |ucceed("|200 ints|
|00003b60| 20 72 65 61 6c 6c 6f 63 | 27 64 20 28 6f 72 20 65 | realloc|'d (or e|
|00003b70| 6c 73 65 29 5c 6e 22 29 | 3b 0a 58 0a 58 23 75 6e |lse)\n")|;.X.X#un|
|00003b80| 64 65 66 20 45 52 52 4f | 52 5f 45 58 49 54 5f 4c |def ERRO|R_EXIT_L|
|00003b90| 49 4e 54 4f 4b 0a 58 23 | 64 65 66 69 6e 65 20 45 |INTOK.X#|define E|
|00003ba0| 52 52 4f 52 5f 45 58 49 | 54 5f 4c 49 4e 54 4f 4b |RROR_EXI|T_LINTOK|
|00003bb0| 28 6e 65 6c 65 6d 2c 20 | 73 69 7a 65 29 20 5c 0a |(nelem, |size) \.|
|00003bc0| 58 09 66 61 69 6c 28 22 | 6d 65 6d 6f 72 79 20 61 |X.fail("|memory a|
|00003bd0| 6c 6c 6f 63 61 74 69 6f | 6e 20 66 61 69 6c 65 64 |llocatio|n failed|
|00003be0| 5c 6e 22 29 3b 0a 58 0a | 58 09 4d 52 5f 41 4c 4c |\n");.X.|X.MR_ALL|
|00003bf0| 4f 43 5f 4f 52 5f 45 4c | 53 45 5f 4c 49 4e 54 4f |OC_OR_EL|SE_LINTO|
|00003c00| 4b 28 70 2c 20 34 30 30 | 2c 20 69 6e 74 29 3b 0a |K(p, 400|, int);.|
|00003c10| 58 09 73 75 63 63 65 65 | 64 28 22 34 30 30 20 69 |X.succee|d("400 i|
|00003c20| 6e 74 73 20 6d 72 5f 61 | 6c 6c 6f 63 27 64 20 28 |nts mr_a|lloc'd (|
|00003c30| 72 65 61 6c 6c 6f 63 27 | 64 29 20 28 6f 72 20 65 |realloc'|d) (or e|
|00003c40| 6c 73 65 29 5c 6e 22 29 | 3b 0a 58 0a 58 09 65 78 |lse)\n")|;.X.X.ex|
|00003c50| 69 74 28 30 29 3b 0a 58 | 09 72 65 74 75 72 6e 20 |it(0);.X|.return |
|00003c60| 30 3b 09 2f 2a 20 73 68 | 75 74 73 20 75 70 20 48 |0;./* sh|uts up H|
|00003c70| 50 2d 55 58 20 6c 69 6e | 74 20 2a 2f 0a 58 7d 0a |P-UX lin|t */.X}.|
|00003c80| 58 0a 58 66 61 69 6c 28 | 73 29 0a 58 09 63 68 61 |X.Xfail(|s).X.cha|
|00003c90| 72 20 2a 73 3b 0a 58 7b | 0a 58 09 66 70 75 74 73 |r *s;.X{|.X.fputs|
|00003ca0| 28 73 2c 20 73 74 64 6f | 75 74 29 3b 0a 58 09 65 |(s, stdo|ut);.X.e|
|00003cb0| 78 69 74 28 31 29 3b 0a | 58 7d 0a 58 0a 58 73 75 |xit(1);.|X}.X.Xsu|
|00003cc0| 63 63 65 65 64 28 73 29 | 0a 58 09 63 68 61 72 20 |cceed(s)|.X.char |
|00003cd0| 2a 73 3b 0a 58 7b 0a 58 | 09 66 70 75 74 73 28 73 |*s;.X{.X|.fputs(s|
|00003ce0| 2c 20 73 74 64 6f 75 74 | 29 3b 0a 58 09 72 65 74 |, stdout|);.X.ret|
|00003cf0| 75 72 6e 3b 0a 58 7d 0a | 45 4e 44 5f 4f 46 5f 74 |urn;.X}.|END_OF_t|
|00003d00| 5f 6d 65 6d 6c 69 6e 74 | 6f 6b 2e 63 0a 69 66 20 |_memlint|ok.c.if |
|00003d10| 74 65 73 74 20 31 34 33 | 38 20 2d 6e 65 20 60 77 |test 143|8 -ne `w|
|00003d20| 63 20 2d 63 20 3c 74 5f | 6d 65 6d 6c 69 6e 74 6f |c -c <t_|memlinto|
|00003d30| 6b 2e 63 60 3b 20 74 68 | 65 6e 0a 20 20 20 20 65 |k.c`; th|en. e|
|00003d40| 63 68 6f 20 73 68 61 72 | 3a 20 5c 22 74 5f 6d 65 |cho shar|: \"t_me|
|00003d50| 6d 6c 69 6e 74 6f 6b 2e | 63 5c 22 20 75 6e 70 61 |mlintok.|c\" unpa|
|00003d60| 63 6b 65 64 20 77 69 74 | 68 20 77 72 6f 6e 67 20 |cked wit|h wrong |
|00003d70| 73 69 7a 65 21 0a 66 69 | 0a 23 20 65 6e 64 20 6f |size!.fi|.# end o|
|00003d80| 66 20 6f 76 65 72 77 72 | 69 74 69 6e 67 20 63 68 |f overwr|iting ch|
|00003d90| 65 63 6b 0a 66 69 0a 65 | 63 68 6f 20 73 68 61 72 |eck.fi.e|cho shar|
|00003da0| 3a 20 45 6e 64 20 6f 66 | 20 73 68 65 6c 6c 20 61 |: End of| shell a|
|00003db0| 72 63 68 69 76 65 2e 0a | 65 78 69 74 20 30 0a 0a |rchive..|exit 0..|
+--------+-------------------------+-------------------------+--------+--------+