summaryrefslogtreecommitdiff
path: root/src/FreeType
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2009-01-20 23:16:35 -0500
committerAdam Jackson <ajax@redhat.com>2009-01-20 23:16:35 -0500
commit0cdc9b8f850342d50b72a57507db3413eacc6fb8 (patch)
treeb86480167977d28f8e7574c91aedf982db52bf32 /src/FreeType
parent632a2e90a4b209facc84d7a18873f19a720ea7df (diff)
downloadxorg-lib-libXfont-0cdc9b8f850342d50b72a57507db3413eacc6fb8.tar.gz
xalloc -> malloc, etc.
Diffstat (limited to 'src/FreeType')
-rw-r--r--src/FreeType/ftfuncs.c111
-rw-r--r--src/FreeType/xttcap.c19
2 files changed, 58 insertions, 72 deletions
diff --git a/src/FreeType/ftfuncs.c b/src/FreeType/ftfuncs.c
index 9f3af5d..35d58d5 100644
--- a/src/FreeType/ftfuncs.c
+++ b/src/FreeType/ftfuncs.c
@@ -194,24 +194,22 @@ FreeTypeOpenFace(FTFacePtr *facep, char *FTFileName, char *realFileName, int fac
}
/* No cached match; need to make a new one */
- face = (FTFacePtr)xalloc(sizeof(FTFaceRec));
- if(face == NULL) {
+ face = calloc(1, sizeof(FTFaceRec));
+ if (face == NULL) {
return AllocError;
}
- memset(face, 0, sizeof(FTFaceRec));
- face->filename = (char*)xalloc(strlen(FTFileName)+1);
- if(face->filename == NULL) {
- xfree(face);
+ face->filename = strdup(FTFileName);
+ if (face->filename == NULL) {
+ free(face);
return AllocError;
}
- strcpy(face->filename, FTFileName);
ftrc = FT_New_Face(ftypeLibrary, realFileName, faceNumber, &face->face);
if(ftrc != 0) {
ErrorF("FreeType: couldn't open face %s: %d\n", FTFileName, ftrc);
- xfree(face->filename);
- xfree(face);
+ free(face->filename);
+ free(face);
return BadFontName;
}
@@ -257,8 +255,8 @@ FreeTypeFreeFace(FTFacePtr face)
}
MUMBLE1("Closing face: %s\n", face->filename);
FT_Done_Face(face->face);
- xfree(face->filename);
- xfree(face);
+ free(face->filename);
+ free(face);
}
}
@@ -417,7 +415,7 @@ FreeTypeOpenInstance(FTInstancePtr *instance_return, FTFacePtr face,
}
/* None matching found */
- instance = (FTInstancePtr)xalloc(sizeof(FTInstanceRec));
+ instance = malloc(sizeof(FTInstanceRec));
if(instance == NULL) {
return AllocError;
}
@@ -452,7 +450,7 @@ FreeTypeOpenInstance(FTInstancePtr *instance_return, FTFacePtr face,
ftrc = FT_New_Size(instance->face->face, &instance->size);
if(ftrc != 0) {
ErrorF("FreeType: couldn't create size object: %d\n", ftrc);
- xfree(instance);
+ free(instance);
return FTtoXReturnCode(ftrc);
}
FreeTypeActivateInstance(instance);
@@ -465,14 +463,14 @@ FreeTypeOpenInstance(FTInstancePtr *instance_return, FTFacePtr face,
int xsize, ysize;
xrc = FTFindSize(face->face, trans, &xsize, &ysize);
if(xrc != Successful) {
- xfree(instance);
+ free(instance);
return xrc;
}
ftrc = FT_Set_Pixel_Sizes(instance->face->face, xsize, ysize);
}
if(ftrc != 0) {
FT_Done_Size(instance->size);
- xfree(instance);
+ free(instance);
return FTtoXReturnCode(ftrc);
}
@@ -569,10 +567,10 @@ FreeTypeFreeInstance(FTInstancePtr instance)
FreeTypeFreeFace(instance->face);
if(instance->charcellMetrics) {
- xfree(instance->charcellMetrics);
+ free(instance->charcellMetrics);
}
if(instance->forceConstantMetrics) {
- xfree(instance->forceConstantMetrics);
+ free(instance->forceConstantMetrics);
}
if(instance->glyphs) {
for(i = 0; i < iceil(instance->nglyphs, FONTSEGMENTSIZE); i++) {
@@ -580,21 +578,21 @@ FreeTypeFreeInstance(FTInstancePtr instance)
for(j = 0; j < FONTSEGMENTSIZE; j++) {
if(instance->available[i][j] ==
FT_AVAILABLE_RASTERISED)
- xfree(instance->glyphs[i][j].bits);
+ free(instance->glyphs[i][j].bits);
}
- xfree(instance->glyphs[i]);
+ free(instance->glyphs[i]);
}
}
- xfree(instance->glyphs);
+ free(instance->glyphs);
}
if(instance->available) {
for(i = 0; i < iceil(instance->nglyphs, FONTSEGMENTSIZE); i++) {
if(instance->available[i])
- xfree(instance->available[i]);
+ free(instance->available[i]);
}
- xfree(instance->available);
+ free(instance->available);
}
- xfree(instance);
+ free(instance);
}
}
@@ -617,38 +615,30 @@ FreeTypeInstanceFindGlyph(unsigned idx_in, int flags, FTInstancePtr instance,
}
if(*available == NULL) {
- *available =
- (int**)xalloc(sizeof(int*) * iceil(instance->nglyphs,
- FONTSEGMENTSIZE));
+ *available = calloc(iceil(instance->nglyphs, FONTSEGMENTSIZE),
+ sizeof(int *));
if(*available == NULL)
return AllocError;
- memset((char*)(*available), 0,
- sizeof(int*) * iceil(instance->nglyphs, FONTSEGMENTSIZE));
}
segment = ifloor(idx, FONTSEGMENTSIZE);
offset = idx - segment * FONTSEGMENTSIZE;
if((*available)[segment] == NULL) {
- (*available)[segment] = (int*)xalloc(sizeof(int) * FONTSEGMENTSIZE);
+ (*available)[segment] = calloc(FONTSEGMENTSIZE, sizeof(int *));
if((*available)[segment] == NULL)
return AllocError;
- memset((char*)(*available)[segment], 0, sizeof(int) * FONTSEGMENTSIZE);
}
if(*glyphs == NULL) {
- *glyphs = (CharInfoPtr*)xalloc(sizeof(CharInfoPtr)*
- iceil(instance->nglyphs,
- FONTSEGMENTSIZE));
+ *glyphs = calloc(iceil(instance->nglyphs, FONTSEGMENTSIZE),
+ sizeof(CharInfoPtr));
if(*glyphs == NULL)
return AllocError;
- memset((char*)(*glyphs), 0,
- sizeof(CharInfoPtr)*iceil(instance->nglyphs, FONTSEGMENTSIZE));
}
if((*glyphs)[segment] == NULL) {
- (*glyphs)[segment]=
- (CharInfoPtr)xalloc(sizeof(CharInfoRec) * FONTSEGMENTSIZE);
+ (*glyphs)[segment] = malloc(sizeof(CharInfoRec) * FONTSEGMENTSIZE);
if((*glyphs)[segment] == NULL)
return AllocError;
}
@@ -1372,10 +1362,9 @@ FreeTypeRasteriseGlyph(unsigned idx, int flags, CharInfoPtr tgp,
bpr = (((wd + (instance->bmfmt.glyph<<3) - 1) >> 3) &
-instance->bmfmt.glyph);
- raster = (char*)xalloc(ht * bpr);
+ raster = calloc(1, ht * bpr);
if(raster == NULL)
return AllocError;
- memset(raster, 0, ht * bpr);
tgp->bits = raster;
@@ -1534,10 +1523,10 @@ FreeTypeFreeFont(FTFontPtr font)
{
FreeTypeFreeInstance(font->instance);
if(font->ranges)
- xfree(font->ranges);
+ free(font->ranges);
if(font->dummy_char.bits)
- xfree(font->dummy_char.bits);
- xfree(font);
+ free(font->dummy_char.bits);
+ free(font);
}
/* Free a font. If freeProps is 0, don't free the properties. */
@@ -1552,8 +1541,8 @@ FreeTypeFreeXFont(FontPtr pFont, int freeProps)
FreeTypeFreeFont(tf);
}
if(freeProps && pFont->info.nprops>0) {
- xfree(pFont->info.isStringProp);
- xfree(pFont->info.props);
+ free(pFont->info.isStringProp);
+ free(pFont->info.props);
}
DestroyFontRec(pFont);
}
@@ -1633,13 +1622,13 @@ FreeTypeAddProperties(FTFontPtr font, FontScalablePtr vals, FontInfoPtr info,
( (font_properties && (post || t1info)) ? 3 : 0 ) +
2; /* type */
- info->props = (FontPropPtr)xalloc(maxprops * sizeof(FontPropRec));
+ info->props = malloc(maxprops * sizeof(FontPropRec));
if(info->props == NULL)
return AllocError;
- info->isStringProp = (char*)xalloc(maxprops);
+ info->isStringProp = malloc(maxprops);
if(info->isStringProp == NULL) {
- xfree(info->props);
+ free(info->props);
return AllocError;
}
@@ -2133,7 +2122,7 @@ restrict_code_range_by_str(int count,unsigned short *refFirstCol,
fflush(stderr);
#endif
nRanges++;
- ranges = (fsRange *)xrealloc(ranges, nRanges*sizeof(*ranges));
+ ranges = realloc(ranges, nRanges*sizeof(*ranges));
if (NULL == ranges)
break;
{
@@ -2164,7 +2153,7 @@ restrict_code_range_by_str(int count,unsigned short *refFirstCol,
}
result=i;
}
- xfree(ranges);
+ free(ranges);
}
return result;
}
@@ -2208,7 +2197,7 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
int dirLen = p1-fileName;
int baseLen = fileName+len - p2 -1;
- *dynStrRealFileName = (char *)xalloc(dirLen+baseLen+1);
+ *dynStrRealFileName = malloc(dirLen+baseLen+1);
if( *dynStrRealFileName == NULL ) {
result = AllocError;
goto quit;
@@ -2278,7 +2267,7 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
if( beginptr && 0 < *face_number ) {
char *slash;
*dynStrFTFileName = /* add -> ':'+strlen0+':'+strlen1+'\0' */
- (char *)xalloc(1+strlen(beginptr)+1+strlen(*dynStrRealFileName)+1);
+ malloc(1+strlen(beginptr)+1+strlen(*dynStrRealFileName)+1);
if( *dynStrFTFileName == NULL ){
result = AllocError;
goto quit;
@@ -2303,7 +2292,7 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals,
}
}
else{
- *dynStrFTFileName = (char *)xalloc(strlen(*dynStrRealFileName)+1);
+ *dynStrFTFileName = malloc(strlen(*dynStrRealFileName)+1);
if( *dynStrFTFileName == NULL ){
result = AllocError;
goto quit;
@@ -2823,7 +2812,7 @@ FreeTypeLoadFont(FTFontPtr font, FontInfoPtr info, FTFacePtr face,
font->nranges = vals->nranges;
font->ranges = 0;
if(font->nranges) {
- font->ranges = (fsRange*)xalloc(vals->nranges*sizeof(fsRange));
+ font->ranges = malloc(vals->nranges*sizeof(fsRange));
if(font->ranges == NULL)
return AllocError;
memcpy((char*)font->ranges, (char*)vals->ranges,
@@ -3151,12 +3140,11 @@ FreeTypeLoadXFont(char *fileName,
char *dynStrFTFileName = NULL; /* :1:foo.ttc */
char *dynStrTTCapCodeRange = NULL;
- font = (FTFontPtr)xalloc(sizeof(FTFontRec));
+ font = calloc(1, sizeof(FTFontRec));
if(font == NULL) {
xrc = AllocError;
goto quit;
}
- memset(font, 0, sizeof(FTFontRec));
xrc = FreeTypeSetUpTTCap(fileName, vals,
&dynStrRealFileName, &dynStrFTFileName,
@@ -3461,7 +3449,7 @@ FreeTypeLoadXFont(char *fileName,
}
/* header's metrics */
- instance->charcellMetrics = (xCharInfo*)xalloc(sizeof(xCharInfo));
+ instance->charcellMetrics = malloc(sizeof(xCharInfo));
if(instance->charcellMetrics == NULL) {
xrc = AllocError;
goto quit;
@@ -3492,7 +3480,7 @@ FreeTypeLoadXFont(char *fileName,
int c = ins_ttcap->force_c_representative_metrics_char_code;
/* header's metrics */
if( instance->forceConstantMetrics == NULL ){
- instance->forceConstantMetrics = (xCharInfo*)xalloc(sizeof(xCharInfo));
+ instance->forceConstantMetrics = malloc(sizeof(xCharInfo));
if(instance->forceConstantMetrics == NULL) {
xrc = AllocError;
goto quit;
@@ -3632,9 +3620,9 @@ FreeTypeLoadXFont(char *fileName,
}
quit:
- if ( dynStrTTCapCodeRange ) xfree(dynStrTTCapCodeRange);
- if ( dynStrFTFileName ) xfree(dynStrFTFileName);
- if ( dynStrRealFileName ) xfree(dynStrRealFileName);
+ if ( dynStrTTCapCodeRange ) free(dynStrTTCapCodeRange);
+ if ( dynStrFTFileName ) free(dynStrFTFileName);
+ if ( dynStrRealFileName ) free(dynStrRealFileName);
if ( xrc != Successful ) {
if( font ){
if( face && font->instance == NULL ) FreeTypeFreeFace(face);
@@ -3763,9 +3751,8 @@ FreeTypeGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
else ht=ht_actual;
bpr = (((wd + (tf->instance->bmfmt.glyph<<3) - 1) >> 3) &
-tf->instance->bmfmt.glyph);
- raster = (char*)xalloc(ht * bpr);
+ raster = calloc(1, ht * bpr);
if(raster) {
- memset(raster, 0, ht * bpr);
tf->dummy_char.bits = raster;
*gp++ = &tf->dummy_char;
}
diff --git a/src/FreeType/xttcap.c b/src/FreeType/xttcap.c
index 49d2e8e..89e092b 100644
--- a/src/FreeType/xttcap.c
+++ b/src/FreeType/xttcap.c
@@ -235,7 +235,7 @@ SPropRecValList_add_record(SDynPropRecValList *pThisList,
{
char *p;
- if (NULL == (p = (char *)xalloc(strlen(strValue)+1))) {
+ if (NULL == (p = malloc(strlen(strValue)+1))) {
fprintf(stderr,
"truetype font property : "
"cannot allocate memory.\n");
@@ -259,8 +259,7 @@ SPropRecValList_add_record(SDynPropRecValList *pThisList,
/* add to list */
SPropRecValListNodeP *newNode;
- if (NULL == (newNode =
- (SPropRecValListNodeP *)xalloc(sizeof(*newNode)))) {
+ if (NULL == (newNode = malloc(sizeof(*newNode)))) {
fprintf(stderr,
"truetype font property : "
"cannot allocate memory.\n");
@@ -449,7 +448,7 @@ parse_one_line(SDynPropRecValList *pThisList, FILE *is)
char *buf = NULL;
char *recordHead, *valueHead = NULL;
- if (NULL == (buf = xalloc(LEN_LINEBUF))) {
+ if (NULL == (buf = malloc(LEN_LINEBUF))) {
fprintf(stderr,
"truetype font property file : cannot allocate memory.\n");
result = True;
@@ -484,7 +483,7 @@ parse_one_line(SDynPropRecValList *pThisList, FILE *is)
result = SPropRecValList_add_record(pThisList, recordHead, valueHead);
}
quit:
- xfree(buf);
+ free(buf);
abort:
return result;
}
@@ -625,13 +624,13 @@ SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList,
char *value;
len = term-p-1;
- value=(char *)xalloc(len+1);
+ value=malloc(len+1);
memcpy(value, p+1, len);
value[len]='\0';
SPropRecValList_add_record(pThisList,
"FaceNumber",
value);
- xfree(value);
+ free(value);
term=p;
}
break;
@@ -645,7 +644,7 @@ SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList,
int i;
char const *nextColon = strchr(strCapHead, ':');
if (0<nextColon-strCapHead) {
- char *duplicated = (char *)xalloc((nextColon-strCapHead)+1);
+ char *duplicated = malloc((nextColon-strCapHead)+1);
{
char *value;
@@ -674,7 +673,7 @@ SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList,
next:
;
}
- xfree(duplicated);
+ free(duplicated);
}
strCapHead = nextColon+1;
}
@@ -695,7 +694,7 @@ XttXstrdup(char const *str)
{
char *result;
- result = (char *)xalloc(strlen(str)+1);
+ result = malloc(strlen(str)+1);
if (result)
strcpy(result, str);