cleanup: calloc some stuff

This commit is contained in:
bnnm 2024-08-18 23:10:45 +02:00
parent 09746b5253
commit d04e8d571a
10 changed files with 32 additions and 32 deletions

View File

@ -21,19 +21,19 @@ struct VGMSTREAM_TAGS {
char targetpath[VGMSTREAM_TAGS_LINE_MAX];
/* tag section for filename (see comments below) */
int section_found;
bool section_found;
off_t section_start;
off_t section_end;
off_t offset;
/* commands */
int autotrack_on;
int autotrack_written;
bool autotrack_on;
bool autotrack_written;
int track_count;
int exact_match;
bool exact_match;
int autoalbum_on;
int autoalbum_written;
bool autoalbum_on;
bool autoalbum_written;
};
@ -50,7 +50,7 @@ static void tags_clean(VGMSTREAM_TAGS* tag) {
}
VGMSTREAM_TAGS* vgmstream_tags_init(const char* *tag_key, const char* *tag_val) {
VGMSTREAM_TAGS* tags = malloc(sizeof(VGMSTREAM_TAGS));
VGMSTREAM_TAGS* tags = calloc(1, sizeof(VGMSTREAM_TAGS));
if (!tags) goto fail;
*tag_key = tags->key;
@ -102,7 +102,7 @@ int vgmstream_tags_next_tag(VGMSTREAM_TAGS* tags, STREAMFILE* tagfile) {
if (tags->autotrack_on && !tags->autotrack_written) {
sprintf(tags->key, "%s", "TRACK");
sprintf(tags->val, "%i", tags->track_count);
tags->autotrack_written = 1;
tags->autotrack_written = true;
return 1;
}
@ -119,7 +119,7 @@ int vgmstream_tags_next_tag(VGMSTREAM_TAGS* tags, STREAMFILE* tagfile) {
sprintf(tags->key, "%s", "ALBUM");
sprintf(tags->val, "%s", path+1);
tags->autoalbum_written = 1;
tags->autoalbum_written = true;
return 1;
}
@ -150,13 +150,13 @@ int vgmstream_tags_next_tag(VGMSTREAM_TAGS* tags, STREAMFILE* tagfile) {
if (ok == 1 || ok == 2) {
int key_len = n2 - n1;
if (strncasecmp(tags->key, "AUTOTRACK", key_len) == 0) {
tags->autotrack_on = 1;
tags->autotrack_on = true;
}
else if (strncasecmp(tags->key, "AUTOALBUM", key_len) == 0) {
tags->autoalbum_on = 1;
tags->autoalbum_on = true;
}
else if (strncasecmp(tags->key, "EXACTMATCH", key_len) == 0) {
tags->exact_match = 1;
tags->exact_match = true;
}
continue; /* not an actual tag */
@ -210,7 +210,7 @@ int vgmstream_tags_next_tag(VGMSTREAM_TAGS* tags, STREAMFILE* tagfile) {
if (filename_found) {
/* section ok, start would be set before this (or be 0) */
tags->section_end = tags->offset;
tags->section_found = 1;
tags->section_found = true;
tags->offset = tags->section_start;
}
else {

View File

@ -489,7 +489,7 @@ static ffmpeg_codec_data* init_ffmpeg_mp4_custom(STREAMFILE* sf, mp4_custom_t* m
if (buf_len > 0x100000) /* ??? */
goto fail;
buf = malloc(buf_len);
buf = calloc(1, buf_len);
if (!buf) goto fail;
bytes = make_m4a_header(buf, buf_len, mp4, sf, type); /* before changing stream_offset/size */

View File

@ -320,7 +320,7 @@ circus_handle_t* circus_init(off_t start, uint8_t codec, uint8_t flags) {
circus_handle_t* handle = NULL;
int scale_index, err;
handle = malloc(sizeof(circus_handle_t));
handle = calloc(1, sizeof(circus_handle_t));
if (!handle) goto fail;
handle->start = start;

View File

@ -146,7 +146,7 @@ static void THuff_SetPositionData(THuff* self, THuffPositionData* s);
//------------------------------------------------------------------------------
//create
static THuff* THuff_Create(TStream* buf) {
THuff* self = malloc(sizeof(THuff));
THuff* self = calloc(1, sizeof(THuff));
if (!self) return NULL;
//define stream
@ -558,7 +558,7 @@ struct TCompressWaveData {
//-----------------------------------------------------------
//create
TCompressWaveData* TCompressWaveData_Create(void) {
TCompressWaveData* self = malloc(sizeof(TCompressWaveData));
TCompressWaveData* self = calloc(1, sizeof(TCompressWaveData));
if (!self) return NULL;
#if 0
self->Data = NULL;

View File

@ -80,7 +80,7 @@ static int is_use_runlength(NWAData* nwa) {
NWAData* nwalib_open(STREAMFILE* sf) {
uint8_t header[0x2c] = {0};
int i;
NWAData* const nwa = malloc(sizeof(NWAData));
NWAData* const nwa = calloc(1, sizeof(NWAData));
if (!nwa) goto fail;
//NWAData::ReadHeader

View File

@ -1140,7 +1140,7 @@ tac_handle_t* tac_init(const uint8_t* buf, int buf_size) {
if (buf_size < TAC_BLOCK_SIZE)
goto fail;
handle = malloc(sizeof(tac_handle_t));
handle = calloc(1, sizeof(tac_handle_t));
if (!handle) goto fail;
{

View File

@ -319,7 +319,7 @@ static int preload_acb_waveform(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload Waveform=%i\n", *p_rows);
acb->Waveform = malloc(*p_rows * sizeof(Waveform_t));
acb->Waveform = calloc(1, *p_rows * sizeof(Waveform_t));
if (!acb->Waveform) goto fail;
c_Id = utf_get_column(Table, "Id");
@ -410,7 +410,7 @@ static int preload_acb_synth(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload Synth=%i\n", *p_rows);
acb->Synth = malloc(*p_rows * sizeof(Synth_t));
acb->Synth = calloc(1, *p_rows * sizeof(Synth_t));
if (!acb->Synth) goto fail;
c_Type = utf_get_column(Table, "Type");
@ -613,7 +613,7 @@ static int preload_acb_trackcommand(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload TrackEvent/Command=%i\n", *p_rows);
acb->TrackCommand = malloc(*p_rows * sizeof(TrackCommand_t));
acb->TrackCommand = calloc(1, *p_rows * sizeof(TrackCommand_t));
if (!acb->TrackCommand) goto fail;
c_Command = utf_get_column(Table, "Command");
@ -665,7 +665,7 @@ static int preload_acb_track(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload Track=%i\n", *p_rows);
acb->Track = malloc(*p_rows * sizeof(Track_t));
acb->Track = calloc(1, *p_rows * sizeof(Track_t));
if (!acb->Track) goto fail;
c_EventIndex = utf_get_column(Table, "EventIndex");
@ -724,7 +724,7 @@ static int preload_acb_sequence(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload Sequence=%i\n", *p_rows);
acb->Sequence = malloc(*p_rows * sizeof(Sequence_t));
acb->Sequence = calloc(1, *p_rows * sizeof(Sequence_t));
if (!acb->Sequence) goto fail;
c_NumTracks = utf_get_column(Table, "NumTracks");
@ -826,7 +826,7 @@ static int preload_acb_block(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload Block=%i\n", *p_rows);
acb->Block = malloc(*p_rows * sizeof(Block_t));
acb->Block = calloc(1, *p_rows * sizeof(Block_t));
if (!acb->Block) goto fail;
c_NumTracks = utf_get_column(Table, "NumTracks");
@ -891,7 +891,7 @@ static int preload_acb_blocksequence(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload BlockSequence=%i\n", *p_rows);
acb->BlockSequence = malloc(*p_rows * sizeof(BlockSequence_t));
acb->BlockSequence = calloc(1, *p_rows * sizeof(BlockSequence_t));
if (!acb->BlockSequence) goto fail;
c_NumTracks = utf_get_column(Table, "NumTracks");
@ -972,7 +972,7 @@ static int preload_acb_cue(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload Cue=%i\n", *p_rows);
acb->Cue = malloc(*p_rows * sizeof(Cue_t));
acb->Cue = calloc(1, *p_rows * sizeof(Cue_t));
if (!acb->Cue) goto fail;
c_ReferenceType = utf_get_column(Table, "ReferenceType");
@ -1064,7 +1064,7 @@ static int preload_acb_cuename(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload CueName=%i\n", *p_rows);
acb->CueName = malloc(*p_rows * sizeof(CueName_t));
acb->CueName = calloc(1, *p_rows * sizeof(CueName_t));
if (!acb->CueName) goto fail;
c_CueIndex = utf_get_column(Table, "CueIndex");
@ -1118,7 +1118,7 @@ static int preload_acb_waveformextensiondata(acb_header* acb) {
return 1;
//;VGM_LOG("acb: preload WaveformExtensionData=%i\n", *p_rows);
acb->WaveformExtensionData = malloc(*p_rows * sizeof(WaveformExtensionData_t));
acb->WaveformExtensionData = calloc(1, *p_rows * sizeof(WaveformExtensionData_t));
if (!acb->WaveformExtensionData) goto fail;
c_LoopStart = utf_get_column(Table, "LoopStart");

View File

@ -60,7 +60,7 @@ static void close_bar(BARSTREAMFILE *streamFile) {
/*static*/ STREAMFILE *wrap_bar_STREAMFILE(STREAMFILE *file) {
BARSTREAMFILE *streamfile = malloc(sizeof(BARSTREAMFILE));
BARSTREAMFILE *streamfile = calloc(1, sizeof(BARSTREAMFILE));
if (!streamfile)
return NULL;

View File

@ -244,7 +244,7 @@ blowfish_ctx* blowfish_init_ecb(uint8_t* key, int32_t key_len) {
uint32_t xl, xr;
uint8_t tmpkey[18*4];
blowfish_ctx* ctx = malloc(sizeof(blowfish_ctx));
blowfish_ctx* ctx = calloc(1, sizeof(blowfish_ctx));
if (!ctx) return NULL;

View File

@ -145,7 +145,7 @@ utf_context* utf_open(STREAMFILE* sf, uint32_t table_offset, int* p_rows, const
utf->table_name = utf->string_table + utf->name_offset;
utf->schema = malloc(utf->columns * sizeof(struct utf_column_t));
utf->schema = calloc(1, utf->columns * sizeof(struct utf_column_t));
if (!utf->schema) goto fail;
for (i = 0; i < utf->columns; i++) {