[util] Plug minor leak

This commit is contained in:
Behdad Esfahbod 2014-03-19 15:38:02 -07:00
parent 09732cc669
commit ea5e8a02eb
5 changed files with 24 additions and 17 deletions

View File

@ -31,8 +31,7 @@
struct output_buffer_t
{
output_buffer_t (option_parser_t *parser)
: options (parser,
g_strjoinv ("/", (gchar**) hb_buffer_serialize_list_formats ())),
: options (parser, hb_buffer_serialize_list_formats ()),
format (parser),
gs (NULL),
line_no (0),
@ -53,7 +52,8 @@ struct output_buffer_t
{
if (options.explicit_output_format)
fail (false, "Unknown output format `%s'; supported formats are: %s",
options.output_format, options.supported_formats);
options.output_format,
g_strjoinv ("/", const_cast<char**> (options.supported_formats)));
else
/* Just default to TEXT if not explicitly requested and the
* file extension is not recognized. */

View File

@ -246,24 +246,26 @@ stdio_write_func (void *closure,
return CAIRO_STATUS_SUCCESS;
}
const char helper_cairo_supported_formats[] =
"ansi"
const char *helper_cairo_supported_formats[] =
{
"ansi",
#ifdef CAIRO_HAS_PNG_FUNCTIONS
"/png"
"png",
#endif
#ifdef CAIRO_HAS_SVG_SURFACE
"/svg"
"svg",
#endif
#ifdef CAIRO_HAS_PDF_SURFACE
"/pdf"
"pdf",
#endif
#ifdef CAIRO_HAS_PS_SURFACE
"/ps"
"ps",
#ifdef HAS_EPS
"/eps"
"eps",
#endif
#endif
;
NULL
};
cairo_t *
helper_cairo_create_context (double w, double h,
@ -343,7 +345,8 @@ helper_cairo_create_context (double w, double h,
surface = constructor2 (stdio_write_func, f, w, h, content);
else
fail (false, "Unknown output format `%s'; supported formats are: %s%s",
extension, helper_cairo_supported_formats,
extension,
g_strjoinv ("/", const_cast<char**> (helper_cairo_supported_formats)),
out_opts->explicit_output_format ? "" :
"\nTry setting format using --output-format");

View File

@ -36,7 +36,7 @@ cairo_scaled_font_t *
helper_cairo_create_scaled_font (const font_options_t *font_opts,
double font_size);
extern const char helper_cairo_supported_formats[];
extern const char *helper_cairo_supported_formats[];
cairo_t *
helper_cairo_create_context (double w, double h,

View File

@ -374,7 +374,11 @@ output_options_t::add_options (option_parser_t *parser)
if (NULL == supported_formats)
text = "Set output format";
else
text = text_free = g_strdup_printf ("Set output format\n\n Supported formats are: %s", supported_formats);
{
char *items = g_strjoinv ("/", const_cast<char **> (supported_formats));
text = text_free = g_strdup_printf ("Set output format\n\n Supported formats are: %s", items);
g_free (items);
}
GOptionEntry entries[] =
{

View File

@ -65,7 +65,7 @@ template <typename Type> static inline Type MIN (const Type &a, const Type &b) {
template <typename Type> static inline Type MAX (const Type &a, const Type &b) { return a > b ? a : b; }
void fail (hb_bool_t suggest_help, const char *format, ...) G_GNUC_NORETURN;
void fail (hb_bool_t suggest_help, const char *format, ...) G_GNUC_NORETURN G_GNUC_PRINTF (2, 3);
extern hb_bool_t debug;
@ -318,7 +318,7 @@ struct text_options_t : option_group_t
struct output_options_t : option_group_t
{
output_options_t (option_parser_t *parser,
const char *supported_formats_ = NULL) {
const char **supported_formats_ = NULL) {
output_file = NULL;
output_format = NULL;
supported_formats = supported_formats_;
@ -354,7 +354,7 @@ struct output_options_t : option_group_t
const char *output_file;
const char *output_format;
const char *supported_formats;
const char **supported_formats;
bool explicit_output_format;
mutable FILE *fp;