Commit a7e4fb26 authored by Josh Coalson's avatar Josh Coalson
Browse files

zero allocated class memory

parent 18926701
......@@ -254,6 +254,7 @@ FLAC__BitBuffer *FLAC__bitbuffer_new()
FLAC__BitBuffer *bb = (FLAC__BitBuffer*)malloc(sizeof(FLAC__BitBuffer));
if(0 != bb) {
memset(bb, 0, sizeof(FLAC__BitBuffer));
bb->buffer = 0;
bb->capacity = 0;
bb->blurbs = bb->bits = bb->total_bits = 0;
......
......@@ -99,20 +99,24 @@ FLAC__FileDecoder *FLAC__file_decoder_new()
if(decoder == 0) {
return 0;
}
memset(decoder, 0, sizeof(FLAC__FileDecoder));
decoder->protected_ = (FLAC__FileDecoderProtected*)malloc(sizeof(FLAC__FileDecoderProtected));
if(decoder->protected_ == 0) {
free(decoder);
return 0;
}
memset(decoder->protected_, 0, sizeof(FLAC__FileDecoderProtected));
decoder->private_ = (FLAC__FileDecoderPrivate*)malloc(sizeof(FLAC__FileDecoderPrivate));
if(decoder->private_ == 0) {
free(decoder->protected_);
free(decoder);
return 0;
}
memset(decoder->private_, 0, sizeof(FLAC__FileDecoderPrivate));
decoder->private_->seekable_stream_decoder = FLAC__seekable_stream_decoder_new();
if(0 == decoder->private_->seekable_stream_decoder) {
free(decoder->private_);
free(decoder->protected_);
......
......@@ -125,20 +125,24 @@ FLAC__SeekableStreamDecoder *FLAC__seekable_stream_decoder_new()
if(decoder == 0) {
return 0;
}
memset(decoder, 0, sizeof(FLAC__SeekableStreamDecoder));
decoder->protected_ = (FLAC__SeekableStreamDecoderProtected*)malloc(sizeof(FLAC__SeekableStreamDecoderProtected));
if(decoder->protected_ == 0) {
free(decoder);
return 0;
}
memset(decoder->protected_, 0, sizeof(FLAC__SeekableStreamDecoderProtected));
decoder->private_ = (FLAC__SeekableStreamDecoderPrivate*)malloc(sizeof(FLAC__SeekableStreamDecoderPrivate));
if(decoder->private_ == 0) {
free(decoder->protected_);
free(decoder);
return 0;
}
memset(decoder->private_, 0, sizeof(FLAC__SeekableStreamDecoderPrivate));
decoder->private_->stream_decoder = FLAC__stream_decoder_new();
if(0 == decoder->private_->stream_decoder) {
free(decoder->private_);
free(decoder->protected_);
......
......@@ -146,17 +146,23 @@ FLAC__StreamDecoder *FLAC__stream_decoder_new()
if(decoder == 0) {
return 0;
}
memset(decoder, 0, sizeof(FLAC__StreamDecoder));
decoder->protected_ = (FLAC__StreamDecoderProtected*)malloc(sizeof(FLAC__StreamDecoderProtected));
if(decoder->protected_ == 0) {
free(decoder);
return 0;
}
memset(decoder->protected_, 0, sizeof(FLAC__StreamDecoderProtected));
decoder->private_ = (FLAC__StreamDecoderPrivate*)malloc(sizeof(FLAC__StreamDecoderPrivate));
if(decoder->private_ == 0) {
free(decoder->protected_);
free(decoder);
return 0;
}
memset(decoder->private_, 0, sizeof(FLAC__StreamDecoderPrivate));
decoder->private_->input = FLAC__bitbuffer_new();
if(decoder->private_->input == 0) {
free(decoder->private_);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment