diff options
author | wm4 <wm4@nowhere> | 2014-06-13 02:02:30 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-06-13 02:02:30 +0200 |
commit | 7e7ff4b0ea745a60437b9a2641044761bd2ca002 (patch) | |
tree | 21fffd19a5aa955bb2173e54968fe2594d9b04da /demux/demux.c | |
parent | ee2e91dce15e1971ce092a6bc81eae08a9caa9d1 (diff) | |
download | mpv-7e7ff4b0ea745a60437b9a2641044761bd2ca002.tar.bz2 mpv-7e7ff4b0ea745a60437b9a2641044761bd2ca002.tar.xz |
demux: simplify packet resizing
Actually we don't need to resize packets; we just need to make them
shorter.
Diffstat (limited to 'demux/demux.c')
-rw-r--r-- | demux/demux.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/demux/demux.c b/demux/demux.c index b9236832ce..acdee69d4b 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -167,21 +167,11 @@ struct demux_packet *new_demux_packet_from(void *data, size_t len) return dp; } -void resize_demux_packet(struct demux_packet *dp, size_t len) +void demux_packet_shorten(struct demux_packet *dp, size_t len) { - if (len > 1000000000) { - fprintf(stderr, "Attempt to realloc demux packet over 1 GB!\n"); - abort(); - } - assert(dp->allocation); - dp->buffer = realloc(dp->buffer, len + FF_INPUT_BUFFER_PADDING_SIZE); - if (!dp->buffer) { - fprintf(stderr, "Memory allocation failure!\n"); - abort(); - } - memset(dp->buffer + len, 0, FF_INPUT_BUFFER_PADDING_SIZE); + assert(len <= dp->len); dp->len = len; - dp->allocation = dp->buffer; + memset(dp->buffer + dp->len, 0, FF_INPUT_BUFFER_PADDING_SIZE); } void free_demux_packet(struct demux_packet *dp) |