aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/dixfonts.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/dix/dixfonts.c')
-rw-r--r--xorg-server/dix/dixfonts.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c
index bc2732fb9..be389e82f 100644
--- a/xorg-server/dix/dixfonts.c
+++ b/xorg-server/dix/dixfonts.c
@@ -168,9 +168,8 @@ QueueFontWakeup(FontPathElementPtr fpe)
}
}
if (num_slept_fpes == size_slept_fpes) {
- new = (FontPathElementPtr *)
- realloc(slept_fpes,
- sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
+ new = reallocarray(slept_fpes, size_slept_fpes + 4,
+ sizeof(FontPathElementPtr));
if (!new)
return;
slept_fpes = new;
@@ -424,7 +423,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
* copy the current FPE list, so that if it gets changed by another client
* while we're blocking, the request still appears atomic
*/
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
if (!c->fpe_list) {
free((void *) c->fontname);
free(c);
@@ -821,7 +820,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
if (!(c = malloc(sizeof *c)))
return BadAlloc;
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
if (!c->fpe_list) {
free(c);
return BadAlloc;
@@ -1072,7 +1071,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
if (!(c = malloc(sizeof *c)))
goto badAlloc;
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
if (!c->fpe_list) {
free(c);
goto badAlloc;
@@ -1441,7 +1440,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
*new_closure = *c;
c = new_closure;
- data = malloc(c->nChars * itemSize);
+ data = xallocarray(c->nChars, itemSize);
if (!data) {
free(c);
c = old_closure;
@@ -1597,7 +1596,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
unsigned char *cp = paths;
FontPathElementPtr fpe = NULL, *fplist;
- fplist = malloc(sizeof(FontPathElementPtr) * npaths);
+ fplist = xallocarray(npaths, sizeof(FontPathElementPtr));
if (!fplist) {
*bad = 0;
return BadAlloc;
@@ -1894,8 +1893,7 @@ RegisterFPEFunctions(NameCheckFunc name_func,
FPEFunctions *new;
/* grow the list */
- new = (FPEFunctions *) realloc(fpe_functions,
- (num_fpe_types + 1) * sizeof(FPEFunctions));
+ new = reallocarray(fpe_functions, num_fpe_types + 1, sizeof(FPEFunctions));
if (!new)
return -1;
fpe_functions = new;