diff options
author | Matt Turner <mattst88@gmail.com> | 2012-09-04 23:09:22 -0700 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2012-09-05 22:28:50 -0700 |
commit | 6bda027e01c15df24d36de5bf3838ea8ed7e9e56 (patch) | |
tree | bb41d06abd676913add0761732908c064b68663a /src/glx | |
parent | 5067506ea6ada5eeae33b1acf1c916e00121c12a (diff) |
Use calloc instead of malloc/memset-0
This patch has been generated by the following Coccinelle semantic
patch:
@@
expression E;
identifier I;
@@
- I = malloc(E);
+ I = calloc(1, E);
...
- memset(I, 0, sizeof *I);
Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'src/glx')
-rw-r--r-- | src/glx/applegl_glx.c | 3 | ||||
-rw-r--r-- | src/glx/dri2_glx.c | 12 | ||||
-rw-r--r-- | src/glx/dri_glx.c | 6 | ||||
-rw-r--r-- | src/glx/drisw_glx.c | 9 | ||||
-rw-r--r-- | src/glx/indirect_glx.c | 6 |
5 files changed, 12 insertions, 24 deletions
diff --git a/src/glx/applegl_glx.c b/src/glx/applegl_glx.c index c3597cee765..a67416ec3f4 100644 --- a/src/glx/applegl_glx.c +++ b/src/glx/applegl_glx.c @@ -173,11 +173,10 @@ applegl_create_screen(int screen, struct glx_display * priv) { struct glx_screen *psc; - psc = malloc(sizeof *psc); + psc = calloc(1, sizeof *psc); if (psc == NULL) return NULL; - memset(psc, 0, sizeof *psc); glx_screen_init(psc, screen, priv); psc->vtable = &applegl_screen_vtable; diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index 5644f665c4c..f2fc1873298 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -198,11 +198,10 @@ dri2_create_context(struct glx_screen *base, shared = pcp_shared->driContext; } - pcp = malloc(sizeof *pcp); + pcp = calloc(1, sizeof *pcp); if (pcp == NULL) return NULL; - memset(pcp, 0, sizeof *pcp); if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { free(pcp); return NULL; @@ -261,13 +260,12 @@ dri2_create_context_attribs(struct glx_screen *base, shared = pcp_shared->driContext; } - pcp = malloc(sizeof *pcp); + pcp = calloc(1, sizeof *pcp); if (pcp == NULL) { *error = __DRI_CTX_ERROR_NO_MEMORY; goto error_exit; } - memset(pcp, 0, sizeof *pcp); if (!glx_context_init(&pcp->base, &psc->base, &config->base)) goto error_exit; @@ -352,11 +350,10 @@ dri2CreateDrawable(struct glx_screen *base, XID xDrawable, struct dri2_display *pdp; GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1; - pdraw = malloc(sizeof(*pdraw)); + pdraw = calloc(1, sizeof(*pdraw)); if (!pdraw) return NULL; - memset(pdraw, 0, sizeof *pdraw); pdraw->base.destroyDrawable = dri2DestroyDrawable; pdraw->base.xDrawable = xDrawable; pdraw->base.drawable = drawable; @@ -1018,11 +1015,10 @@ dri2CreateScreen(int screen, struct glx_display * priv) drm_magic_t magic; int i; - psc = malloc(sizeof *psc); + psc = calloc(1, sizeof *psc); if (psc == NULL) return NULL; - memset(psc, 0, sizeof *psc); psc->fd = -1; if (!glx_screen_init(&psc->base, screen, priv)) { diff --git a/src/glx/dri_glx.c b/src/glx/dri_glx.c index a158de023ba..3a727e52904 100644 --- a/src/glx/dri_glx.c +++ b/src/glx/dri_glx.c @@ -593,11 +593,10 @@ dri_create_context(struct glx_screen *base, shared = pcp_shared->driContext; } - pcp = malloc(sizeof *pcp); + pcp = calloc(1, sizeof *pcp); if (pcp == NULL) return NULL; - memset(pcp, 0, sizeof *pcp); if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { free(pcp); return NULL; @@ -651,11 +650,10 @@ driCreateDrawable(struct glx_screen *base, if (xDrawable != drawable) return NULL; - pdp = malloc(sizeof *pdp); + pdp = calloc(1, sizeof *pdp); if (!pdp) return NULL; - memset(pdp, 0, sizeof *pdp); pdp->base.drawable = drawable; pdp->base.psc = &psc->base; diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index b68e62272c7..920a9ab7b99 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -392,11 +392,10 @@ drisw_create_context(struct glx_screen *base, shared = pcp_shared->driContext; } - pcp = malloc(sizeof *pcp); + pcp = calloc(1, sizeof *pcp); if (pcp == NULL) return NULL; - memset(pcp, 0, sizeof *pcp); if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { free(pcp); return NULL; @@ -457,11 +456,10 @@ drisw_create_context_attribs(struct glx_screen *base, shared = pcp_shared->driContext; } - pcp = malloc(sizeof *pcp); + pcp = calloc(1, sizeof *pcp); if (pcp == NULL) return NULL; - memset(pcp, 0, sizeof *pcp); if (!glx_context_init(&pcp->base, &psc->base, &config->base)) { free(pcp); return NULL; @@ -522,11 +520,10 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable, Bool ret; const __DRIswrastExtension *swrast = psc->swrast; - pdp = malloc(sizeof(*pdp)); + pdp = calloc(1, sizeof(*pdp)); if (!pdp) return NULL; - memset(pdp, 0, sizeof *pdp); pdp->base.xDrawable = xDrawable; pdp->base.drawable = drawable; pdp->base.psc = &psc->base; diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c index 5eef59c1d5a..f3cc1e7d049 100644 --- a/src/glx/indirect_glx.c +++ b/src/glx/indirect_glx.c @@ -352,12 +352,11 @@ indirect_create_context(struct glx_screen *psc, } /* Allocate our context record */ - gc = malloc(sizeof *gc); + gc = calloc(1, sizeof *gc); if (!gc) { /* Out of memory */ return NULL; } - memset(gc, 0, sizeof *gc); glx_context_init(gc, psc, mode); gc->isDirect = GL_FALSE; @@ -464,11 +463,10 @@ indirect_create_screen(int screen, struct glx_display * priv) { struct glx_screen *psc; - psc = malloc(sizeof *psc); + psc = calloc(1, sizeof *psc); if (psc == NULL) return NULL; - memset(psc, 0, sizeof *psc); glx_screen_init(psc, screen, priv); psc->vtable = &indirect_screen_vtable; |