moved font plotter allocation
Delayed font plotter alloction until the requested font plotter is found.
This commit is contained in:
parent
2c0bcc39bd
commit
258477ad28
|
@ -45,22 +45,35 @@ void dump_font_drivers(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Create an new text plotter object
|
* Create an new text plotter object
|
||||||
* Available: "vdi", "freetype"
|
*
|
||||||
* @param vdihandle the vdi handle to act upon,
|
* Available: "vdi", "freetype", "internal"
|
||||||
* @param name selector ID (string) of the font plotter.
|
* \param vdihandle the vdi handle to act upon,
|
||||||
* @flags flags configration flags of the plotter,
|
* \param name selector ID (string) of the font plotter.
|
||||||
|
* flags flags configration flags of the plotter,
|
||||||
* available flags:
|
* available flags:
|
||||||
* FONTPLOT_FLAG_MONOGLYPH - Enable 1 bit font plotting
|
* FONTPLOT_FLAG_MONOGLYPH - Enable 1 bit font plotting
|
||||||
* @param error set to != 0 when errors occur
|
* \param error set to != 0 when errors occur
|
||||||
|
* \return the new font plotter instance on success, or NULL on failure.
|
||||||
*/
|
*/
|
||||||
FONT_PLOTTER new_font_plotter(int vdihandle, char * name, unsigned long flags,
|
FONT_PLOTTER new_font_plotter(int vdihandle, char * name, unsigned long flags,
|
||||||
int * error)
|
int * error)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
int res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
int res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
||||||
FONT_PLOTTER fplotter;
|
FONT_PLOTTER fplotter = NULL;
|
||||||
|
|
||||||
|
/* set the default error code: */
|
||||||
|
*error = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
|
||||||
|
/* Find the selector string in the font plotter table, */
|
||||||
|
/* and bail out when the font plotter is not available: */
|
||||||
|
for (i = 0; font_driver_table[i].name != NULL; i++) {
|
||||||
|
|
||||||
|
/* found selector in driver table? */
|
||||||
|
if (strcmp(name, font_driver_table[i].name) == 0) {
|
||||||
|
|
||||||
/* allocate the font plotter instance: */
|
/* allocate the font plotter instance: */
|
||||||
fplotter = (FONT_PLOTTER)malloc(sizeof(struct s_font_plotter));
|
fplotter = (FONT_PLOTTER)malloc(sizeof(struct s_font_plotter));
|
||||||
|
@ -76,31 +89,22 @@ FONT_PLOTTER new_font_plotter( int vdihandle, char * name, unsigned long flags,
|
||||||
fplotter->flags = 0;
|
fplotter->flags = 0;
|
||||||
fplotter->flags |= flags;
|
fplotter->flags |= flags;
|
||||||
|
|
||||||
/* Find the selector string in the font plotter table: */
|
/* Execute the constructor: */
|
||||||
/* And bail out when the font plotter is not available: */
|
assert(font_driver_table[i].ctor);
|
||||||
for( i = 0; ; i++) {
|
|
||||||
if( font_driver_table[i].name == NULL ) {
|
|
||||||
res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
if( strcmp(name, font_driver_table[i].name) == 0 ) {
|
|
||||||
if( font_driver_table[i].ctor ) {
|
|
||||||
res = font_driver_table[i].ctor(fplotter);
|
res = font_driver_table[i].ctor(fplotter);
|
||||||
*error = 0;
|
|
||||||
} else {
|
/* success? */
|
||||||
res = 0-ERR_PLOTTER_NOT_AVAILABLE;
|
|
||||||
*error = res;
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
|
/* NO success! */
|
||||||
free(fplotter);
|
free(fplotter);
|
||||||
*error = res;
|
*error = res;
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
*error = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return(fplotter);
|
return(fplotter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue