*/
#include "libavutil/crc.h"
+#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio.h"
#include <stdarg.h>
int ret;
/* packetized write: output the header */
- buf1[0] = (buf_size >> 24);
- buf1[1] = (buf_size >> 16);
- buf1[2] = (buf_size >> 8);
- buf1[3] = (buf_size);
+ AV_WB32(buf1, buf_size);
ret= dyn_buf_write(opaque, buf1, 4);
if(ret < 0)
return ret;
static int url_open_dyn_buf_internal(ByteIOContext **s, int max_packet_size)
{
DynBuffer *d;
- int io_buffer_size, ret;
-
- if (max_packet_size)
- io_buffer_size = max_packet_size;
- else
- io_buffer_size = 1024;
+ int ret;
+ unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size)
return -1;
- d = av_malloc(sizeof(DynBuffer) + io_buffer_size);
+ d = av_mallocz(sizeof(DynBuffer) + io_buffer_size);
if (!d)
- return -1;
+ return AVERROR(ENOMEM);
*s = av_mallocz(sizeof(ByteIOContext));
if(!*s) {
av_free(d);
return AVERROR(ENOMEM);
}
d->io_buffer_size = io_buffer_size;
- d->buffer = NULL;
- d->pos = 0;
- d->size = 0;
- d->allocated_size = 0;
ret = init_put_byte(*s, d->io_buffer, io_buffer_size,
1, d, NULL,
max_packet_size ? dyn_packet_buf_write : dyn_buf_write,