本文整理汇总了C++中BitstreamReader::free方法的典型用法代码示例。如果您正苦于以下问题:C++ BitstreamReader::free方法的具体用法?C++ BitstreamReader::free怎么用?C++ BitstreamReader::free使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitstreamReader
的用法示例。
在下文中一共展示了BitstreamReader::free方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: realloc
PyObject*
verifymodule_ogg(PyObject *dummy, PyObject *args) {
PyObject *file_obj;
BitstreamReader *bitstream;
int has_previous_header = 0;
struct ogg_header previous_header;
struct ogg_header header;
uint8_t *data_buffer = NULL;
int data_buffer_size = 0;
int i;
uint32_t checksum;
/*fixes a "may be used unitialized" warning*/
previous_header.bitstream_serial_number =
previous_header.page_sequence_number = 0;
if (!PyArg_ParseTuple(args, "O", &file_obj))
return NULL;
if (!PyFile_CheckExact(file_obj)) {
PyErr_SetString(PyExc_TypeError,
"first argument must be an actual file object");
return NULL;
} else {
bitstream = br_open(PyFile_AsFile(file_obj), BS_LITTLE_ENDIAN);
br_add_callback(bitstream, ogg_crc, &checksum);
}
if (!setjmp(*br_try(bitstream))) {
do {
checksum = 0;
if (verifymodule_read_ogg_header(bitstream, &header) == OK) {
if (data_buffer_size < header.segment_length_total) {
data_buffer = realloc(data_buffer,
header.segment_length_total);
data_buffer_size = header.segment_length_total;
}
if (fread(data_buffer,
sizeof(uint8_t),
header.segment_length_total,
bitstream->input.file) !=
header.segment_length_total) {
PyErr_SetString(PyExc_IOError, "I/O error reading stream");
goto error;
}
for (i = 0; i < header.segment_length_total; i++)
ogg_crc(data_buffer[i], &checksum);
if (header.checksum != checksum) {
PyErr_SetString(PyExc_ValueError,
"checksum mismatch in stream");
goto error;
}
/* printf("calculated checksum : 0x%8.8X\n", checksum); */
if (has_previous_header) {
if (header.bitstream_serial_number !=
previous_header.bitstream_serial_number) {
PyErr_SetString(PyExc_ValueError,
"differing serial numbers in stream");
goto error;
}
if (header.page_sequence_number !=
(previous_header.page_sequence_number + 1)) {
PyErr_SetString(PyExc_ValueError,
"page sequence number not incrementing");
goto error;
}
previous_header = header;
} else {
previous_header = header;
has_previous_header = 1;
}
} else {
goto error;
}
} while (!(header.type & 0x4));
} else {
PyErr_SetString(PyExc_IOError, "I/O error reading stream");
goto error;
}
br_etry(bitstream);
free(data_buffer);
bitstream->input.file = NULL;
bitstream->free(bitstream);
Py_INCREF(Py_None);
return Py_None;
error:
br_etry(bitstream);
if (data_buffer != NULL)
free(data_buffer);
bitstream->input.file = NULL;
bitstream->free(bitstream);
return NULL;
}