diff options
author | Daniel Stone <daniel@fooishbar.org> | 2005-09-05 07:40:50 +0000 |
---|---|---|
committer | Daniel Stone <daniel@fooishbar.org> | 2005-09-05 07:40:50 +0000 |
commit | 5c5c51fa6da03f19831632a092761a1e4bcf653b (patch) | |
tree | fbbff9ebaeab589115da61eb8e66b0397faa98d2 /dix | |
parent | 691669c0121494df90c8523f7d17e01ba0b14a57 (diff) |
Initialise private arrays with calloc, rather than standard malloc.
(Benjamin Herrenschmidt)
Diffstat (limited to 'dix')
-rw-r--r-- | dix/colormap.c | 5 | ||||
-rw-r--r-- | dix/privates.c | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/dix/colormap.c b/dix/colormap.c index c21623cd1..47c6c51e3 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -398,9 +398,8 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->devPrivates = NULL; else { - pmap->devPrivates = (DevUnion *) xalloc ( - colormapPrivateCount * sizeof(DevUnion)); - + pmap->devPrivates = (DevUnion *) xcalloc ( + sizeof(DevUnion), colormapPrivateCount); if (!pmap->devPrivates) { FreeResource (mid, RT_NONE); diff --git a/dix/privates.c b/dix/privates.c index 933810517..1e04a7b22 100644 --- a/dix/privates.c +++ b/dix/privates.c @@ -347,10 +347,13 @@ AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc) { privs = (DevUnion *) xrealloc (pColormap->devPrivates, colormapPrivateCount * sizeof(DevUnion)); - + if (!privs) { + colormapPrivateCount--; + return -1; + } + bzero(&privs[index], sizeof(DevUnion)); pColormap->devPrivates = privs; - - if (!privs || !(*initPrivFunc)(pColormap,index)) + if (!(*initPrivFunc)(pColormap,index)) { colormapPrivateCount--; return -1; |