Initialize global pointers in examples.
authorRalph Giles <giles@thaumas.net>
Mon, 28 Nov 2016 14:06:56 +0000 (14:06 +0000)
committerRalph Giles <giles@thaumas.net>
Mon, 28 Nov 2016 21:28:31 +0000 (13:28 -0800)
Global pointers are initialized to zero in C, but not in C++.

Add an explicit initializer to reduce confusion and avoid
bugs when the example code is copied into C++ applications.

Based on a patch by Alex Houghton <houghton1411@aol.com>.

examples/dump_video.c
examples/player_example.c
examples/png2theora.c
examples/tiff2theora.c

index 9b4b401..a596cb9 100644 (file)
@@ -77,8 +77,8 @@ ogg_stream_state  vo;
 ogg_stream_state  to;
 th_info           ti;
 th_comment        tc;
-th_setup_info    *ts;
-th_dec_ctx       *td;
+th_setup_info    *ts=NULL;
+th_dec_ctx       *td=NULL;
 
 int              theora_p=0;
 int              theora_processing_headers;
index 913692e..18fbdd1 100644 (file)
@@ -93,8 +93,8 @@ ogg_stream_state vo;
 ogg_stream_state to;
 th_info      ti;
 th_comment   tc;
-th_dec_ctx       *td;
-th_setup_info    *ts;
+th_dec_ctx       *td = NULL;
+th_setup_info    *ts = NULL;
 vorbis_info      vi;
 vorbis_dsp_state vd;
 vorbis_block     vb;
index c740ad8..7a8334c 100644 (file)
@@ -63,10 +63,10 @@ static ogg_stream_state ogg_os;
 static ogg_packet op;
 static ogg_page og;
 
-static th_enc_ctx      *td;
+static th_enc_ctx      *td = NULL;
 static th_info          ti;
 
-static char *input_filter;
+static char *input_filter = NULL;
 
 const char *optstring = "o:hv:\4:\2:V:s:S:f:F:ck:d:\1\2\3\4\5\6";
 struct option options [] = {
index 0297884..685f940 100644 (file)
@@ -63,10 +63,10 @@ static ogg_stream_state ogg_os;
 static ogg_packet op;
 static ogg_page og;
 
-static th_enc_ctx      *td;
+static th_enc_ctx      *td = NULL;
 static th_info          ti;
 
-static char *input_filter;
+static char *input_filter = NULL;
 
 const char *optstring = "o:hv:\4:\2:V:s:S:f:F:ck:d:\1\2\3\4\5\6";
 struct option options [] = {