zero allocated class memory

This commit is contained in:
Josh Coalson 2002-08-03 22:05:11 +00:00
parent 189267013e
commit a7e4fb2629
4 changed files with 17 additions and 2 deletions

View File

@ -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;

View File

@ -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_);

View File

@ -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_);

View File

@ -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_);