diff options
Diffstat (limited to 'src/bitmap')
-rw-r--r-- | src/bitmap/bdfread.c | 9 | ||||
-rw-r--r-- | src/bitmap/bitmaputil.c | 3 | ||||
-rw-r--r-- | src/bitmap/bitscale.c | 7 | ||||
-rw-r--r-- | src/bitmap/pcfread.c | 13 | ||||
-rw-r--r-- | src/bitmap/pcfwrite.c | 3 | ||||
-rw-r--r-- | src/bitmap/snfread.c | 5 |
6 files changed, 23 insertions, 17 deletions
diff --git a/src/bitmap/bdfread.c b/src/bitmap/bdfread.c index f2b1e22..f4340b9 100644 --- a/src/bitmap/bdfread.c +++ b/src/bitmap/bdfread.c @@ -53,6 +53,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <ctype.h> #include <X11/fonts/fntfilst.h> @@ -107,7 +108,7 @@ bdfReadBitmap(CharInfoPtr pCI, FontFilePtr file, int bit, int byte, widthBytes = BYTES_PER_ROW(widthBits, glyph); if (widthBytes * height > 0) { - picture = malloc(widthBytes * height); + picture = mallocarray(widthBytes, height); if (!picture) { bdfError("Couldn't allocate picture (%d*%d)\n", widthBytes, height); goto BAILOUT; @@ -313,7 +314,7 @@ bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState, bitmapFont->metrics = ci; if (bitmapExtra) { - bitmapExtra->glyphNames = malloc(nchars * sizeof(Atom)); + bitmapExtra->glyphNames = mallocarray(nchars, sizeof(Atom)); if (!bitmapExtra->glyphNames) { bdfError("Couldn't allocate glyphNames (%d*%d)\n", nchars, (int) sizeof(Atom)); @@ -321,7 +322,7 @@ bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState, } } if (bitmapExtra) { - bitmapExtra->sWidths = malloc(nchars * sizeof(int)); + bitmapExtra->sWidths = mallocarray(nchars, sizeof(int)); if (!bitmapExtra->sWidths) { bdfError("Couldn't allocate sWidth (%d *%d)\n", nchars, (int) sizeof(int)); @@ -640,7 +641,7 @@ bdfReadProperties(FontFilePtr file, FontPtr pFont, bdfFileState *pState) pFont->info.props = NULL; pFont->info.nprops = 0; - stringProps = malloc((nProps + BDF_GENPROPS) * sizeof(char)); + stringProps = mallocarray((nProps + BDF_GENPROPS), sizeof(char)); pFont->info.isStringProp = stringProps; if (stringProps == NULL) { bdfError("Couldn't allocate stringProps (%d*%d)\n", diff --git a/src/bitmap/bitmaputil.c b/src/bitmap/bitmaputil.c index 232729f..c2135a0 100644 --- a/src/bitmap/bitmaputil.c +++ b/src/bitmap/bitmaputil.c @@ -30,6 +30,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <X11/fonts/fntfilst.h> #include <X11/fonts/bitmap.h> @@ -210,7 +211,7 @@ bitmapAddInkMetrics(FontPtr pFont) int i; bitmapFont = (BitmapFontPtr) pFont->fontPrivate; - bitmapFont->ink_metrics = malloc(bitmapFont->num_chars * sizeof(xCharInfo)); + bitmapFont->ink_metrics = mallocarray(bitmapFont->num_chars, sizeof(xCharInfo)); if (!bitmapFont->ink_metrics) { fprintf(stderr, "Error: Couldn't allocate ink_metrics (%d*%ld)\n", bitmapFont->num_chars, (unsigned long)sizeof(xCharInfo)); diff --git a/src/bitmap/bitscale.c b/src/bitmap/bitscale.c index 5f77635..12d40d1 100644 --- a/src/bitmap/bitscale.c +++ b/src/bitmap/bitscale.c @@ -34,6 +34,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <X11/fonts/fntfilst.h> #include <X11/fonts/bitmap.h> @@ -585,7 +586,7 @@ ComputeScaledProperties(FontInfoPtr sourceFontInfo, /* the font to be scaled */ } nProps = NPROPS + 1 + sizeof(fontPropTable) / sizeof(fontProp) + sizeof(rawFontPropTable) / sizeof(fontProp); - fp = malloc(sizeof(FontPropRec) * nProps); + fp = mallocarray(sizeof(FontPropRec), nProps); *pProps = fp; if (!fp) { fprintf(stderr, "Error: Couldn't allocate font properties (%ld*%d)\n", @@ -859,7 +860,7 @@ ScaleFont(FontPtr opf, /* originating font */ bitmapFont->encoding = 0; bitmapFont->bitmapExtra = 0; bitmapFont->pDefault = 0; - bitmapFont->metrics = malloc(nchars * sizeof(CharInfoRec)); + bitmapFont->metrics = mallocarray(nchars, sizeof(CharInfoRec)); if (!bitmapFont->metrics) { fprintf(stderr, "Error: Couldn't allocate metrics (%d*%ld)\n", nchars, (unsigned long)sizeof(CharInfoRec)); @@ -1174,7 +1175,7 @@ ScaleBitmap(FontPtr pFont, CharInfoPtr opci, CharInfoPtr pci, /* Looks like we need to anti-alias. Create a workspace to contain the grayscale character plus an additional row and column for scratch */ - char_grayscale = malloc((width + 1) * (height + 1)); + char_grayscale = mallocarray((width + 1), (height + 1)); if (char_grayscale) { diffusion_workspace = calloc((newWidth + 2) * 2, sizeof(int)); diff --git a/src/bitmap/pcfread.c b/src/bitmap/pcfread.c index ae34c28..bf64d6f 100644 --- a/src/bitmap/pcfread.c +++ b/src/bitmap/pcfread.c @@ -34,6 +34,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <X11/fonts/fntfilst.h> #include <X11/fonts/bitmap.h> @@ -138,7 +139,7 @@ pcfReadTOC(FontFilePtr file, int *countp) pcfError("pcfReadTOC(): invalid file format\n"); return NULL; } - tables = malloc(count * sizeof(PCFTableRec)); + tables = mallocarray(count, sizeof(PCFTableRec)); if (!tables) { pcfError("pcfReadTOC(): Couldn't allocate tables (%d*%d)\n", count, (int) sizeof(PCFTableRec)); @@ -263,13 +264,13 @@ pcfGetProperties(FontInfoPtr pFontInfo, FontFilePtr file, goto Bail; } if (IS_EOF(file)) goto Bail; - props = malloc(nprops * sizeof(FontPropRec)); + props = mallocarray(nprops, sizeof(FontPropRec)); if (!props) { pcfError("pcfGetProperties(): Couldn't allocate props (%d*%d)\n", nprops, (int) sizeof(FontPropRec)); goto Bail; } - isStringProp = malloc(nprops * sizeof(char)); + isStringProp = mallocarray(nprops, sizeof(char)); if (!isStringProp) { pcfError("pcfGetProperties(): Couldn't allocate isStringProp (%d*%d)\n", nprops, (int) sizeof(char)); @@ -456,7 +457,7 @@ pcfReadFont(FontPtr pFont, FontFilePtr file, pcfError("pcfReadFont(): invalid file format\n"); goto Bail; } - metrics = malloc(nmetrics * sizeof(CharInfoRec)); + metrics = mallocarray(nmetrics, sizeof(CharInfoRec)); if (!metrics) { pcfError("pcfReadFont(): Couldn't allocate metrics (%d*%d)\n", nmetrics, (int) sizeof(CharInfoRec)); @@ -483,7 +484,7 @@ pcfReadFont(FontPtr pFont, FontFilePtr file, if (nbitmaps != nmetrics || IS_EOF(file)) goto Bail; /* nmetrics is already ok, so nbitmap also is */ - offsets = malloc(nbitmaps * sizeof(CARD32)); + offsets = mallocarray(nbitmaps, sizeof(CARD32)); if (!offsets) { pcfError("pcfReadFont(): Couldn't allocate offsets (%d*%d)\n", nbitmaps, (int) sizeof(CARD32)); @@ -573,7 +574,7 @@ pcfReadFont(FontPtr pFont, FontFilePtr file, if (nink_metrics != nmetrics) goto Bail; /* nmetrics already checked */ - ink_metrics = malloc(nink_metrics * sizeof(xCharInfo)); + ink_metrics = mallocarray(nink_metrics, sizeof(xCharInfo)); if (!ink_metrics) { pcfError("pcfReadFont(): Couldn't allocate ink_metrics (%d*%d)\n", nink_metrics, (int) sizeof(xCharInfo)); diff --git a/src/bitmap/pcfwrite.c b/src/bitmap/pcfwrite.c index 61ae83d..de7936c 100644 --- a/src/bitmap/pcfwrite.c +++ b/src/bitmap/pcfwrite.c @@ -34,6 +34,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <X11/fonts/fntfilst.h> #include <X11/fonts/bitmap.h> @@ -235,7 +236,7 @@ pcfWriteFont(FontPtr pFont, FontFilePtr file) ink_minbounds = &pFont->info.ink_minbounds; ink_maxbounds = &pFont->info.ink_maxbounds; } - offsetProps = malloc(pFont->info.nprops * sizeof(FontPropRec)); + offsetProps = mallocarray(pFont->info.nprops, sizeof(FontPropRec)); if (!offsetProps) { pcfError("pcfWriteFont(): Couldn't allocate offsetProps (%d*%d)", pFont->info.nprops, (int) sizeof(FontPropRec)); diff --git a/src/bitmap/snfread.c b/src/bitmap/snfread.c index 452b99d..2e94f9c 100644 --- a/src/bitmap/snfread.c +++ b/src/bitmap/snfread.c @@ -53,6 +53,7 @@ from The Open Group. #include <config.h> #endif #include "libxfontint.h" +#include "src/util/replace.h" #include <ctype.h> #include <X11/fonts/fntfilst.h> @@ -453,13 +454,13 @@ snfReadFontInfo(FontInfoPtr pFontInfo, FontFilePtr file) return ret; snfCopyInfo(&fi, pFontInfo); - pFontInfo->props = malloc(fi.nProps * sizeof(FontPropRec)); + pFontInfo->props = mallocarray(fi.nProps, sizeof(FontPropRec)); if (!pFontInfo->props) { snfError("snfReadFontInfo(): Couldn't allocate props (%d*%d)\n", fi.nProps, (int) sizeof(FontPropRec)); return AllocError; } - pFontInfo->isStringProp = malloc(fi.nProps * sizeof(char)); + pFontInfo->isStringProp = mallocarray(fi.nProps, sizeof(char)); if (!pFontInfo->isStringProp) { snfError("snfReadFontInfo(): Couldn't allocate isStringProp (%d*%d)\n", fi.nProps, (int) sizeof(char)); |