# HG changeset patch # User reimar # Date 1351717001 0 # Node ID b4d9b416a8f1b10032d91908f8596763b37ed2c1 # Parent 425467b5be98ccbbf52e2c0e27485b26e029810f Remove some incorrect usages of realloc_struct. diff -r 425467b5be98 -r b4d9b416a8f1 libmpdemux/demux_ts.c --- a/libmpdemux/demux_ts.c Wed Oct 31 20:44:16 2012 +0000 +++ b/libmpdemux/demux_ts.c Wed Oct 31 20:56:41 2012 +0000 @@ -1754,7 +1754,6 @@ 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 @@ 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ 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++;