summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2015-03-21 15:05:30 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2015-04-21 16:58:08 -0700
commitf59236c2865d22c6f0b2d1ba303213afd10cd02e (patch)
tree86865f9806a3754895861910a8a27c1d93bb5653 /glamor
parent7ac280287491fe06127d9fefc504217e21c780e6 (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>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor_compositerects.c2
-rw-r--r--glamor/glamor_glyphs.c2
-rw-r--r--glamor/glamor_gradient.c8
-rw-r--r--glamor/glamor_pixmap.c4
-rw-r--r--glamor/glamor_prepare.c4
-rw-r--r--glamor/glamor_utils.c2
6 files changed, 11 insertions, 11 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++) {