[PATCH:libXxf86vm] When Xcalloc() returns NULL, you don't need to Xfree() it
walter harms
wharms at bfs.de
Sun Apr 14 04:25:34 PDT 2013
Am 14.04.2013 00:20, schrieb Alan Coopersmith:
> I have no words to explain how this ever happened.
>
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
> ---
> src/XF86VMode.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/src/XF86VMode.c b/src/XF86VMode.c
> index 4f19cf3..c0e50e6 100644
> --- a/src/XF86VMode.c
> +++ b/src/XF86VMode.c
> @@ -256,7 +256,6 @@ XF86VidModeGetModeLine(Display* dpy, int screen, int* dotclock,
> if (modeline->privsize > 0) {
> if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) {
> _XEatData(dpy, (modeline->privsize) * sizeof(INT32));
> - Xfree(modeline->private);
> return False;
> }
you can improve readability by splitting the if()
modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)) ;
if (!modeline->private)
{
_XEatData(dpy, (modeline->privsize) * sizeof(INT32));
return False;
}
btw: is the use of Xcalloc really needed ?
> _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
> @@ -321,7 +320,6 @@ XF86VidModeGetAllModeLines(Display* dpy, int screen, int* modecount,
> _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo));
> else
> _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo));
> - Xfree(modelines);
> return False;
> }
> mdinfptr = (XF86VidModeModeInfo *) (
> @@ -353,7 +351,6 @@ XF86VidModeGetAllModeLines(Display* dpy, int screen, int* modecount,
> if (!(modelines[i]->private =
> Xcalloc(oldxmdline.privsize, sizeof(INT32)))) {
> _XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32));
> - Xfree(modelines[i]->private);
> } else {
> _XRead(dpy, (char*)modelines[i]->private,
> oldxmdline.privsize * sizeof(INT32));
> @@ -384,7 +381,6 @@ XF86VidModeGetAllModeLines(Display* dpy, int screen, int* modecount,
> if (!(modelines[i]->private =
> Xcalloc(xmdline.privsize, sizeof(INT32)))) {
> _XEatData(dpy, (xmdline.privsize) * sizeof(INT32));
> - Xfree(modelines[i]->private);
> } else {
> _XRead(dpy, (char*)modelines[i]->private,
> xmdline.privsize * sizeof(INT32));
> @@ -1039,7 +1035,6 @@ XF86VidModeGetDotClocks(Display* dpy, int screen, int *flagsPtr,
>
> if (!(dotclocks = (int*) Xcalloc(rep.clocks, sizeof(int)))) {
> _XEatData(dpy, (rep.clocks) * 4);
> - Xfree(dotclocks);
> return False;
> }
>
More information about the xorg-devel
mailing list