Revision 8bea72f7

View differences:

libavformat/aviobuf.c
1136 1136
static int url_open_dyn_buf_internal(AVIOContext **s, int max_packet_size)
1137 1137
{
1138 1138
    DynBuffer *d;
1139
    int ret;
1140 1139
    unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
1141 1140

  
1142 1141
    if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size)
......
1144 1143
    d = av_mallocz(sizeof(DynBuffer) + io_buffer_size);
1145 1144
    if (!d)
1146 1145
        return AVERROR(ENOMEM);
1147
    *s = av_mallocz(sizeof(AVIOContext));
1146
    d->io_buffer_size = io_buffer_size;
1147
    *s = avio_alloc_context(d->io_buffer, d->io_buffer_size, 1, d, NULL,
1148
                            max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
1149
                            max_packet_size ? NULL : dyn_buf_seek);
1148 1150
    if(!*s) {
1149 1151
        av_free(d);
1150 1152
        return AVERROR(ENOMEM);
1151 1153
    }
1152
    d->io_buffer_size = io_buffer_size;
1153
    ret = ffio_init_context(*s, d->io_buffer, io_buffer_size,
1154
                        1, d, NULL,
1155
                        max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
1156
                        max_packet_size ? NULL : dyn_buf_seek);
1157
    if (ret == 0) {
1158
        (*s)->max_packet_size = max_packet_size;
1159
    } else {
1160
        av_free(d);
1161
        av_freep(s);
1162
    }
1163
    return ret;
1154
    (*s)->max_packet_size = max_packet_size;
1155
    return 0;
1164 1156
}
1165 1157

  
1166 1158
int avio_open_dyn_buf(AVIOContext **s)

Also available in: Unified diff