Introduce print_stream_ps_alloc() and start using it
authorkrj <krj@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 26 Sep 2009 05:48:04 +0000 (05:48 +0000)
committerkrj <krj@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 26 Sep 2009 05:48:04 +0000 (05:48 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@30164 f5534014-38df-0310-8fa8-9805f1628bb7

print.c

diff --git a/print.c b/print.c
index 17fa8b70b23838d6489cd46e6e771758d31cbdf8..5632bcc5166e64f89411d8afb5bbe66243ed6e5e 100644 (file)
--- a/print.c
+++ b/print.c
@@ -1209,17 +1209,12 @@ static const print_stream_ops_t print_ps_ops = {
        destroy_ps
 };
 
-print_stream_t *
-print_stream_ps_new(int to_file, const char *dest)
+static print_stream_t *
+print_stream_ps_alloc(int to_file, FILE *fh)
 {
-       FILE *fh;
        print_stream_t *stream;
        output_ps *output;
 
-       fh = open_print_dest(to_file, dest);
-       if (fh == NULL)
-               return NULL;
-
        output = g_malloc(sizeof *output);
        output->to_file = to_file;
        output->fh = fh;
@@ -1231,19 +1226,21 @@ print_stream_ps_new(int to_file, const char *dest)
 }
 
 print_stream_t *
-print_stream_ps_stdio_new(FILE *fh)
+print_stream_ps_new(int to_file, const char *dest)
 {
-       print_stream_t *stream;
-       output_ps *output;
+       FILE *fh;
 
-       output = g_malloc(sizeof *output);
-       output->to_file = TRUE;
-       output->fh = fh;
-       stream = g_malloc(sizeof (print_stream_t));
-       stream->ops = &print_ps_ops;
-       stream->data = output;
+       fh = open_print_dest(to_file, dest);
+       if (fh == NULL)
+               return NULL;
 
-       return stream;
+       return print_stream_ps_alloc(to_file, fh);
+}
+
+print_stream_t *
+print_stream_ps_stdio_new(FILE *fh)
+{
+       return print_stream_ps_alloc(TRUE, fh);
 }
 
 output_fields_t* output_fields_new()