diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-03-21 15:05:30 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2015-04-21 16:58:08 -0700 |
commit | f59236c2865d22c6f0b2d1ba303213afd10cd02e (patch) | |
tree | 86865f9806a3754895861910a8a27c1d93bb5653 | |
parent | 7ac280287491fe06127d9fefc504217e21c780e6 (diff) |
Convert glamor & glx to new *allocarray functions
v2: fixup whitespace
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
-rw-r--r-- | glamor/glamor_compositerects.c | 2 | ||||
-rw-r--r-- | glamor/glamor_glyphs.c | 2 | ||||
-rw-r--r-- | glamor/glamor_gradient.c | 8 | ||||
-rw-r--r-- | glamor/glamor_pixmap.c | 4 | ||||
-rw-r--r-- | glamor/glamor_prepare.c | 4 | ||||
-rw-r--r-- | glamor/glamor_utils.c | 2 | ||||
-rw-r--r-- | glx/single2.c | 9 | ||||
-rw-r--r-- | glx/single2swap.c | 9 |
8 files changed, 19 insertions, 21 deletions
diff --git a/glamor/glamor_compositerects.c b/glamor/glamor_compositerects.c index e188d8a3f..885a6c065 100644 --- a/glamor/glamor_compositerects.c +++ b/glamor/glamor_compositerects.c @@ -57,7 +57,7 @@ _pixman_region_init_clipped_rectangles(pixman_region16_t * region, unsigned int i, j; if (num_rects > ARRAY_SIZE(stack_boxes)) { - boxes = malloc(sizeof(pixman_box16_t) * num_rects); + boxes = xallocarray(num_rects, sizeof(pixman_box16_t)); if (boxes == NULL) return FALSE; } diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c index 2cf0c7d16..4f3f9696d 100644 --- a/glamor/glamor_glyphs.c +++ b/glamor/glamor_glyphs.c @@ -634,7 +634,7 @@ glyph_new_fixed_list(struct glamor_glyph_list *fixed_list, } DEBUGF("got %d lists\n", list_cnt); if (list_cnt != 0) { - fixed_list->list = malloc(list_cnt * sizeof(*cur_list)); + fixed_list->list = xallocarray(list_cnt, sizeof(*cur_list)); memcpy(fixed_list->list, *head_list, list_cnt * sizeof(*cur_list)); fixed_list->list[0].xOff = *head_x; fixed_list->list[0].yOff = *head_y; diff --git a/glamor/glamor_gradient.c b/glamor/glamor_gradient.c index 8ea645efc..d34131d35 100644 --- a/glamor/glamor_gradient.c +++ b/glamor/glamor_gradient.c @@ -997,13 +997,13 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen, /* Set all the stops and colors to shader. */ if (stops_count > RADIAL_SMALL_STOPS) { - stop_colors = malloc(4 * stops_count * sizeof(float)); + stop_colors = xallocarray(stops_count, 4 * sizeof(float)); if (stop_colors == NULL) { ErrorF("Failed to allocate stop_colors memory.\n"); goto GRADIENT_FAIL; } - n_stops = malloc(stops_count * sizeof(float)); + n_stops = xallocarray(stops_count, sizeof(float)); if (n_stops == NULL) { ErrorF("Failed to allocate n_stops memory.\n"); goto GRADIENT_FAIL; @@ -1338,13 +1338,13 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen, /* Set all the stops and colors to shader. */ if (stops_count > LINEAR_SMALL_STOPS) { - stop_colors = malloc(4 * stops_count * sizeof(float)); + stop_colors = xallocarray(stops_count, 4 * sizeof(float)); if (stop_colors == NULL) { ErrorF("Failed to allocate stop_colors memory.\n"); goto GRADIENT_FAIL; } - n_stops = malloc(stops_count * sizeof(float)); + n_stops = xallocarray(stops_count, sizeof(float)); if (n_stops == NULL) { ErrorF("Failed to allocate n_stops memory.\n"); goto GRADIENT_FAIL; diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c index 89b4c366b..623574716 100644 --- a/glamor/glamor_pixmap.c +++ b/glamor/glamor_pixmap.c @@ -775,7 +775,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, if (pixmap->drawable.depth == 1) stride = (((w * 8 + 7) / 8) + 3) & ~3; - converted_bits = malloc(h * stride); + converted_bits = xallocarray(h, stride); if (converted_bits == NULL) return FALSE; @@ -966,7 +966,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, void *sub_bits; int i, j; - sub_bits = malloc(h * stride); + sub_bits = xallocarray(h, stride); if (sub_bits == NULL) return FALSE; box.x1 = x; diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c index 83ba7f16f..9bfc557e1 100644 --- a/glamor/glamor_prepare.c +++ b/glamor/glamor_prepare.c @@ -91,8 +91,8 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box) pixmap->devKind * pixmap->drawable.height, NULL, gl_usage); } else { - pixmap->devPrivate.ptr = malloc(pixmap->devKind * - pixmap->drawable.height); + pixmap->devPrivate.ptr = xallocarray(pixmap->devKind, + pixmap->drawable.height); if (!pixmap->devPrivate.ptr) return FALSE; } diff --git a/glamor/glamor_utils.c b/glamor/glamor_utils.c index f06896096..d3e6fd3ff 100644 --- a/glamor/glamor_utils.c +++ b/glamor/glamor_utils.c @@ -31,7 +31,7 @@ glamor_solid_boxes(PixmapPtr pixmap, xRectangle *rect; int n; - rect = malloc(nbox * sizeof (xRectangle)); + rect = xallocarray(nbox, sizeof(xRectangle)); if (!rect) return; for (n = 0; n < nbox; n++) { diff --git a/glx/single2.c b/glx/single2.c index a6ea614fd..acc66ac07 100644 --- a/glx/single2.c +++ b/glx/single2.c @@ -62,9 +62,8 @@ __glXDisp_FeedbackBuffer(__GLXclientState * cl, GLbyte * pc) size = *(GLsizei *) (pc + 0); type = *(GLenum *) (pc + 4); if (cx->feedbackBufSize < size) { - cx->feedbackBuf = (GLfloat *) realloc(cx->feedbackBuf, - (size_t) size - * __GLX_SIZE_FLOAT32); + cx->feedbackBuf = reallocarray(cx->feedbackBuf, + (size_t) size, __GLX_SIZE_FLOAT32); if (!cx->feedbackBuf) { cl->client->errorValue = size; return BadAlloc; @@ -94,8 +93,8 @@ __glXDisp_SelectBuffer(__GLXclientState * cl, GLbyte * pc) pc += __GLX_SINGLE_HDR_SIZE; size = *(GLsizei *) (pc + 0); if (cx->selectBufSize < size) { - cx->selectBuf = (GLuint *) realloc(cx->selectBuf, - (size_t) size * __GLX_SIZE_CARD32); + cx->selectBuf = reallocarray(cx->selectBuf, + (size_t) size, __GLX_SIZE_CARD32); if (!cx->selectBuf) { cl->client->errorValue = size; return BadAlloc; diff --git a/glx/single2swap.c b/glx/single2swap.c index 53490694b..d5bb1c03c 100644 --- a/glx/single2swap.c +++ b/glx/single2swap.c @@ -63,9 +63,8 @@ __glXDispSwap_FeedbackBuffer(__GLXclientState * cl, GLbyte * pc) size = *(GLsizei *) (pc + 0); type = *(GLenum *) (pc + 4); if (cx->feedbackBufSize < size) { - cx->feedbackBuf = (GLfloat *) realloc(cx->feedbackBuf, - (size_t) size - * __GLX_SIZE_FLOAT32); + cx->feedbackBuf = reallocarray(cx->feedbackBuf, + (size_t) size, __GLX_SIZE_FLOAT32); if (!cx->feedbackBuf) { cl->client->errorValue = size; return BadAlloc; @@ -99,8 +98,8 @@ __glXDispSwap_SelectBuffer(__GLXclientState * cl, GLbyte * pc) __GLX_SWAP_INT(pc + 0); size = *(GLsizei *) (pc + 0); if (cx->selectBufSize < size) { - cx->selectBuf = (GLuint *) realloc(cx->selectBuf, - (size_t) size * __GLX_SIZE_CARD32); + cx->selectBuf = reallocarray(cx->selectBuf, + (size_t) size, __GLX_SIZE_CARD32); if (!cx->selectBuf) { cl->client->errorValue = size; return BadAlloc; |