[MPlayer-cvslog] r35318 - trunk/libmpdemux/demux_ts.c

reimar subversion at mplayerhq.hu
Wed Oct 31 21:56:41 CET 2012


Author: reimar
Date: Wed Oct 31 21:56:41 2012
New Revision: 35318

Log:
Remove some incorrect usages of realloc_struct.

Modified:
   trunk/libmpdemux/demux_ts.c

Modified: trunk/libmpdemux/demux_ts.c
==============================================================================
--- trunk/libmpdemux/demux_ts.c	Wed Oct 31 21:44:16 2012	(r35317)
+++ trunk/libmpdemux/demux_ts.c	Wed Oct 31 21:56:41 2012	(r35318)
@@ -1754,7 +1754,6 @@ static int parse_pat(ts_priv_t * priv, i
 	unsigned char *base;
 	int entries, i;
 	uint16_t progid;
-	struct pat_progs_t *tmp;
 	ts_section_t *section;
 
 	section = &(priv->pat.section);
@@ -1788,14 +1787,14 @@ static int parse_pat(ts_priv_t * priv, i
 
 		if((idx = prog_idx_in_pat(priv, progid)) == -1)
 		{
-			int sz = sizeof(struct pat_progs_t) * (priv->pat.progs_cnt+1);
-			tmp = realloc_struct(priv->pat.progs, priv->pat.progs_cnt+1, sizeof(struct pat_progs_t));
-			if(tmp == NULL)
+			priv->pat.progs = realloc_struct(priv->pat.progs, priv->pat.progs_cnt+1, sizeof(struct pat_progs_t));
+			if(!priv->pat.progs)
 			{
+				int sz = sizeof(struct pat_progs_t) * (priv->pat.progs_cnt+1);
+				priv->pat.progs_cnt = 0;
 				mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PAT: COULDN'T REALLOC %d bytes, NEXT\n", sz);
 				break;
 			}
-			priv->pat.progs = tmp;
 			idx = priv->pat.progs_cnt;
 			priv->pat.progs_cnt++;
 		}
@@ -2047,7 +2046,7 @@ static uint16_t parse_mp4_es_descriptor(
 {
 	int i = 0, j = 0, k, found;
 	uint8_t flag;
-	mp4_es_descr_t es, *target_es = NULL, *tmp;
+	mp4_es_descr_t es, *target_es = NULL;
 
 	mp_msg(MSGT_DEMUX, MSGL_V, "PARSE_MP4ES: len=%d\n", len);
 	memset(&es, 0, sizeof(mp4_es_descr_t));
@@ -2082,13 +2081,13 @@ static uint16_t parse_mp4_es_descriptor(
 
 			if(! found)
 			{
-				tmp = realloc_struct(pmt->mp4es, pmt->mp4es_cnt+1, sizeof(mp4_es_descr_t));
-				if(tmp == NULL)
+				pmt->mp4es = realloc_struct(pmt->mp4es, pmt->mp4es_cnt+1, sizeof(mp4_es_descr_t));
+				if(!pmt->mp4es)
 				{
+					pmt->mp4es_cnt = 0;
 					fprintf(stderr, "CAN'T REALLOC MP4_ES_DESCR\n");
 					continue;
 				}
-				pmt->mp4es = tmp;
 				target_es = &(pmt->mp4es[pmt->mp4es_cnt]);
 				pmt->mp4es_cnt++;
 			}
@@ -2423,8 +2422,6 @@ static int parse_pmt(ts_priv_t * priv, u
 	int32_t idx, es_count, section_bytes;
 	uint8_t m=0;
 	int skip;
-	pmt_t *tmp;
-	struct pmt_es_t *tmp_es;
 	ts_section_t *section;
 	ES_stream_t *tss;
 	int i;
@@ -2433,14 +2430,14 @@ static int parse_pmt(ts_priv_t * priv, u
 
 	if(idx == -1)
 	{
-		int sz = (priv->pmt_cnt + 1) * sizeof(pmt_t);
-		tmp = realloc_struct(priv->pmt, priv->pmt_cnt + 1, sizeof(pmt_t));
-		if(tmp == NULL)
+		priv->pmt = realloc_struct(priv->pmt, priv->pmt_cnt + 1, sizeof(pmt_t));
+		if(!priv->pmt)
 		{
+			int sz = (priv->pmt_cnt + 1) * sizeof(pmt_t);
+			priv->pmt_cnt = 0;
 			mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT: COULDN'T REALLOC %d bytes, NEXT\n", sz);
 			return 0;
 		}
-		priv->pmt = tmp;
 		idx = priv->pmt_cnt;
 		memset(&(priv->pmt[idx]), 0, sizeof(pmt_t));
 		priv->pmt_cnt++;
@@ -2494,14 +2491,14 @@ static int parse_pmt(ts_priv_t * priv, u
 		idx = es_pid_in_pmt(pmt, es_pid);
 		if(idx == -1)
 		{
-			int sz = sizeof(struct pmt_es_t) * (pmt->es_cnt + 1);
-			tmp_es = realloc_struct(pmt->es, pmt->es_cnt + 1, sizeof(struct pmt_es_t));
-			if(tmp_es == NULL)
+			pmt->es = realloc_struct(pmt->es, pmt->es_cnt + 1, sizeof(struct pmt_es_t));
+			if(!pmt->es)
 			{
+				int sz = sizeof(struct pmt_es_t) * (pmt->es_cnt + 1);
+				pmt->es_cnt = 0;
 				mp_msg(MSGT_DEMUX, MSGL_ERR, "PARSE_PMT, COULDN'T ALLOCATE %d bytes for PMT_ES\n", sz);
 				continue;
 			}
-			pmt->es = tmp_es;
 			idx = pmt->es_cnt;
 			memset(&(pmt->es[idx]), 0, sizeof(struct pmt_es_t));
 			pmt->es_cnt++;


More information about the MPlayer-cvslog mailing list