Category : C Source Code
Archive   : MEMDEBUG.ZIP
Filename : MEMDEBUG.PS

 
Output of file : MEMDEBUG.PS contained in archive : MEMDEBUG.ZIP
%!PS-Adobe-3.0
%%Title: (Memdebug)
%%Creator: (MS Word 5.1: LaserWriter 8 8.1.1)
%%CreationDate: (8:27 AM Monday, January 31, 1994)
%%For: (rEnE)
%%Pages: 12
%%DocumentFonts: Times-Roman Times-Bold Times-Italic Helvetica-Bold Helvetica Courier
%%DocumentNeededFonts: Times-Roman Times-Bold Times-Italic Helvetica-Bold Helvetica Courier
%%DocumentSuppliedFonts:
%%DocumentData: Clean7Bit
%%PageOrder: Ascend
%%Orientation: Portrait
%ADO_PaperArea: -30 -29 812 566
%ADO_ImageableArea: 0 0 781 538
%%EndComments
/md 184 dict def md begin
/currentpacking where {pop /sc_oldpacking currentpacking def true setpacking}if
%%BeginFile: adobe_psp_basic
%%Copyright: Copyright 1990-1993 Adobe Systems Incorporated. All Rights Reserved.
/bd{bind def}bind def
/xdf{exch def}bd
/xs{exch store}bd
/ld{load def}bd
/Z{0 def}bd
/T/true
/F/false
/:L/lineto
/lw/setlinewidth
/:M/moveto
/rl/rlineto
/rm/rmoveto
/:C/curveto
/:T/translate
/:K/closepath
/:mf/makefont
/gS/gsave
/gR/grestore
/np/newpath
14{ld}repeat
/$m matrix def
/av 81 def
/por true def
/normland false def
/psb-nosave{}bd
/pse-nosave{}bd
/us Z
/psb{/us save store}bd
/pse{us restore}bd
/level2
/languagelevel where
{
pop languagelevel 2 ge
}{
false
}ifelse
def
/featurecleanup
{
stopped
cleartomark
countdictstack exch sub dup 0 gt
{
{end}repeat
}{
pop
}ifelse
}bd
/noload Z
/startnoload
{
{/noload save store}if
}bd
/endnoload
{
{noload restore}if
}bd
level2 startnoload
/setjob
{
statusdict/jobname 3 -1 roll put
}bd
/setcopies
{
userdict/#copies 3 -1 roll put
}bd
level2 endnoload level2 not startnoload
/setjob
{
1 dict begin/JobName xdf currentdict end setuserparams
}bd
/setcopies
{
1 dict begin/NumCopies xdf currentdict end setpagedevice
}bd
level2 not endnoload
/pm Z
/mT Z
/sD Z
/realshowpage Z
/initializepage
{
/pm save store mT concat
}bd
/endp
{
pm restore showpage
}def
/$c/DeviceRGB def
/rectclip where
{
pop/rC/rectclip ld
}{
/rC
{
np 4 2 roll
:M
1 index 0 rl
0 exch rl
neg 0 rl
:K
clip np
}bd
}ifelse
/rectfill where
{
pop/rF/rectfill ld
}{
/rF
{
gS
np
4 2 roll
:M
1 index 0 rl
0 exch rl
neg 0 rl
fill
gR
}bd
}ifelse
/rectstroke where
{
pop/rS/rectstroke ld
}{
/rS
{
gS
np
4 2 roll
:M
1 index 0 rl
0 exch rl
neg 0 rl
:K
stroke
gR
}bd
}ifelse
%%EndFile
%%BeginFile: adobe_psp_colorspace_level1
%%Copyright: Copyright 1991-1993 Adobe Systems Incorporated. All Rights Reserved.
/G/setgray ld
/:F/setrgbcolor ld
%%EndFile
%%BeginFile: adobe_psp_uniform_graphics
%%Copyright: Copyright 1990-1993 Adobe Systems Incorporated. All Rights Reserved.
/@a
{
np :M 0 rl :L 0 exch rl 0 rl :L fill
}bd
/@b
{
np :M 0 rl 0 exch rl :L 0 rl 0 exch rl fill
}bd
/arct where
{
pop
}{
/arct
{
arcto pop pop pop pop
}bd
}ifelse
/x1 Z
/x2 Z
/y1 Z
/y2 Z
/rad Z
/@q
{
/rad xs
/y2 xs
/x2 xs
/y1 xs
/x1 xs
np
x2 x1 add 2 div y1 :M
x2 y1 x2 y2 rad arct
x2 y2 x1 y2 rad arct
x1 y2 x1 y1 rad arct
x1 y1 x2 y1 rad arct
fill
}bd
/@s
{
/rad xs
/y2 xs
/x2 xs
/y1 xs
/x1 xs
np
x2 x1 add 2 div y1 :M
x2 y1 x2 y2 rad arct
x2 y2 x1 y2 rad arct
x1 y2 x1 y1 rad arct
x1 y1 x2 y1 rad arct
:K
stroke
}bd
/@i
{
np 0 360 arc fill
}bd
/@j
{
gS
np
:T
scale
0 0 .5 0 360 arc
fill
gR
}bd
/@e
{
np
0 360 arc
:K
stroke
}bd
/@f
{
np
$m currentmatrix
pop
:T
scale
0 0 .5 0 360 arc
:K
$m setmatrix
stroke
}bd
/@k
{
gS
np
:T
0 0 :M
0 0 5 2 roll
arc fill
gR
}bd
/@l
{
gS
np
:T
0 0 :M
scale
0 0 .5 5 -2 roll arc
fill
gR
}bd
/@m
{
np
arc
stroke
}bd
/@n
{
np
$m currentmatrix
pop
:T
scale
0 0 .5 5 -2 roll arc
$m setmatrix
stroke
}bd
%%EndFile
%%BeginFile: adobe_psp_basic_text
%%Copyright: Copyright 1990-1993 Adobe Systems Incorporated. All Rights Reserved.
/S/show ld
/A{
0.0 exch ashow
}bd
/R{
0.0 exch 32 exch widthshow
}bd
/W{
0.0 3 1 roll widthshow
}bd
/J{
0.0 32 4 2 roll 0.0 exch awidthshow
}bd
/V{
0.0 4 1 roll 0.0 exch awidthshow
}bd
/fcflg true def
/fc{
fcflg{
vmstatus exch sub 50000 lt{
(%%[ Warning: Running out of memory ]%%\r)print flush/fcflg false store
}if pop
}if
}bd
/$f[1 0 0 -1 0 0]def
/:ff{$f :mf}bd
/MacEncoding StandardEncoding 256 array copy def
MacEncoding 39/quotesingle put
MacEncoding 96/grave put
/Adieresis/Aring/Ccedilla/Eacute/Ntilde/Odieresis/Udieresis/aacute
/agrave/acircumflex/adieresis/atilde/aring/ccedilla/eacute/egrave
/ecircumflex/edieresis/iacute/igrave/icircumflex/idieresis/ntilde/oacute
/ograve/ocircumflex/odieresis/otilde/uacute/ugrave/ucircumflex/udieresis
/dagger/degree/cent/sterling/section/bullet/paragraph/germandbls
/registered/copyright/trademark/acute/dieresis/notequal/AE/Oslash
/infinity/plusminus/lessequal/greaterequal/yen/mu/partialdiff/summation
/product/pi/integral/ordfeminine/ordmasculine/Omega/ae/oslash
/questiondown/exclamdown/logicalnot/radical/florin/approxequal/Delta/guillemotleft
/guillemotright/ellipsis/space/Agrave/Atilde/Otilde/OE/oe
/endash/emdash/quotedblleft/quotedblright/quoteleft/quoteright/divide/lozenge
/ydieresis/Ydieresis/fraction/currency/guilsinglleft/guilsinglright/fi/fl
/daggerdbl/periodcentered/quotesinglbase/quotedblbase/perthousand
/Acircumflex/Ecircumflex/Aacute/Edieresis/Egrave/Iacute/Icircumflex/Idieresis/Igrave
/Oacute/Ocircumflex/apple/Ograve/Uacute/Ucircumflex/Ugrave/dotlessi/circumflex/tilde
/macron/breve/dotaccent/ring/cedilla/hungarumlaut/ogonek/caron
MacEncoding 128 128 getinterval astore pop
level2 startnoload
/copyfontdict
{
findfont dup length dict
begin
{
1 index/FID ne{def}{pop pop}ifelse
}forall
}bd
level2 endnoload level2 not startnoload
/copyfontdict
{
findfont dup length dict
copy
begin
}bd
level2 not endnoload
md/fontname known not{
/fontname/customfont def
}if
/Encoding Z
/:mre
{
copyfontdict
/Encoding MacEncoding def
fontname currentdict
end
definefont :ff def
}bd
/:bsr
{
copyfontdict
/Encoding Encoding 256 array copy def
Encoding dup
}bd
/pd{put dup}bd
/:esr
{
pop pop
fontname currentdict
end
definefont :ff def
}bd
/scf
{
scalefont def
}bd
/scf-non
{
$m scale :mf setfont
}bd
/ps Z
/fz{/ps xs}bd
/sf/setfont ld
/cF/currentfont ld
/mbf
{
/makeblendedfont where
{
pop
makeblendedfont
/ABlend exch definefont
}{
pop
}ifelse
def
}def
%%EndFile
%%BeginFile: adobe_psp_derived_styles
%%Copyright: Copyright 1990-1993 Adobe Systems Incorporated. All Rights Reserved.
/wi
version(23.0)eq
{
{
gS 0 0 0 0 rC stringwidth gR
}bind
}{
/stringwidth load
}ifelse
def
/$o 1. def
/gl{$o G}bd
/ms{:M S}bd
/condensedmtx[.82 0 0 1 0 0]def
/:mc
{
condensedmtx :mf def
}bd
/extendedmtx[1.18 0 0 1 0 0]def
/:me
{
extendedmtx :mf def
}bd
/basefont Z
/basefonto Z
/dxa Z
/dxb Z
/dxc Z
/dxd Z
/dsdx2 Z
/bfproc Z
/:fbase
{
dup/FontType get 0 eq{
dup length dict begin
dup{1 index/FID ne 2 index/UniqueID ne and{def}{pop pop}ifelse}forall
/FDepVector exch/FDepVector get[exch/:fbase load forall]def
}/bfproc load ifelse
/customfont currentdict end definefont
}bd
/:mo
{
/bfproc{
dup dup length 2 add dict
begin
{
1 index/FID ne 2 index/UniqueID ne and{def}{pop pop}ifelse
}forall
/PaintType 2 def
/StrokeWidth .012 0 FontMatrix idtransform pop def
/customfont currentdict
end
definefont
8 dict begin
/basefonto xdf
/basefont xdf
/FontType 3 def
/FontMatrix[1 0 0 1 0 0]def
/FontBBox[0 0 1 1]def
/Encoding StandardEncoding def
/BuildChar
{
exch begin
basefont setfont
( )dup 0 4 -1 roll put
dup wi
setcharwidth
0 0 :M
gS
gl
dup show
gR
basefonto setfont
show
end
}def
}store :fbase
}bd
/:mso
{
/bfproc{
7 dict begin
/basefont xdf
/FontType 3 def
/FontMatrix[1 0 0 1 0 0]def
/FontBBox[0 0 1 1]def
/Encoding StandardEncoding def
/BuildChar
{
exch begin
sD begin
/dxa 1 ps div def
basefont setfont
( )dup 0 4 -1 roll put
dup wi
1 index 0 ne
{
exch dxa add exch
}if
setcharwidth
dup 0 0 ms
dup dxa 0 ms
dup dxa dxa ms
dup 0 dxa ms
gl
dxa 2. div dup ms
end
end
}def
}store :fbase
}bd
/:ms
{
/bfproc{
dup dup length 2 add dict
begin
{
1 index/FID ne 2 index/UniqueID ne and{def}{pop pop}ifelse
}forall
/PaintType 2 def
/StrokeWidth .012 0 FontMatrix idtransform pop def
/customfont currentdict
end
definefont
8 dict begin
/basefonto xdf
/basefont xdf
/FontType 3 def
/FontMatrix[1 0 0 1 0 0]def
/FontBBox[0 0 1 1]def
/Encoding StandardEncoding def
/BuildChar
{
exch begin
sD begin
/dxb .05 def
basefont setfont
( )dup 0 4 -1 roll put
dup wi
exch dup 0 ne
{
dxb add
}if
exch setcharwidth
dup dxb .01 add 0 ms
0 dxb :T
gS
gl
dup 0 0 ms
gR
basefonto setfont
0 0 ms
end
end
}def
}store :fbase
}bd
/:mss
{
/bfproc{
7 dict begin
/basefont xdf
/FontType 3 def
/FontMatrix[1 0 0 1 0 0]def
/FontBBox[0 0 1 1]def
/Encoding StandardEncoding def
/BuildChar
{
exch begin
sD begin
/dxc 1 ps div def
/dsdx2 .05 dxc 2 div add def
basefont setfont
( )dup 0 4 -1 roll put
dup wi
exch dup 0 ne
{
dsdx2 add
}if
exch setcharwidth
dup dsdx2 .01 add 0 ms
0 .05 dxc 2 div sub :T
dup 0 0 ms
dup dxc 0 ms
dup dxc dxc ms
dup 0 dxc ms
gl
dxc 2 div dup ms
end
end
}def
}store :fbase
}bd
/:msb
{
/bfproc{
7 dict begin
/basefont xdf
/FontType 3 def
/FontMatrix[1 0 0 1 0 0]def
/FontBBox[0 0 1 1]def
/Encoding StandardEncoding def
/BuildChar
{
exch begin
sD begin
/dxd .03 def
basefont setfont
( )dup 0 4 -1 roll put
dup wi
1 index 0 ne
{
exch dxd add exch
}if
setcharwidth
dup 0 0 ms
dup dxd 0 ms
dup dxd dxd ms
0 dxd ms
end
end
}def
}store :fbase
}bd
/italicmtx[1 0 -.212557 1 0 0]def
/:mi
{
italicmtx :mf def
}bd
/:v
{
[exch dup/FontMatrix get exch
dup/FontInfo known
{
/FontInfo get
dup/UnderlinePosition known
{
dup/UnderlinePosition get
2 index 0
3 1 roll
transform
exch pop
}{
.1
}ifelse
3 1 roll
dup/UnderlineThickness known
{
/UnderlineThickness get
exch 0 3 1 roll
transform
exch pop
abs
}{
pop pop .067
}ifelse
}{
pop pop .1 .067
}ifelse
]
}bd
/$t Z
/$p Z
/$s Z
/:p
{
aload pop
2 index mul/$t xs
1 index mul/$p xs
.012 mul/$s xs
}bd
/:m
{gS
0 $p rm
$t lw
0 rl stroke
gR
}bd
/:n
{
gS
0 $p rm
$t lw
0 rl
gS
gl
stroke
gR
strokepath
$s lw
/setstrokeadjust where{pop
currentstrokeadjust true setstrokeadjust stroke setstrokeadjust
}{
stroke
}ifelse
gR
}bd
/:o
{gS
0 $p rm
$t 2 div dup rm
$t lw
dup 0 rl
stroke
gR
:n
}bd
%%EndFile
/currentpacking where {pop sc_oldpacking setpacking}if
end % md
%%EndProlog
%%BeginSetup
md begin
countdictstack
[
{%stopped
%%BeginFeature: *ManualFeed False
1 dict dup /ManualFeed false put setpagedevice
%%EndFeature
}featurecleanup
countdictstack
[
{%stopped
%%BeginFeature: *InputSlot Cassette

%%EndFeature
}featurecleanup
(rEnE)setjob
/pT[1 0 0 -1 29 812]def/mT[1 0 0 -1 29 812]def
/sD 16 dict def
300 level2{1 dict dup/WaitTimeout 4 -1 roll put setuserparams}{statusdict/waittimeout 3 -1 roll put}ifelse
%%IncludeFont: Times-Roman
%%IncludeFont: Times-Bold
%%IncludeFont: Times-Italic
%%IncludeFont: Helvetica-Bold
%%IncludeFont: Helvetica
%%IncludeFont: Courier
/f0_1/Times-Roman :mre
/f0_12 f0_1 12 scf
/f0_10 f0_1 10 scf
/f1_1/Times-Bold :mre
/f1_24 f1_1 24 scf
/f1_18 f1_1 18 scf
/f2_1 f1_1 :v def
/f3_1 f0_1 :v def
/f4_1/Times-Italic :mre
/f4_12 f4_1 12 scf
/f5_1/Helvetica-Bold :mre
/f5_14 f5_1 14 scf
/f6_1/Helvetica :mre
/f6_14 f6_1 14 scf
/f7_1/Courier :mre
/f7_10 f7_1 10 scf
/f8_1 f0_1 1.087 scf
/f8_10 f8_1 10 scf
/f8_9 f8_1 9 scf
/Courier findfont[10 0 0 -10 0 0]:mf setfont
%%EndSetup
%%Page: 1 1
%%BeginPageSetup
initializepage
(rEnE; page: 1 of 12)setjob
%%EndPageSetup
gS 0 0 538 781 rC
420 72 :M
f0_12 sf
-.098(Version 1.3)A
427 90 :M
-.083(1/27/1994)A
218 261 :M
f1_24 sf
24 f2_1 :p
115.001 :m
-.138(Memdebug)A
210 300 :M
f0_12 sf
-.015(Document no TOOL-PM-1)A
225 354 :M
-.054(Author: Schmit Ren\216)A
254 372 :M
-.133(CRP-HT)A
199 390 :M
-.012(Internet: [email protected])A
endp
%%Page: 2 2
%%BeginPageSetup
initializepage
(rEnE; page: 2 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
485 800 :M
-.993(- )A
492 800 :M
-.993(2-)A
88 791 -1 1 507 790 1 88 790 @a
105 101 :M
f5_14 sf
-.012(Table of Contents)A
105 119 :M
f0_12 sf
-.042(Product Overview)A
196 119 :M
(......................................................................................................)S
193 119 :M
( )S
504 119 :M
(3)S
105 137 :M
-.092(Features)A
148 137 :M
(......................................................................................................................)S
146 137 :M
( )S
504 137 :M
(3)S
117 155 :M
-.031(Usage Scope)A
181 155 :M
(...........................................................................................................)S
179 155 :M
( )S
504 155 :M
(3)S
117 173 :M
-.195(Errors)A
148 173 :M
(......................................................................................................................)S
147 173 :M
( )S
504 173 :M
(3)S
117 191 :M
-.036(Statistics)A
163 191 :M
(.................................................................................................................)S
160 191 :M
( )S
504 191 :M
(4)S
117 209 :M
-.03(Customising Memdebug and Debugging)A
313 209 :M
(...............................................................)S
312 209 :M
( )S
504 209 :M
(5)S
105 227 :M
-.108(User Guide)A
163 227 :M
(.................................................................................................................)S
160 227 :M
( )S
504 227 :M
(6)S
117 245 :M
-.011(Using Memdebug in a Program)A
271 245 :M
(.............................................................................)S
268 245 :M
( )S
504 245 :M
(6)S
117 263 :M
-.019(Customising and Debugging Functions)A
307 263 :M
(.................................................................)S
305 263 :M
( )S
504 263 :M
(6)S
105 281 :M
-.026(Limitations and Known Bugs)A
250 281 :M
(....................................................................................)S
247 281 :M
( )S
504 281 :M
(8)S
105 299 :M
-.122(Internals)A
148 299 :M
(......................................................................................................................)S
147 299 :M
( )S
504 299 :M
(9)S
105 317 :M
-.045(Function Prototype List)A
220 317 :M
(..............................................................................................)S
219 317 :M
( )S
504 317 :M
(12)S
105 335 :M
-.03(Bibliography)A
169 335 :M
(...............................................................................................................)S
168 335 :M
( )S
504 335 :M
(12)S
endp
%%Page: 3 3
%%BeginPageSetup
initializepage
(rEnE; page: 3 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
485 800 :M
-.993(- )A
492 800 :M
-.993(3-)A
88 791 -1 1 507 790 1 88 790 @a
261 89 :M
f1_18 sf
-.14(Memdebug)A
105 125 :M
f5_14 sf
(Product Overview)S
105 143 :M
f0_12 sf
.907 .091(Memdebug is a utility that helps you debug all memory allocations and frees in)J
90 155 :M
.784 .078(your C programs. Use Memdebug to trace memory blocks that have not been freed)J
90 167 :M
.183 .018(correctly, to simulate \324out of memory\325 errors and to optimise your )J
f7_10 sf
.065(malloc\(\)/free\(\))A
90 179 :M
f0_12 sf
1.232 .123(sequences. Furthermore, chances are higher that your program will not hang your)J
90 191 :M
.439 .044(computer when it performs some illegal memory operation such as freeing an illegal)J
90 203 :M
.485 .048(pointer. Of course, all these errors are detected at run-time and logged with as much)J
90 215 :M
-.037(debugging data as possible.)A
105 233 :M
.118 .012(Memdebug is written in portable ANSI C, and only minor changes to your sources)J
90 245 :M
.217 .022(are necessary to use its basic features. Later on, all Memdebug calls may be switched)J
90 257 :M
-.006(off at compilation time, so that your final product version won\325t be affected at all.)A
105 292 :M
f5_14 sf
-.048(Features)A
105 321 :M
f6_14 sf
(Usage Scope)S
105 339 :M
f0_12 sf
.371 .037(Memdebug supports all ANSI C <)J
274 339 :M
f7_10 sf
.052(stdlib)A
f0_12 sf
.204 .02(> memory management functions: )J
f7_10 sf
.069(mal-)A
90 351 :M
(loc\(\))S
f0_12 sf
(, )S
f7_10 sf
-.008(calloc\(\))A
f0_12 sf
(, )S
f7_10 sf
-.008(realloc\(\))A
f0_12 sf
( and )S
f7_10 sf
(free\(\))S
f0_12 sf
(.)S
105 369 :M
.654 .065(At compilation time, or more precisely during the pre-processor pass, all calls to)J
90 381 :M
1.27 .127(those functions are changed to calls of Memdebug\325s own routines, which call the)J
90 393 :M
.858 .086(standard library functions during their execution. When the MEMDEBUG pre-pro)J
501 393 :M
(-)S
90 405 :M
.175 .018(cessor symbol is not defined, no substitutions of the standard function calls are made,)J
90 417 :M
1.244 .124(and all Memdebug-specific function calls are changed to empty statements. Thus,)J
90 429 :M
-.012(your final program won\325t be affected by the presence of Memdebug calls.)A
105 447 :M
.025 .003(Only data concerning memory management is treated by Memdebug. Bugs such as)J
90 459 :M
-.019(illegal memory references are only partially detected by Memdebug. Memdebug looks)A
90 471 :M
.666 .067(out for \324off by one\325 errors at the start and end of a memory block. Furthermore, the)J
90 483 :M
.19 .019(content of data may be set to some dummy value by Memdebug\325s version of )J
f7_10 sf
.065(free\(\))A
f0_12 sf
(,)S
90 495 :M
.055 .005(which will probably make your program fail when it accesses this memory block later)J
90 507 :M
(on.)S
105 525 :M
.247 .025(Many errors that are detected won\325t have the usual fatal effect. But beware! Don\325t)J
90 537 :M
1.584 .158(use Memdebug as a \324Bug Preventer\325, as eventually, the bugs will turn up again.)J
90 549 :M
.333 .033(Moreover, the performances of your program degrade dramatically when Memdebug)J
90 561 :M
-.141(is used!)A
105 590 :M
f6_14 sf
-.019(Errors)A
105 608 :M
f0_12 sf
.17 .017(By default, a message will be written to )J
f7_10 sf
.064(stderr)A
f0_12 sf
.189 .019( for each error that Memdebug de)J
501 608 :M
(-)S
90 620 :M
5.008 .501(tects. )J
127 620 :M
f7_10 sf
1.732(stderr)A
f0_12 sf
4.779 .478( may be redirected to another text file specified in the)J
90 632 :M
f7_10 sf
.071(set_MemdebugOptions)A
f0_12 sf
.214 .021(\(\) function. Generally, the message itself is preceded by a file)J
90 644 :M
-.001(name and a line number. It represents the source location where the error occurred.)A
105 662 :M
-.02(The following errors are detected by Memdebug:)A
105 680 :M
.667 .067(Memory exhaustion: No more system or Memdebug memory \(see later\) is avail)J
501 680 :M
(-)S
90 692 :M
.559 .056(able at this point of execution. This error may occur during calls to )J
426 692 :M
f7_10 sf
(malloc\(\))S
f0_12 sf
(, )S
f7_10 sf
(cal-)S
90 704 :M
-.017(loc\(\))A
f0_12 sf
-.013( and )A
f7_10 sf
-.017(realloc\(\))A
f0_12 sf
(.)S
105 722 :M
.032 .003(Unallocated pointer: A pointer is used that was not obtained by a call to )J
f7_10 sf
.012(malloc\(\))A
f0_12 sf
(,)S
90 734 :M
f7_10 sf
.283(calloc\(\))A
f0_12 sf
.328 .033( or )J
158 734 :M
f7_10 sf
.338(realloc\(\))A
f0_12 sf
.844 .084(. This error may occur during calls to the )J
f7_10 sf
.338(realloc\(\))A
f0_12 sf
.881 .088( and)J
90 746 :M
f7_10 sf
-.048(free\(\))A
f0_12 sf
-.04( routines.)A
endp
%%Page: 4 4
%%BeginPageSetup
initializepage
(rEnE; page: 4 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
485 800 :M
-.993(- )A
492 800 :M
-.993(4-)A
88 791 -1 1 507 790 1 88 790 @a
105 81 :M
-.083(Spurious )A
151 81 :M
f7_10 sf
.014(free\(\))A
f0_12 sf
.028 .003( calls: The )J
f7_10 sf
.014(free\(\))A
f0_12 sf
.041 .004( routine has been called with the NULL pointer)J
90 93 :M
.506 .051(as its argument. According to the ANSI standard, this is no error, and )J
437 93 :M
f7_10 sf
(free\(\))S
f0_12 sf
( won\325t)S
90 105 :M
1.478 .148(do anything if this happens, but you might consider it bad programming style to)J
90 117 :M
f7_10 sf
-.033(free\(\))A
f0_12 sf
-.031( NULL pointers.)A
105 135 :M
.15 .015(Unbalanced allocation/free call number: When the program exits, Memdebug tests)J
90 147 :M
1.114 .111(whether all allocated blocks have been freed previously. If this is not he case, the)J
90 159 :M
-.026(number of blocks still allocated are written to )A
311 159 :M
f7_10 sf
-.03(stderr)A
f0_12 sf
-.026(. More information about the un)A
501 159 :M
(-)S
90 171 :M
-.005(freed blocks may be found in the statistical data.)A
105 189 :M
1.486 .149(Corrupted memory blocks: As mentioned above, Memdebug tests whether the)J
90 201 :M
.467 .047(bytes immediately preceding or following a memory block remain unchanged. If the)J
90 213 :M
-.013(user writes at these memory locations, an error will be written to )A
403 213 :M
f7_10 sf
(stderr)S
f0_12 sf
(.)S
105 242 :M
f6_14 sf
(Statistics)S
105 260 :M
f0_12 sf
.804 .08(During run time, Memdebug gathers an abundance of statistical data concerning)J
90 272 :M
.999 .1(memory usage. This information is written to )J
323 272 :M
f7_10 sf
.268(stdout)A
f0_12 sf
.797 .08(, which may be redirected as)J
90 284 :M
-.015(needed. Following are the main categories of data gathered:)A
105 302 :M
.357 .036(General statistics: They include the number of times a given routine has been cal)J
501 302 :M
(-)S
90 314 :M
.435 .044(led, the current, maximal and overall number of currently allocated blocks and bytes)J
90 326 :M
-.013(of memory, and some details about the number of errors that occurred.)A
105 344 :M
.289 .029(Next comes an alphabetically sorted list of all the pointer variables that have been)J
90 356 :M
.723 .072(used. Indicated are the name of the pointers used when the memory block has been)J
90 368 :M
.131 .013(freed, the number of times the block has been freed as well as the overall and average)J
90 380 :M
-.029(size allocated for this variable.)A
105 398 :M
.749 .075(Follows a list containing all variables that have not been freed. Each line begins)J
90 410 :M
.324 .032(with the file name and line number where the memory block was allocated, indicates)J
90 422 :M
.54 .054(the size in bytes and the size expression during allocation and the current content of)J
90 434 :M
.057 .006(the memory pointed to. Of course, the format of the data is unknown, so it is casted to)J
90 446 :M
-.002(a string and serves only as an indication. Non-printing characters are replaced by dots,)A
90 458 :M
-.015(so serial terminals won\325t get disturbed.)A
105 476 :M
.338 .034(Finally, a list containing a trace of all memory management function calls is prin)J
501 476 :M
(-)S
90 488 :M
.135 .013(ted. This list contains the file name and line number of the function call as well as the)J
90 500 :M
.632 .063(name of the pointer variable \(if available\), the block\325s size in bytes and the size ex)J
501 500 :M
(-)S
90 512 :M
-.123(pression.)A
endp
%%Page: 5 5
%%BeginPageSetup
initializepage
(rEnE; page: 5 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
485 800 :M
-.993(- )A
492 800 :M
-.993(5-)A
88 791 -1 1 507 790 1 88 790 @a
105 95 :M
f6_14 sf
-.022(Customising Memdebug and Debugging)A
105 113 :M
f0_12 sf
.308 .031(The user may customise Memdebug\325s output and it\325s behaviour during allocation.)J
90 125 :M
-.01(To do so, he has to insert routine calls into his source programs. As already mentioned)A
90 137 :M
.977 .098(earlier, these calls will be wiped out by macro definitions when the MEMDEBUG)J
90 149 :M
.254 .025(symbol is not defined during compilation, and the presence of these routine calls will)J
90 161 :M
-.024(not affect the final program behaviour.)A
105 179 :M
.623 .062(The main customisation routine is the )J
296 179 :M
f7_10 sf
.08(set_MemdebugOptions)A
f0_12 sf
.244 .024(\(\) routine. It serves)J
90 191 :M
.209 .021(to select the statistics to be printed and to specify the output files, that\325s to say the re)J
501 191 :M
(-)S
90 203 :M
.737 .074(direction of )J
152 203 :M
f7_10 sf
.271(stderr)A
f0_12 sf
.439 .044( and )J
215 203 :M
f7_10 sf
.346(stdout)A
f0_12 sf
.912 .091(. Furthermore, the user may set a limit in bytes or)J
90 215 :M
-.018(calls for the allocation routines.)A
105 233 :M
.188 .019(The )J
f7_10 sf
.073(print_MemdebugStatistics)A
f0_12 sf
.215 .022(\(\) routine may be inserted to explicitly print out)J
90 245 :M
.581 .058(the statistics file at a given moment. Thus, the user may make a kind of snapshot of)J
90 257 :M
-.015(the memory status anywhere in the program. Memdebug won\325t print out automatically)A
90 269 :M
-.014(a final statistic report when this routine has been called once.)A
105 287 :M
.271 .027(The )J
f7_10 sf
.105(check_MemdebugError\(\))A
f0_12 sf
.329 .033( function returns the number of illegal memory op)J
501 287 :M
(-)S
90 299 :M
.043 .004(erations that occurred during program execution. This function is especially useful for)J
90 311 :M
.222 .022(behind-the-scenes test programs that do no direct output. This is also why no implicit)J
90 323 :M
-.009(final statistics will be printed.)A
105 341 :M
.29 .029(One last routine, )J
190 341 :M
f7_10 sf
.092(generate_MemdebugError)A
f0_12 sf
.257 .026(\(\), is used to simulate out of memory)J
90 353 :M
.489 .049(errors. The next allocation after this call will fail. With the )J
383 353 :M
f7_10 sf
-.047(set_MemdebugOptions)A
f0_12 sf
-.063(\(\))A
90 365 :M
.518 .052(routine, you may specify the number of )J
f7_10 sf
.176(generate_MemdebugError)A
f0_12 sf
.495 .05(\(\) calls that may)J
90 377 :M
-.008(be done before an error occurs.)A
endp
%%Page: 6 6
%%BeginPageSetup
initializepage
(rEnE; page: 6 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
485 800 :M
-.993(- )A
492 800 :M
-.993(6-)A
88 791 -1 1 507 790 1 88 790 @a
105 101 :M
f5_14 sf
-.075(User Guide)A
105 130 :M
f6_14 sf
-.026(Using Memdebug in a Program)A
105 148 :M
f0_12 sf
-.014(To produce the MEMDEBUG object code files, you have to compile )A
439 148 :M
f7_10 sf
(memdebug.c,)S
90 160 :M
.053(memfree.c)A
f0_12 sf
.086 .009( and )J
169 160 :M
f7_10 sf
.08(memalpha.c)A
f0_12 sf
.246 .025(. BEWARE: don\325t define the )J
f7_10 sf
.08(MEMDEBUG)A
f0_12 sf
.234 .023( symbol, else the)J
90 172 :M
-.008(utility will end up in an infinite loop!)A
105 190 :M
-.002(Hint for UNIX users: with the ar command, create an archive file!)A
105 208 :M
.644 .064(Three operations are necessary to add Memdebug\325s facilities to a program. First,)J
90 220 :M
.409 .041(the <)J
116 220 :M
f7_10 sf
.237(Memdebug.h)A
f0_12 sf
.65 .065(> library header needs to be included into )J
12 f3_1 :p
27.697 :m
.21(every)A
.571 .057( source file of the)J
90 232 :M
.276 .028(program. If the program owns a common header file that is included everywhere, it\325s)J
90 244 :M
-.028(simplest to include <)A
f7_10 sf
-.035(Memdebug.h)A
f0_12 sf
-.031(> there.)A
105 262 :M
2.578 .258(Then, the MEMDEBUG pre-processor symbol has to be defined to enable)J
90 274 :M
-.003(Memdebug\325s functions. If possible, you should do this on the compiler call line \(using)A
90 286 :M
-.017(-d or -define or similar\). Of course, you may also define \(or #undefine\) the symbol be)A
501 286 :M
(-)S
90 298 :M
-.03(fore every inclusion of <)A
209 298 :M
f7_10 sf
-.065(Memdebug.h)A
f0_12 sf
-.105(>.)A
105 316 :M
-.012(Finally, you will need to include the Memdebug objects file to your link list.)A
105 334 :M
.006 .001(This is all that is needed to get the basic, default information of Memdebug. All er)J
501 334 :M
(-)S
90 346 :M
.489 .049(rors will be detected by Memdebug, and final statistics will be generated. All output)J
90 358 :M
.488 .049(will be send to )J
167 358 :M
f7_10 sf
.069(stderr)A
f0_12 sf
.112 .011( and )J
228 358 :M
f7_10 sf
.142(stdout)A
f0_12 sf
.396 .04(. The internal memory limit is set to infinite, and)J
90 370 :M
.041 .004(no call sequence trace is generated \(to save some memory\). Memory contents are des)J
501 370 :M
(-)S
90 382 :M
-.075(troyed when a )A
161 382 :M
f7_10 sf
-.012(free\(\))A
f0_12 sf
-.01( of a pointer is made.)A
105 400 :M
.263 .026(The first call to a memory management function will start Memdebug. Thus, if no)J
90 412 :M
-.004(memory function is used, no final statistics will be printed.)A
105 441 :M
f6_14 sf
-.011(Customising and Debugging Functions)A
90 474 :M
f7_10 sf
(enum t_Option)S
90 485 :M
({)S
118 496 :M
(c_No = 0,)S
118 507 :M
(c_Yes)S
90 518 :M
(};)S
90 540 :M
(typedef enum t_Option t_Option;)S
90 551 :M
(void set_MemdebugOptions\()S
260 562 :M
(t_Option)S
316 562 :M
(p_GeneralStatistics,)S
260 573 :M
(t_Option)S
316 573 :M
(p_AlphabeticalList,)S
260 584 :M
(t_Option)S
316 584 :M
(p_NotFreeList,)S
260 595 :M
(t_Option)S
316 595 :M
(p_CallSequenceList,)S
260 617 :M
(t_Option)S
316 617 :M
(p_SpuriousFreeList,)S
260 639 :M
(t_Option)S
316 639 :M
(p_PrintContents,)S
260 650 :M
(t_Option)S
316 650 :M
(p_DestroyContents,)S
260 672 :M
(long)S
316 672 :M
(p_GenerateErrorCount,)S
260 683 :M
(size_t)S
316 683 :M
(p_MaximalMemoryAvailable,)S
260 705 :M
(char* )S
316 705 :M
(p_StatisticsFileName,)S
260 716 :M
(char* )S
316 716 :M
(p_ErrorFileName)S
231 727 :M
(\);)S
endp
%%Page: 7 7
%%BeginPageSetup
initializepage
(rEnE; page: 7 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
485 800 :M
-.993(- )A
492 800 :M
-.993(7-)A
88 791 -1 1 507 790 1 88 790 @a
105 81 :M
.241 .024(The )J
f7_10 sf
.093(set_MemdebugOptions)A
f0_12 sf
.331 .033(\(\) function changes the options setting of Memdebug.)J
90 93 :M
.596 .06(The first four parameters are used to tell Memdebug which statistic listings to print.)J
90 105 :M
f7_10 sf
-.018(p_Spuriousfree)A
f0_12 sf
-.015( may be set to c_No if you don\325t care about )A
385 105 :M
f7_10 sf
-.066(free\(NULL\))A
f0_12 sf
-.052( calls.)A
105 123 :M
f7_10 sf
-.024(p_PrintContents)A
f0_12 sf
-.019( determines if the contents of an allocated pointer will be prin)A
490 123 :M
-.33(ted)A
90 135 :M
-.011(out in string format. This may be turned off if you don\325t care about the contents.)A
105 153 :M
.205 .02(When )J
f7_10 sf
.058(p_DestroyContents)A
f0_12 sf
.083 .008( is set to )J
284 153 :M
f7_10 sf
.077(c_Yes)A
f0_12 sf
.219 .022( \(the default\), the contents of the mem)J
501 153 :M
(-)S
90 165 :M
-.002(ory pointed to by a pointer will be replaced by the \324@\325 character before the memory is)A
90 177 :M
.38 .038(released. This will probably result in a run-time error when the memory is \(illegally\))J
90 189 :M
-.049(referenced later on.)A
105 207 :M
6.672 .667(In )J
127 207 :M
f7_10 sf
1.257(p_GenerateErrorCount)A
f0_12 sf
3.327 .333(, you may indicate the number of )J
469 207 :M
f7_10 sf
(gener-)S
90 219 :M
.056(ate_MemdebugError\(\))A
f0_12 sf
.153 .015( calls that may be done before an error is generated. This may)J
90 231 :M
.68 .068(be useful if you suspect your program to fail only after the n\325th memory alloca)J
483 231 :M
-.167(tion.)A
90 243 :M
-.033(The default error count is 0.)A
105 261 :M
(With )S
133 261 :M
f7_10 sf
.089(p_MaximalMemoryAvailable)A
f0_12 sf
.272 .027(, you may set the maximal amount of memory)J
90 273 :M
.67 .067(that Memdebug will allocate at a given time. This parameter will be ignored during)J
90 285 :M
.347 .035(subsequent calls of )J
187 285 :M
f7_10 sf
.098(set_MemdebugOptions)A
f0_12 sf
.293 .029(, and you can\325t set the memory limitation)J
90 297 :M
.018 .002(to 0 bytes \(in fact, 0 is used to indicate \324no change in setting\325\). Note however that sys)J
501 297 :M
(-)S
90 309 :M
.112 .011(tem memory may run out before it reaches the limit you indicate, and that Memdebug)J
90 321 :M
.898 .09(doesn\325t care about memory fragmentation. To test real life memory limitations, set)J
90 333 :M
-.003(this limit to a lower value than the actual memory limit of the target machine!)A
105 351 :M
f7_10 sf
.069(p_StatisticsFileName)A
f0_12 sf
.167 .017( and)J
f7_10 sf
.443 .044( p_ErrorFileName)J
345 351 :M
f0_12 sf
1.143 .114( indicate the file names that re)J
501 351 :M
(-)S
90 363 :M
.479 .048(place )J
f7_10 sf
.162(stdout)A
f0_12 sf
.263 .026( and )J
181 363 :M
f7_10 sf
.201(stderr)A
f0_12 sf
.478 .048(. If you pass the empty string, )J
f7_10 sf
.201(stdout)A
f0_12 sf
.325 .033( and )J
431 363 :M
f7_10 sf
.085(stderr)A
f0_12 sf
.188 .019( will be)J
90 375 :M
.099 .01(used. The previous file\(s\) will be closed automatically \(except, of course, )J
448 375 :M
f7_10 sf
-.034(stdout)A
f0_12 sf
-.038( and)A
90 387 :M
f7_10 sf
-.137(stderr)A
f0_12 sf
-.16(\).)A
90 420 :M
f7_10 sf
(void print_MemdebugStatistics)S
288 420 :M
(\( void \);)S
105 434 :M
f0_12 sf
.235 .023(Calling this function will cause Memdebug to generate a statistic listing, using the)J
90 446 :M
-.046(currently set options.)A
90 479 :M
f7_10 sf
(int)S
118 479 :M
(check_MemdebugError)S
288 479 :M
(\( void \);)S
105 493 :M
f0_12 sf
1.101 .11(Returns the number of illegally freed memory, spurious )J
391 493 :M
f7_10 sf
.166(free\(\))A
f0_12 sf
.602 .06(s and corrupted)J
90 505 :M
-.005(blocks. No more implicit statistics will be printed.)A
90 538 :M
f7_10 sf
(void generate_MemdebugError)S
288 538 :M
(\( void \);)S
105 552 :M
f0_12 sf
2.326 .233(The next call to )J
197 552 :M
f7_10 sf
.448(malloc\(\))A
f0_12 sf
.373 .037(, )J
f7_10 sf
.448(calloc\(\))A
f0_12 sf
.591 .059(, or )J
328 552 :M
f7_10 sf
.494(realloc\(\))A
f0_12 sf
1.067 .107( will fail when )J
f7_10 sf
.592(gener-)A
90 564 :M
.289(ate_MemdebugError)A
f0_12 sf
.682 .068( has been called )J
281 564 :M
f7_10 sf
.177(p_GenerateErrorCount)A
f0_12 sf
.572 .057( times, regardless of)J
90 576 :M
-.015(the option settings and the size of the block to be allocated.)A
endp
%%Page: 8 8
%%BeginPageSetup
initializepage
(rEnE; page: 8 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
485 800 :M
-.993(- )A
492 800 :M
-.993(8-)A
88 791 -1 1 507 790 1 88 790 @a
105 101 :M
f5_14 sf
-.034(Limitations and Known Bugs)A
105 119 :M
f0_12 sf
.625 .063(Memdebug may hide some bugs in your program. Errors such as deallocating an)J
90 131 :M
-.668(il)A
97 131 :M
.277 .028(legal pointer will no more cause your program to hang, but only until Memdebug is)J
90 143 :M
1.682 .168(turned off again. Thus, you should always inspect the error listing generated by)J
90 155 :M
-.082(Memdebug.)A
105 173 :M
.88 .088(Memdebug is quite a resource-intensive utility. It will slow down your program)J
90 185 :M
.497 .05(considerably \(maybe up to a hundred times!!!\), and it needs a lot of space to memo)J
501 185 :M
(-)S
90 197 :M
-.01(rise all information. Thus, if your program itself uses much memory, or if you allocate)A
90 209 :M
2.621 .262(many small blocks, your system may run out of memory, and you can\325t use)J
90 221 :M
.749 .075(Memdebug. But before giving up, try turning off the allocation trace function. This)J
90 233 :M
-.023(may save a considerable amount of memory!)A
105 251 :M
.964 .096(Due to the slowing down of your application, you should be cautious while de)J
501 251 :M
(-)S
90 263 :M
-.003(bugging real-time applications. Memdebug may mess up all of your timing.)A
105 281 :M
.985 .098(Final statistics printout and data cleanup are done by exit functions. So, if your)J
90 293 :M
.422 .042(program also installs exit functions, and your system imposes some limit concerning)J
90 305 :M
.377 .038(the number of such functions, you should know that there is one \(1\) such function in)J
90 317 :M
.181 .018(Memdebug. Ensure all additional data cleanup functions are installed AFTER the ini)J
501 317 :M
(-)S
90 329 :M
-.002(tialisation of Memdebug, or you might get erroneous \324pointer not freed\325 messages.)A
105 347 :M
.074 .007(Each redirection of an output uses one file descriptor, which might cause problems)J
90 359 :M
-.008(with programs using a lot of files.)A
105 377 :M
2.217 .222(There might be a very slight chance that there\325s still some memory bug in)J
90 389 :M
1.308 .131(Memdebug \(such as an unreleased pointer\). Unfortunately, debugging Memdebug)J
90 401 :M
-.015(with Memdebug ends up in an infinite loop\311)A
105 419 :M
.558 .056(Besides: beware when compiling the library: don\325t compile it with the )J
f7_10 sf
.203(MEMDEBUG)A
90 431 :M
f0_12 sf
.887 .089(symbol defined, else your program will end up in an infinite loop. The Memdebug)J
90 443 :M
.145 .014(functions themselves call memory allocation functions that, when Memdebug\325ed, call)J
90 455 :M
-.027(again a Memdebug function and so on.)A
105 473 :M
.937 .094(One last note: Never \(and in this context, never means )J
384 473 :M
f4_12 sf
.238(NEVER)A
f0_12 sf
.56 .056(\) ship a program)J
90 485 :M
.309 .031(version that has Memdebug enabled. Anyhow, your customers won\325t like an applica)J
501 485 :M
(-)S
90 497 :M
.441 .044(tion that\325s that slow and eats up so much memory. Memdebug is not a \324Bug Hiding\325)J
90 509 :M
-.025(tool, but a debugging tool!)A
endp
%%Page: 9 9
%%BeginPageSetup
initializepage
(rEnE; page: 9 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
485 800 :M
-.993(- )A
492 800 :M
-.993(9-)A
88 791 -1 1 507 790 1 88 790 @a
105 101 :M
f5_14 sf
-.042(Internals)A
105 119 :M
f0_12 sf
.087 .009(Extensive use is made of the C pre-processor. All function calls are either replaced)J
90 131 :M
2.041 .204(by macro calls \(when Memdebug is enabled\), or faded out \(in the other case\).)J
90 143 :M
.292 .029(Furthermore, the pre-defined symbols __FILE__ and __LINE__ are used to get loca)J
501 143 :M
(-)S
90 155 :M
.117 .012(tion information. All parameters are passed once with the # prefix, so that Memdebug)J
90 167 :M
-.014(gets information about the identifiers and size expressions used.)A
105 185 :M
.006 .001(Initialisation of Memdebug is done during the first call of one of Memdebug\325s rou)J
501 185 :M
(-)S
90 197 :M
.454 .045(tines, including )J
f7_10 sf
.131(malloc\(\))A
f0_12 sf
.109 .011(, )J
f7_10 sf
.131(calloc\(\))A
f0_12 sf
.109 .011(, )J
f7_10 sf
.131(realloc\(\))A
f0_12 sf
.212 .021( and )J
359 197 :M
f7_10 sf
.102(free\(\))A
f0_12 sf
.336 .034(. An initialisation rou)J
501 197 :M
(-)S
90 209 :M
.358 .036(tine is called each time, but when it has been called once, it will exit immediately on)J
90 221 :M
-.014(every subsequent call.)A
105 239 :M
.784 .078(Memdebug\325s last statistic printout and all data cleanup are done at exit time. To)J
90 251 :M
.533 .053(achieve this, some exit handlers have been installed, using the atexit\(\) )J
f7_10 sf
.173(stdlib)A
f0_12 sf
.501 .05( func)J
501 251 :M
(-)S
90 263 :M
-.167(tion.)A
105 281 :M
.193 .019(The data structures used by Memdebug are primarily some simple counters to col)J
501 281 :M
(-)S
90 293 :M
.287 .029(lect usage number and size statistics. The operations performed on these counters are)J
90 305 :M
-.064(straightforward.)A
105 323 :M
.127 .013(The \324of by one\325 error checking is done with prefix and postfix sentinels. Instead of)J
90 335 :M
.46 .046(allocating a block with the exact size required, Memdebug allocates some additional)J
90 347 :M
-.016(space \(see fig. 1\))A
105 365 :M
.035 .003(Memdebug now fills the two sentinels with a random value, which is also stored in)J
90 377 :M
.303 .03(the internal block descriptor \(see below\). When the block is either realloced or freed,)J
90 389 :M
.054 .005(the three values are compared against each other, and an error is generated should one)J
90 401 :M
-.005(of the sentinels no longer contain its original value.)A
212 428 185 127 rC
215.5 485.5 180 21 rS
-1 -1 237 507 1 1 236 485 @b
-1 -1 372 507 1 1 371 485 @b
13 10 58 225 510 @k
230 514 -1 1 282 548 1 230 513 @a
13 122 170 384 512 @k
-1 -1 337 546 1 1 379 515 @b
286 551 :M
-.124(Sentinels)A
13 -114 -66 244 483 @k
-1 -1 245 478 1 1 244 451 @b
258 457 :M
-.08(User pointer returned)A
13 -114 -66 217 482 @k
-1 -1 218 477 1 1 217 433 @b
228 439 :M
-.18(Allocated memory blocks)A
gR
gS 29 30 538 781 rC
294 570 :M
f0_10 sf
-.021(fig. 1)A
endp
%%Page: 10 10
%%BeginPageSetup
initializepage
(rEnE; page: 10 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
479 800 :M
-.993(- )A
486 800 :M
-.497(10-)A
88 791 -1 1 507 790 1 88 790 @a
105 84 :M
.401 .04(Memorisation and semantic checking of the storage allocator functions required a)J
90 96 :M
.091 .009(much more sophisticated data structure. Each memory block is represented by two re)J
501 96 :M
(-)S
90 108 :M
.83 .083(cords. One record contains general information about a variable, while another one)J
90 120 :M
.184 .018(contains information about a particular instantiation of the variable. The first one will)J
90 132 :M
-.013(be called \324Block Descriptor\325, and the second one \324Call Sequence\325.)A
105 150 :M
1.193 .119(When a block is allocated, a BlockDescriptor is created, and the pointer to the)J
90 162 :M
2.971 .297(block is stored in it. A reference to it is stored in an AVL tree called the)J
90 174 :M
.34 .034(NotFreedTree, the pointer being used as a key. An AVL tree has been chosen for the)J
90 186 :M
.728 .073(following reason: )J
181 186 :M
f7_10 sf
.247(malloc\(\))A
f0_12 sf
.811 .081( tends to allocate memory in subsequent locations, and)J
90 198 :M
.233 .023(using a simple tree would be equivalent to using a list \(the tree would degenerate\). In)J
90 210 :M
.359 .036(consequence, each retrieval of a BlockDescriptor will be accelerated considerable by)J
90 222 :M
.797 .08(using an AVL tree, even if insertion and deletion of a node in such a tree are quite)J
90 234 :M
-.11(costly.)A
105 252 :M
.079 .008(A CallSequence record is allocated next, and in it are stored all data relevant to the)J
90 264 :M
3.075 .308(allocation of the block \(the location, the size and so on\). A pointer to the)J
90 276 :M
.267 .027(BlockDescriptor is stored into the CallSequence descriptor, and vice versa. This dou)J
501 276 :M
(-)S
90 288 :M
2.827 .283(ble reference will be used later on during the )J
347 288 :M
f7_10 sf
.498(free\(\))A
f0_12 sf
1.707 .171( operation. Finally, the)J
90 300 :M
-.014(CallSequence is inserted into the call sequence list \(see fig. 2\))A
189 309 232 214 rC
252 431 -1 1 304 518 1 252 430 @a
-1 -1 213 516 1 1 251 431 @b
228 482 -1 1 250 514 1 228 481 @a
-1 -1 271 517 1 1 283 484 @b
1 G
280 481 9 10 rF
0 G
280.5 481.5 8 9 rS
1 G
223 476 11 12 rF
0 G
223.5 476.5 10 11 rS
1 G
208 511 11 11 rF
0 G
208.5 511.5 10 10 rS
1 G
243 510 11 11 rF
0 G
243.5 510.5 10 10 rS
1 G
268 392 37 26 rF
0 G
268.5 392.5 36 25 rS
1 G
247 428 11 9 rF
0 G
247.5 428.5 10 8 rS
1 G
264 510 11 12 rF
0 G
264.5 510.5 10 11 rS
1 G
295 510 12 12 rF
0 G
295.5 510.5 11 11 rS
1 G
209 340 34 20 rF
0 G
209.5 340.5 33 19 rS
1 G
266 340 34 20 rF
0 G
266.5 340.5 33 19 rS
13 66 114 285 417 @k
-1 -1 286 481 1 1 285 423 @b
13 156 204 266 345 @k
242 346 -1 1 261 345 1 242 345 @a
13 -24 24 242 355 @k
248 356 -1 1 267 355 1 248 355 @a
13 66 114 279 359 @k
13 -114 -66 279 392 @k
-1 -1 280 387 1 1 279 365 @b
318 414 :M
f8_10 sf
(Block Descriptor)S
318 352 :M
(Call Sequence List)S
318 507 :M
(Free Tree)S
gR
gS 29 30 538 781 rC
294 538 :M
f0_10 sf
-.209(Fig.2)A
endp
%%Page: 11 11
%%BeginPageSetup
initializepage
(rEnE; page: 11 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
479 800 :M
-.993(- )A
486 800 :M
-.497(11-)A
88 791 -1 1 507 790 1 88 790 @a
105 84 :M
3.101 .31(During a )J
160 84 :M
f7_10 sf
.807(free\(\))A
f0_12 sf
2.444 .244( operation, the BlockDescriptor is first looked for in the)J
90 96 :M
1.113 .111(NotFreedTree. If it isn\325t found, an illegal deallocation has been attempted, and no)J
90 108 :M
.414 .041(further actions are performed. If it is found, the variable that hold the pointer will be)J
90 120 :M
1.211 .121(looked for in another AVL Tree, the AllocatedTree. In this tree, references to the)J
90 132 :M
.253 .025(block descriptors of all already freed variables are stored, the variable identifier ser)J
495 132 :M
-.993(v-)A
90 144 :M
.054 .005(ing as key. When the variable is found in this tree, the corresponding BlockDescriptor)J
90 156 :M
.155 .015(is updated, and the intermediate block descriptor is freed. If the variable was not used)J
90 168 :M
.152 .015(previously in a )J
166 168 :M
f7_10 sf
.075(free\(\))A
f0_12 sf
.243 .024( call, a reference to the intermediate BlockDescriptor is stored)J
90 180 :M
-.036(into the tree \(see fig. 3\).)A
105 198 :M
.426 .043(Furthermore, if the function trace service is enabled, a CallSequence descriptor is)J
90 210 :M
.727 .073(appended to the CallSequenceList. In the other case, the )J
f7_10 sf
.236(malloc\(\))A
f0_12 sf
.634 .063( descriptor is re)J
501 210 :M
(-)S
90 222 :M
-.021(moved from this list, which saves much memory.)A
107 231 396 233 rC
170 353 -1 1 222 440 1 170 352 @a
-1 -1 131 438 1 1 169 353 @b
146 404 -1 1 168 436 1 146 403 @a
-1 -1 189 439 1 1 201 406 @b
1 G
198 403 9 10 rF
0 G
198.5 403.5 8 9 rS
1 G
141 398 11 12 rF
0 G
141.5 398.5 10 11 rS
1 G
126 433 11 11 rF
0 G
126.5 433.5 10 10 rS
1 G
161 432 11 11 rF
0 G
161.5 432.5 10 10 rS
1 G
186 314 37 26 rF
0 G
186.5 314.5 36 25 rS
1 G
165 350 11 9 rF
0 G
165.5 350.5 10 8 rS
1 G
182 432 11 12 rF
0 G
182.5 432.5 10 11 rS
1 G
213 432 12 12 rF
0 G
213.5 432.5 11 11 rS
1 G
127 262 34 20 rF
0 G
127.5 262.5 33 19 rS
1 G
184 262 34 20 rF
0 G
184.5 262.5 33 19 rS
.25 G
13 66 114 203 339 @k
-1 -1 204 403 1 1 203 345 @b
0 G
13 156 204 184 267 @k
160 268 -1 1 179 267 1 160 267 @a
13 -24 24 160 277 @k
166 278 -1 1 185 277 1 166 277 @a
.25 G
13 66 114 197 281 @k
13 -114 -66 197 314 @k
-1 -1 198 309 1 1 197 287 @b
227 333 :M
0 G
f8_10 sf
(Block Descriptor)S
400 280 :M
(Call Sequence List)S
149 461 :M
(Free Tree)S
403 347 -1 1 455 434 1 403 346 @a
-1 -1 364 432 1 1 402 347 @b
379 398 -1 1 401 430 1 379 397 @a
-1 -1 422 433 1 1 434 400 @b
1 G
431 397 9 10 rF
0 G
431.5 397.5 8 9 rS
1 G
374 392 11 12 rF
0 G
374.5 392.5 10 11 rS
1 G
359 427 11 11 rF
0 G
359.5 427.5 10 10 rS
1 G
394 426 11 11 rF
0 G
394.5 426.5 10 10 rS
1 G
398 344 11 9 rF
0 G
398.5 344.5 10 8 rS
1 G
415 426 11 12 rF
0 G
415.5 426.5 10 11 rS
1 G
446 426 12 12 rF
0 G
446.5 426.5 11 11 rS
13 -5 43 223 338 @k
229 341 -1 1 373 391 1 229 340 @a
1 G
240 263 34 20 rF
0 G
240.5 263.5 33 19 rS
1 G
298 263 34 20 rF
0 G
298.5 263.5 33 19 rS
1 G
356 264 34 20 rF
0 G
356.5 264.5 33 19 rS
13 -37 11 222 318 @k
-1 -1 229 318 1 1 360 284 @b
13 -24 24 216 277 @k
222 278 -1 1 241 277 1 222 277 @a
13 -24 24 273 277 @k
279 278 -1 1 298 277 1 279 277 @a
13 -24 24 332 279 @k
338 280 -1 1 357 279 1 338 279 @a
13 156 204 241 267 @k
217 268 -1 1 236 267 1 217 267 @a
13 156 204 299 268 @k
275 269 -1 1 294 268 1 275 268 @a
13 156 204 356 269 @k
332 270 -1 1 351 269 1 332 269 @a
13 66 114 374 239 @k
-1 -1 375 263 1 1 374 245 @b
13 -24 24 199 239 @k
205 240 -1 1 375 239 1 205 239 @a
13 -114 -66 199 262 @k
-1 -1 200 257 1 1 199 239 @b
185 275 :M
f8_9 sf
(malloc)S
363 277 :M
(free)S
366 458 :M
f8_10 sf
(Alphabetical )S
366 470 :M
(Tree)S
gR
gS 29 30 538 781 rC
293 479 :M
f0_10 sf
-.067(Fig 3.)A
105 496 :M
f0_12 sf
-.663(A )A
117 496 :M
f7_10 sf
-.013(calloc\(\))A
f0_12 sf
-.01( call is treated similarly to a )A
f7_10 sf
-.013(malloc\(\))A
f0_12 sf
-.01( call.)A
105 514 :M
4.852 .485(A )J
123 514 :M
f7_10 sf
.874(realloc\(\))A
f0_12 sf
2.941 .294( call requires updating the information in the intermediary)J
90 526 :M
.814 .081(BlockDescriptor and adding a CallSequence block to the corresponding list. As the)J
90 538 :M
1.16 .116(pointer to the allocated block is the key in the NotFreedTree and )J
425 538 :M
f7_10 sf
.105(realloc\(\))A
f0_12 sf
.317 .032( may)J
90 550 :M
.288 .029(change this pointer, the reference to the BlockDescriptor is always removed from the)J
90 562 :M
-.009(tree and inserted again after the reallocation. Furthermore, an additional link is used in)A
90 574 :M
.498 .05(the CallSequenceList, connecting a )J
f7_10 sf
.13(realloc\(\))A
f0_12 sf
.348 .035( descriptor to its previous )J
f7_10 sf
.146(realloc\(\))A
90 586 :M
f0_12 sf
-.043(or its original )A
158 586 :M
f7_10 sf
-.092(malloc\(\))A
f0_12 sf
-.082( or )A
222 586 :M
f7_10 sf
-.057(calloc\(\))A
f0_12 sf
-.046( descriptor.)A
endp
%%Page: 12 12
%%BeginPageSetup
initializepage
(rEnE; page: 12 of 12)setjob
%%EndPageSetup
-29 -30 :T
gS 29 30 538 781 rC
450 48 :M
f0_12 sf
-.093(Memdebug)A
88 52 -1 1 507 51 1 88 51 @a
479 800 :M
-.993(- )A
486 800 :M
-.497(12-)A
88 791 -1 1 507 790 1 88 790 @a
105 101 :M
f5_14 sf
-.003(Function Prototype List)A
90 145 :M
f7_10 sf
(void generate_MemdebugError)S
288 145 :M
(\( void \);)S
90 167 :M
(void print_MemdebugStatistics)S
288 167 :M
(\( void \);)S
90 189 :M
(int)S
118 189 :M
(check_MemdebugError)S
288 189 :M
(\( void \);)S
90 211 :M
(void set_MemdebugOptions\()S
260 211 :M
(t_biState)S
345 211 :M
(p_GeneralStatistics,)S
260 222 :M
(t_biState)S
345 222 :M
(p_AlphabeticalList,)S
260 233 :M
(t_biState)S
345 233 :M
(p_NotFreeList,)S
260 244 :M
(t_biState)S
345 244 :M
(p_CallSequenceList,)S
260 266 :M
(t_biState)S
345 266 :M
(p_SpuriousFreeList,)S
260 288 :M
(t_biState)S
345 288 :M
(p_PrintContents,)S
260 299 :M
(t_biState)S
345 299 :M
(p_DestroyContents,)S
260 321 :M
(long)S
345 321 :M
(p_GenerateErrorCount,)S
260 332 :M
(t_MemorySize)S
345 332 :M
(p_MaximalMemoryAvailable,)S
260 354 :M
(char)S
316 354 :M
( *)S
345 354 :M
(p_StatisticsFileName,)S
260 365 :M
(char)S
316 365 :M
( *)S
345 365 :M
(p_ErrorFileName)S
231 376 :M
(\);)S
105 443 :M
f5_14 sf
-.049(Bibliography)A
105 461 :M
f0_12 sf
-.025(K&R: )A
f7_10 sf
-.024(stdlib)A
f0_12 sf
-.018( for description of )A
263 461 :M
f7_10 sf
(malloc\(\))S
f0_12 sf
(,)S
f7_10 sf
(free\(\))S
f0_12 sf
(, )S
f7_10 sf
(calloc\(\))S
f0_12 sf
(,)S
f7_10 sf
(realloc\(\))S
endp
%%Trailer
end % md
%%EOF


  3 Responses to “Category : C Source Code
Archive   : MEMDEBUG.ZIP
Filename : MEMDEBUG.PS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/