Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
libX11
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
92
Issues
92
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xorg
lib
libX11
Commits
6d1dc1f6
Commit
6d1dc1f6
authored
Jun 04, 2015
by
Alan Coopersmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert main src directory to use reallocarray()
parent
bcf7b5aa
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
89 additions
and
68 deletions
+89
-68
src/Depths.c
src/Depths.c
+2
-1
src/FSWrap.c
src/FSWrap.c
+3
-2
src/Font.c
src/Font.c
+9
-7
src/FontInfo.c
src/FontInfo.c
+7
-6
src/FontNames.c
src/FontNames.c
+2
-1
src/GetFPath.c
src/GetFPath.c
+2
-1
src/GetMoEv.c
src/GetMoEv.c
+2
-1
src/GetPntMap.c
src/GetPntMap.c
+2
-2
src/GetRGBCMap.c
src/GetRGBCMap.c
+2
-1
src/LiICmaps.c
src/LiICmaps.c
+2
-2
src/LiProps.c
src/LiProps.c
+2
-2
src/ListExt.c
src/ListExt.c
+2
-1
src/ModMap.c
src/ModMap.c
+2
-1
src/PixFormats.c
src/PixFormats.c
+2
-1
src/PolyReg.c
src/PolyReg.c
+3
-2
src/PutImage.c
src/PutImage.c
+3
-2
src/QuColors.c
src/QuColors.c
+3
-2
src/QuTree.c
src/QuTree.c
+2
-2
src/Quarks.c
src/Quarks.c
+7
-6
src/RdBitF.c
src/RdBitF.c
+3
-3
src/Region.c
src/Region.c
+6
-5
src/SetHints.c
src/SetHints.c
+3
-4
src/SetRGBCMap.c
src/SetRGBCMap.c
+4
-3
src/TextToStr.c
src/TextToStr.c
+2
-2
src/VisUtil.c
src/VisUtil.c
+5
-3
src/WrBitF.c
src/WrBitF.c
+2
-1
src/XlibInt.c
src/XlibInt.c
+5
-4
No files found.
src/Depths.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <stdio.h>
/*
...
...
@@ -49,7 +50,7 @@ int *XListDepths (
register
Depth
*
dp
;
register
int
i
;
depths
=
Xmalloc
(
count
*
sizeof
(
int
));
depths
=
Xmalloc
array
(
count
,
sizeof
(
int
));
if
(
!
depths
)
return
NULL
;
for
(
i
=
0
,
dp
=
scr
->
depths
;
i
<
count
;
i
++
,
dp
++
)
depths
[
i
]
=
dp
->
depth
;
...
...
src/FSWrap.c
View file @
6d1dc1f6
...
...
@@ -63,6 +63,7 @@ from The Open Group.
#include "Xlcint.h"
#include <ctype.h>
#include <X11/Xos.h>
#include "reallocarray.h"
#define XMAXLIST 256
...
...
@@ -112,7 +113,7 @@ _XParseBaseFontNameList(
if
(
!*
ptr
)
break
;
}
if
(
!
(
list
=
Xmalloc
(
sizeof
(
char
*
)
*
(
*
num
+
1
))))
{
if
(
!
(
list
=
Xmalloc
array
((
*
num
+
1
),
sizeof
(
char
*
))))
{
Xfree
(
psave
);
return
(
char
**
)
NULL
;
}
...
...
@@ -133,7 +134,7 @@ copy_string_list(
if
(
string_list
==
NULL
||
list_count
<=
0
)
return
(
char
**
)
NULL
;
string_list_ret
=
Xmalloc
(
sizeof
(
char
*
)
*
list_count
);
string_list_ret
=
Xmalloc
array
(
list_count
,
sizeof
(
char
*
)
);
if
(
string_list_ret
==
NULL
)
return
(
char
**
)
NULL
;
...
...
src/Font.c
View file @
6d1dc1f6
...
...
@@ -31,6 +31,7 @@ authorization from the X Consortium and the XFree86 Project.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <limits.h>
#if defined(XF86BIGFONT)
...
...
@@ -245,8 +246,8 @@ _XQueryFont (
/* nFontProps is a CARD16 */
nbytes
=
reply
.
nFontProps
*
SIZEOF
(
xFontProp
);
if
((
nbytes
>>
2
)
<=
reply_left
)
{
size_t
pbytes
=
reply
.
nFontProps
*
sizeof
(
XFontProp
);
fs
->
properties
=
Xmalloc
(
pbytes
);
fs
->
properties
=
Xmallocarray
(
reply
.
nFontProps
,
sizeof
(
XFontProp
)
);
}
if
(
!
fs
->
properties
)
{
Xfree
(
fs
);
...
...
@@ -266,8 +267,8 @@ _XQueryFont (
if
(
reply
.
nCharInfos
<
(
INT_MAX
/
sizeof
(
XCharStruct
)))
{
nbytes
=
reply
.
nCharInfos
*
SIZEOF
(
xCharInfo
);
if
((
nbytes
>>
2
)
<=
reply_left
)
{
size_t
cibytes
=
reply
.
nCharInfos
*
sizeof
(
XCharStruct
);
fs
->
per_char
=
Xmalloc
(
cibytes
);
fs
->
per_char
=
Xmallocarray
(
reply
.
nCharInfos
,
sizeof
(
XCharStruct
)
);
}
}
if
(
!
fs
->
per_char
)
{
...
...
@@ -489,8 +490,8 @@ _XF86BigfontQueryFont (
/* nFontProps is a CARD16 */
nbytes
=
reply
.
nFontProps
*
SIZEOF
(
xFontProp
);
if
((
nbytes
>>
2
)
<=
reply_left
)
{
size_t
pbytes
=
reply
.
nFontProps
*
sizeof
(
XFontProp
);
fs
->
properties
=
Xmalloc
(
pbytes
);
fs
->
properties
=
Xmallocarray
(
reply
.
nFontProps
,
sizeof
(
XFontProp
)
);
}
if
(
!
fs
->
properties
)
{
Xfree
(
fs
);
...
...
@@ -529,7 +530,8 @@ _XF86BigfontQueryFont (
_XEatDataWords
(
dpy
,
reply_left
);
return
(
XFontStruct
*
)
NULL
;
}
if
(
!
(
fs
->
per_char
=
Xmalloc
(
reply
.
nCharInfos
*
sizeof
(
XCharStruct
))))
{
if
(
!
(
fs
->
per_char
=
Xmallocarray
(
reply
.
nCharInfos
,
sizeof
(
XCharStruct
))))
{
Xfree
(
pUniqCI
);
Xfree
(
fs
->
properties
);
Xfree
(
fs
);
...
...
src/FontInfo.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <limits.h>
#if defined(XF86BIGFONT)
...
...
@@ -91,22 +92,22 @@ XFontStruct **info) /* RETURN */
XFontStruct
*
tmp_finfo
;
char
**
tmp_flist
;
tmp_finfo
=
Xrealloc
(
finfo
,
sizeof
(
XFontStruct
)
*
size
);
tmp_finfo
=
Xrealloc
array
(
finfo
,
size
,
sizeof
(
XFontStruct
)
);
if
(
tmp_finfo
)
finfo
=
tmp_finfo
;
else
goto
badmem
;
tmp_flist
=
Xrealloc
(
flist
,
sizeof
(
char
*
)
*
(
size
+
1
));
tmp_flist
=
Xrealloc
array
(
flist
,
size
+
1
,
sizeof
(
char
*
));
if
(
tmp_flist
)
flist
=
tmp_flist
;
else
goto
badmem
;
}
else
{
if
(
!
(
finfo
=
Xmalloc
(
sizeof
(
XFontStruct
)
*
size
)))
if
(
!
(
finfo
=
Xmalloc
array
(
size
,
sizeof
(
XFontStruct
)
)))
goto
clearwire
;
if
(
!
(
flist
=
Xmalloc
(
sizeof
(
char
*
)
*
(
size
+
1
))))
{
if
(
!
(
flist
=
Xmalloc
array
(
size
+
1
,
sizeof
(
char
*
))))
{
Xfree
(
finfo
);
goto
clearwire
;
}
...
...
@@ -137,8 +138,8 @@ XFontStruct **info) /* RETURN */
/* nFontProps is a CARD16 */
nbytes
=
reply
.
nFontProps
*
SIZEOF
(
xFontProp
);
if
((
nbytes
>>
2
)
<=
reply_left
)
{
size_t
pbytes
=
reply
.
nFontProps
*
sizeof
(
XFontProp
);
fs
->
properties
=
Xmalloc
(
pbytes
);
fs
->
properties
=
Xmallocarray
(
reply
.
nFontProps
,
sizeof
(
XFontProp
)
);
}
if
(
!
fs
->
properties
)
goto
badmem
;
...
...
src/FontNames.c
View file @
6d1dc1f6
...
...
@@ -29,6 +29,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <limits.h>
char
**
...
...
@@ -66,7 +67,7 @@ int *actualCount) /* RETURN */
}
if
(
rep
.
nFonts
)
{
flist
=
Xmalloc
(
rep
.
nFonts
*
sizeof
(
char
*
));
flist
=
Xmalloc
array
(
rep
.
nFonts
,
sizeof
(
char
*
));
if
(
rep
.
length
>
0
&&
rep
.
length
<
(
INT_MAX
>>
2
))
{
rlen
=
rep
.
length
<<
2
;
ch
=
Xmalloc
(
rlen
+
1
);
...
...
src/GetFPath.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <limits.h>
char
**
XGetFontPath
(
...
...
@@ -49,7 +50,7 @@ char **XGetFontPath(
(
void
)
_XReply
(
dpy
,
(
xReply
*
)
&
rep
,
0
,
xFalse
);
if
(
rep
.
nPaths
)
{
flist
=
Xmalloc
(
rep
.
nPaths
*
sizeof
(
char
*
));
flist
=
Xmalloc
array
(
rep
.
nPaths
,
sizeof
(
char
*
));
if
(
rep
.
length
<
(
INT_MAX
>>
2
))
{
nbytes
=
(
unsigned
long
)
rep
.
length
<<
2
;
ch
=
Xmalloc
(
nbytes
+
1
);
...
...
src/GetMoEv.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <limits.h>
XTimeCoord
*
XGetMotionEvents
(
...
...
@@ -53,7 +54,7 @@ XTimeCoord *XGetMotionEvents(
}
if
(
rep
.
nEvents
&&
(
rep
.
nEvents
<
(
INT_MAX
/
sizeof
(
XTimeCoord
))))
tc
=
Xmalloc
(
rep
.
nEvents
*
sizeof
(
XTimeCoord
));
tc
=
Xmalloc
array
(
rep
.
nEvents
,
sizeof
(
XTimeCoord
));
if
(
tc
==
NULL
)
{
/* server returned either no events or a bad event count */
*
nEvents
=
0
;
...
...
src/GetPntMap.c
View file @
6d1dc1f6
...
...
@@ -29,6 +29,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <limits.h>
#ifdef MIN
/* some systems define this in <sys/param.h> */
...
...
@@ -112,8 +113,7 @@ XGetKeyboardMapping (Display *dpy,
nkeysyms
=
rep
.
length
;
if
(
nkeysyms
>
0
)
{
if
(
nkeysyms
<
(
INT_MAX
/
sizeof
(
KeySym
)))
{
nbytes
=
nkeysyms
*
sizeof
(
KeySym
);
mapping
=
Xmalloc
(
nbytes
);
mapping
=
Xmallocarray
(
nkeysyms
,
sizeof
(
KeySym
));
}
if
(
!
mapping
)
{
_XEatDataWords
(
dpy
,
rep
.
length
);
...
...
src/GetRGBCMap.c
View file @
6d1dc1f6
...
...
@@ -33,6 +33,7 @@ from The Open Group.
#include <X11/Xlibint.h>
#include <X11/Xutil.h>
#include "Xatomtype.h"
#include "reallocarray.h"
#include <X11/Xatom.h>
Status
XGetRGBColormaps
(
...
...
@@ -99,7 +100,7 @@ Status XGetRGBColormaps (
/*
* allocate array
*/
cmaps
=
Xmalloc
(
ncmaps
*
sizeof
(
XStandardColormap
));
cmaps
=
Xmalloc
array
(
ncmaps
,
sizeof
(
XStandardColormap
));
if
(
!
cmaps
)
{
Xfree
(
data
);
return
False
;
...
...
src/LiICmaps.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
Colormap
*
XListInstalledColormaps
(
register
Display
*
dpy
,
...
...
@@ -50,8 +51,7 @@ Colormap *XListInstalledColormaps(
}
if
(
rep
.
nColormaps
)
{
nbytes
=
rep
.
nColormaps
*
sizeof
(
Colormap
);
cmaps
=
Xmalloc
(
nbytes
);
cmaps
=
Xmallocarray
(
rep
.
nColormaps
,
sizeof
(
Colormap
));
if
(
!
cmaps
)
{
_XEatDataWords
(
dpy
,
rep
.
length
);
UnlockDisplay
(
dpy
);
...
...
src/LiProps.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
Atom
*
XListProperties
(
register
Display
*
dpy
,
...
...
@@ -49,8 +50,7 @@ Atom *XListProperties(
}
if
(
rep
.
nProperties
)
{
nbytes
=
rep
.
nProperties
*
sizeof
(
Atom
);
properties
=
Xmalloc
(
nbytes
);
properties
=
Xmallocarray
(
rep
.
nProperties
,
sizeof
(
Atom
));
if
(
!
properties
)
{
_XEatDataWords
(
dpy
,
rep
.
length
);
UnlockDisplay
(
dpy
);
...
...
src/ListExt.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <limits.h>
char
**
XListExtensions
(
...
...
@@ -54,7 +55,7 @@ char **XListExtensions(
}
if
(
rep
.
nExtensions
)
{
list
=
Xmalloc
(
rep
.
nExtensions
*
sizeof
(
char
*
));
list
=
Xmalloc
array
(
rep
.
nExtensions
,
sizeof
(
char
*
));
if
(
rep
.
length
>
0
&&
rep
.
length
<
(
INT_MAX
>>
2
))
{
rlen
=
rep
.
length
<<
2
;
ch
=
Xmalloc
(
rlen
+
1
);
...
...
src/ModMap.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <limits.h>
XModifierKeymap
*
...
...
@@ -100,7 +101,7 @@ XNewModifiermap(int keyspermodifier)
if
(
res
)
{
res
->
max_keypermod
=
keyspermodifier
;
res
->
modifiermap
=
(
keyspermodifier
>
0
?
Xmalloc
(
8
*
keyspermodifier
)
Xmalloc
array
(
keyspermodifier
,
8
)
:
(
KeyCode
*
)
NULL
);
if
(
keyspermodifier
&&
(
res
->
modifiermap
==
NULL
))
{
Xfree
(
res
);
...
...
src/PixFormats.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
#include <stdio.h>
/*
...
...
@@ -39,7 +40,7 @@ XPixmapFormatValues *XListPixmapFormats (
int
*
count
)
/* RETURN */
{
XPixmapFormatValues
*
formats
=
Xmalloc
(
dpy
->
nformats
*
sizeof
(
XPixmapFormatValues
));
Xmalloc
array
(
dpy
->
nformats
,
sizeof
(
XPixmapFormatValues
));
if
(
formats
)
{
register
int
i
;
...
...
src/PolyReg.c
View file @
6d1dc1f6
...
...
@@ -55,6 +55,7 @@ SOFTWARE.
#include "Xutil.h"
#include <X11/Xregion.h>
#include "poly.h"
#include "reallocarray.h"
/*
* InsertEdgeInET
...
...
@@ -409,7 +410,7 @@ static int PtsToRegion(
numRects
=
((
numFullPtBlocks
*
NUMPTSTOBUFFER
)
+
iCurPtBlock
)
>>
1
;
if
(
!
(
reg
->
rects
=
Xrealloc
(
reg
->
rects
,
sizeof
(
BOX
)
*
numRects
)))
{
if
(
!
(
reg
->
rects
=
Xrealloc
array
(
reg
->
rects
,
numRects
,
sizeof
(
BOX
)
)))
{
Xfree
(
prevRects
);
return
(
0
);
}
...
...
@@ -519,7 +520,7 @@ XPolygonRegion(
if
(
Count
<
2
)
return
region
;
if
(
!
(
pETEs
=
Xmalloc
(
sizeof
(
EdgeTableEntry
)
*
Count
)))
{
if
(
!
(
pETEs
=
Xmalloc
array
(
Count
,
sizeof
(
EdgeTableEntry
)
)))
{
XDestroyRegion
(
region
);
return
(
Region
)
NULL
;
}
...
...
src/PutImage.c
View file @
6d1dc1f6
...
...
@@ -32,6 +32,7 @@ in this Software without prior written authorization from The Open Group.
#include <stdio.h>
#include "Cr.h"
#include "ImUtil.h"
#include "reallocarray.h"
#if defined(__STDC__) && ((defined(sun) && defined(SVR4)) || defined(WIN32))
#define RConst
/**/
...
...
@@ -771,7 +772,7 @@ SendZImage(
(
req_yoffset
*
image
->
bytes_per_line
)
+
((
req_xoffset
*
image
->
bits_per_pixel
)
>>
3
);
if
((
image
->
bits_per_pixel
==
4
)
&&
((
unsigned
int
)
req_xoffset
&
0x01
))
{
if
(
!
(
shifted_src
=
Xmalloc
(
req
->
height
*
image
->
bytes_per_line
)))
{
if
(
!
(
shifted_src
=
Xmalloc
array
(
req
->
height
,
image
->
bytes_per_line
)))
{
UnGetReq
(
PutImage
);
return
;
}
...
...
@@ -991,7 +992,7 @@ XPutImage (
img
.
bits_per_pixel
=
dest_bits_per_pixel
;
img
.
bytes_per_line
=
ROUNDUP
((
dest_bits_per_pixel
*
width
),
dest_scanline_pad
)
>>
3
;
img
.
data
=
Xmalloc
(
img
.
bytes_per_line
*
height
);
img
.
data
=
Xmalloc
array
(
height
,
img
.
bytes_per_line
);
if
(
img
.
data
==
NULL
)
return
0
;
_XInitImageFuncPtrs
(
&
img
);
...
...
src/QuColors.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
static
void
_XQueryColors
(
...
...
@@ -50,9 +51,9 @@ _XQueryColors(
/* XXX this isn't very efficient */
if
(
_XReply
(
dpy
,
(
xReply
*
)
&
rep
,
0
,
xFalse
)
!=
0
)
{
unsigned
long
nbytes
=
(
long
)
ncolors
*
SIZEOF
(
xrgb
);
xrgb
*
color
=
Xmalloc
(
nbytes
);
xrgb
*
color
=
Xmallocarray
(
ncolors
,
sizeof
(
xrgb
));
if
(
color
!=
NULL
)
{
unsigned
long
nbytes
=
(
long
)
ncolors
*
SIZEOF
(
xrgb
);
_XRead
(
dpy
,
(
char
*
)
color
,
nbytes
);
...
...
src/QuTree.c
View file @
6d1dc1f6
...
...
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
#include "reallocarray.h"
Status
XQueryTree
(
register
Display
*
dpy
,
...
...
@@ -51,8 +52,7 @@ Status XQueryTree (
*
children
=
(
Window
*
)
NULL
;
if
(
rep
.
nChildren
!=
0
)
{
nbytes
=
rep
.
nChildren
*
sizeof
(
Window
);
*
children
=
Xmalloc
(
nbytes
);
*
children
=
Xmallocarray
(
rep
.
nChildren
,
sizeof
(
Window
));
if
(
!
*
children
)
{
_XEatDataWords
(
dpy
,
rep
.
length
);
UnlockDisplay
(
dpy
);
...
...
src/Quarks.c
View file @
6d1dc1f6
...
...
@@ -55,6 +55,7 @@ from The Open Group.
#include "Xlibint.h"
#include <X11/Xresource.h>
#include "Xresinternal.h"
#include "reallocarray.h"
/* Not cost effective, at least for vanilla MIT clients */
/* #define PERMQ */
...
...
@@ -288,15 +289,15 @@ nomatch: if (!rehash)
q
=
nextQuark
;
if
(
!
(
q
&
QUANTUMMASK
))
{
if
(
!
(
q
&
CHUNKMASK
))
{
if
(
!
(
new
=
Xrealloc
(
stringTable
,
sizeof
(
XrmString
*
)
*
((
q
>>
QUANTUMSHIFT
)
+
CHUNKPER
))))
if
(
!
(
new
=
Xrealloc
array
(
stringTable
,
(
q
>>
QUANTUMSHIFT
)
+
CHUNKPER
,
sizeof
(
XrmString
*
))))
goto
fail
;
stringTable
=
(
XrmString
**
)
new
;
#ifdef PERMQ
if
(
!
(
new
=
Xrealloc
(
permTable
,
sizeof
(
Bits
*
)
*
((
q
>>
QUANTUMSHIFT
)
+
CHUNKPER
))))
if
(
!
(
new
=
Xrealloc
array
(
permTable
,
(
q
>>
QUANTUMSHIFT
)
+
CHUNKPER
,
sizeof
(
Bits
*
))))
goto
fail
;
permTable
=
(
Bits
**
)
new
;
#endif
...
...
src/RdBitF.c
View file @
6d1dc1f6
...
...
@@ -49,7 +49,7 @@ from The Open Group.
#include "Xutil.h"
#include <stdio.h>
#include <ctype.h>
#include "reallocarray.h"
#define MAX_SIZE 255
...
...
@@ -190,10 +190,10 @@ XReadBitmapFileData (
bytes_per_line
=
(
ww
+
7
)
/
8
+
padding
;
size
=
bytes_per_line
*
hh
;
bits
=
Xmalloc
(
size
);
bits
=
Xmallocarray
(
hh
,
bytes_per_line
);
if
(
!
bits
)
RETURN
(
BitmapNoMemory
);
size
=
bytes_per_line
*
hh
;
if
(
version10p
)
{
unsigned
char
*
ptr
;
...
...
src/Region.c
View file @
6d1dc1f6
...
...
@@ -77,6 +77,7 @@ SOFTWARE.
#include "Xutil.h"
#include <X11/Xregion.h>
#include "poly.h"
#include "reallocarray.h"
#ifdef DEBUG
#include <stdio.h>
...
...
@@ -521,8 +522,8 @@ miRegionCopy(
{
BOX
*
prevRects
=
dstrgn
->
rects
;
dstrgn
->
rects
=
Xrealloc
(
dstrgn
->
rects
,
rgn
->
numRects
*
(
sizeof
(
BOX
)
));
dstrgn
->
rects
=
Xrealloc
array
(
dstrgn
->
rects
,
rgn
->
numRects
,
sizeof
(
BOX
));
if
(
!
dstrgn
->
rects
)
{
Xfree
(
prevRects
);
dstrgn
->
size
=
0
;
...
...
@@ -790,7 +791,7 @@ miRegionOp(
*/
newReg
->
size
=
max
(
reg1
->
numRects
,
reg2
->
numRects
)
*
2
;
if
(
!
(
newReg
->
rects
=
Xmalloc
(
sizeof
(
BoxRec
)
*
newReg
->
size
)))
{
if
(
!
(
newReg
->
rects
=
Xmalloc
array
(
newReg
->
size
,
sizeof
(
BoxRec
)
)))
{
newReg
->
size
=
0
;
return
;
}
...
...
@@ -980,8 +981,8 @@ miRegionOp(
if
(
REGION_NOT_EMPTY
(
newReg
))
{
BoxPtr
prev_rects
=
newReg
->
rects
;
newReg
->
rects
=
Xrealloc
(
newReg
->
rects
,
sizeof
(
BoxRec
)
*
newReg
->
numRects
);
newReg
->
rects
=
Xrealloc
array
(
newReg
->
rects
,
newReg
->
numRects
,
sizeof
(
BoxRec
)
);
if
(
!
newReg
->
rects
)
newReg
->
rects
=
prev_rects
;
else
...
...
src/SetHints.c
View file @
6d1dc1f6
...
...
@@ -54,6 +54,7 @@ SOFTWARE.
#include "Xatomtype.h"
#include <X11/Xatom.h>
#include <X11/Xos.h>
#include "reallocarray.h"
#define safestrlen(s) ((s) ? strlen(s) : 0)
...
...
@@ -181,10 +182,8 @@ XSetIconSizes (
{
register
int
i
;
xPropIconSize
*
pp
,
*
prop
;
#define size_of_the_real_thing sizeof
/* avoid grepping screwups */
unsigned
nbytes
=
count
*
size_of_the_real_thing
(
xPropIconSize
);
#undef size_of_the_real_thing
if
((
prop
=
pp
=
Xmalloc
(
nbytes
)))
{
if
((
prop
=
pp
=
Xmallocarray
(
count
,
sizeof
(
xPropIconSize
))))
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
pp
->
minWidth
=
list
->
min_width
;
pp
->
minHeight
=
list
->
min_height
;
...
...
src/SetRGBCMap.c
View file @
6d1dc1f6
...
...
@@ -34,6 +34,7 @@ from The Open Group.
#include <X11/Xutil.h>
#include "Xatomtype.h"
#include <X11/Xatom.h>
#include "reallocarray.h"
void
XSetRGBColormaps
(
Display
*
dpy
,
...
...
@@ -55,9 +56,9 @@ void XSetRGBColormaps (
/*
* if doing more than one, allocate scratch space for it
*/
if
((
count
>
1
)
&&
((
data
=
((
xPropStandardColormap
*
)
Xmalloc
(
count
*
sizeof
(
xPropStandardColormap
))))
!=
NULL
))
{
if
((
count
>
1
)
&&
((
data
=
(
Xmallocarray
(
count
,
sizeof
(
xPropStandardColormap
))))
!=
NULL
))
{
alloced_scratch_space
=
True
;
}
else
{
data
=
&
tmpdata
;
...
...
src/TextToStr.c
View file @
6d1dc1f6
...
...
@@ -31,7 +31,7 @@ in this Software without prior written authorization from The Open Group.
#include <X11/Xlibint.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include "reallocarray.h"
/*
* XTextPropertyToStringList - set list and count to contain data stored in
...
...
@@ -72,7 +72,7 @@ Status XTextPropertyToStringList (
/*
* allocate list and duplicate
*/
list
=
Xmalloc
(
nelements
*
sizeof
(
char
*
));
list
=
Xmalloc
array
(
nelements
,
sizeof
(
char
*
));
if
(
!
list
)
return
False
;
start
=
Xmalloc
((
datalen
+
1
)
*
sizeof
(
char
));
/* for <NUL> */
...
...
src/VisUtil.c
View file @
6d1dc1f6
...
...
@@ -30,6 +30,8 @@ in this Software without prior written authorization from The Open Group.
#include "Xlibint.h"
#include "Xutil.h"
#include <stdio.h>
#include "reallocarray.h"
/*
* This procedure returns a list of visual information structures
* that match the specified attributes given in the visual information
...
...
@@ -75,7 +77,7 @@ XVisualInfo *XGetVisualInfo(
count
=
0
;
total
=
10
;
if
(
!
(
vip_base
=
vip
=
Xmalloc
(
sizeof
(
XVisualInfo
)
*
total
)))
{
if
(
!
(
vip_base
=
vip
=
Xmalloc
array
(
total
,
sizeof
(
XVisualInfo
)
)))
{
UnlockDisplay
(
dpy
);
return
(
XVisualInfo
*
)
NULL
;
}
...
...
@@ -131,8 +133,8 @@ XVisualInfo *XGetVisualInfo(
{
XVisualInfo
*
old_vip_base
=
vip_base
;
total
+=
10
;
if
(
!
(
vip_base
=
Xrealloc
(
vip_base
,
sizeof
(
XVisualInfo
)
*
total
)))
{
if
(
!
(
vip_base
=
Xrealloc
array
(
vip_base
,
total
,
sizeof
(
XVisualInfo
)
)))
{
Xfree
(
old_vip_base
);
UnlockDisplay
(
dpy
);
return
(
XVisualInfo
*
)
NULL
;
...
...
src/WrBitF.c
View file @
6d1dc1f6
...
...
@@ -33,6 +33,7 @@ from The Open Group.
#include <X11/Xos.h>
#include "Xutil.h"
#include <stdio.h>
#include "reallocarray.h"
#define ERR_RETURN NULL
...
...
@@ -53,7 +54,7 @@ static char *Format_Image(
bytes_per_line
=
(
width
+
7
)
/
8
;
*
resultsize
=
bytes_per_line
*
height
;
/* Calculate size of data */
data
=
Xmalloc
(
*
resultsize
);
/* Get space for data */
data
=
Xmalloc
array
(
bytes_per_line
,
height
);
/* Get space for data */
if
(
!
data
)
return
(
ERR_RETURN
);
...
...
src/XlibInt.c
View file @
6d1dc1f6
...
...
@@ -39,6 +39,7 @@ from The Open Group.
#endif
#include "Xlibint.h"
#include "Xprivate.h"
#include "reallocarray.h"
#include <X11/Xpoll.h>
#include <assert.h>
#include <stdio.h>
...
...
@@ -349,7 +350,7 @@ _XRegisterInternalConnection(
new_conni
=
Xmalloc
(
sizeof
(
struct
_XConnectionInfo
));
if
(
!
new_conni
)
return
0
;
new_conni
->
watch_data
=
Xmalloc
(
dpy
->
watcher_count
*
sizeof
(
XPointer
));
new_conni
->
watch_data
=
Xmalloc
array
(
dpy
->
watcher_count
,
sizeof
(
XPointer
));
if
(
!
new_conni
->
watch_data
)
{
Xfree
(
new_conni
);
return
0
;
...
...
@@ -435,7 +436,7 @@ XInternalConnectionNumbers(
count
=
0
;
for
(
info_list
=
dpy
->
im_fd_info
;
info_list
;
info_list
=
info_list
->
next
)
count
++
;
fd_list
=
Xmalloc
(
count
*
sizeof
(
int
));
fd_list
=
Xmalloc
array
(
count
,
sizeof
(
int
));
if
(
!
fd_list
)
{
UnlockDisplay
(
dpy
);
return
0
;
...
...
@@ -508,8 +509,8 @@ XAddConnectionWatch(
/* allocate new watch data */
for
(
info_list
=
dpy
->
im_fd_info
;
info_list
;
info_list
=
info_list
->
next
)
{
wd_array
=
Xrealloc
(
info_list
->
watch_data
,
(
dpy
->
watcher_count
+
1
)
*
sizeof
(
XPointer
));
wd_array
=
Xrealloc
array
(
info_list
->
watch_data
,
dpy
->
watcher_count
+
1
,
sizeof
(
XPointer
));
if
(
!
wd_array
)
{
UnlockDisplay
(
dpy
);
return
0
;
...
...
Write
Preview