Commit 2ef8b7cb authored by Fabian Müller's avatar Fabian Müller
Browse files

Replace malloc/memset(0) with calloc

parent cee4a2ad
Loading
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1858,13 +1858,12 @@ static ivas_error initOnFirstGoodFrame(
        return error;
    }

    int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) );
    int16_t *zeroBuf = calloc( pcmFrameSize, sizeof( int16_t ) );
    if ( zeroBuf == NULL )
    {
        fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" );
        return IVAS_ERR_FAILED_ALLOC;
    }
    memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) );

    for ( int16_t i = 0; i < numInitialBadFrames; ++i )
    {
+3 −4
Original line number Diff line number Diff line
@@ -203,16 +203,15 @@ static void init_for_mime( BS_READER_HANDLE hBsReader )
static ivas_error init_for_format( BS_READER_HANDLE *phBsReader, BS_READER_FORMAT format )
{
    /* Allocate memory under handle and check if allocation successful */
    ( *phBsReader ) = (BS_READER_HANDLE) malloc( sizeof( struct BS_Reader ) );
    /* Initialize all struct members to NULL - supported functions
     * will be overwritten below in init_for_<format> */
    ( *phBsReader ) = (BS_READER_HANDLE) calloc( 1, sizeof( struct BS_Reader ) );
    if ( *phBsReader == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "could not allocate bitstream reader" );
    }

    /* Initialize all struct members to NULL - supported functions
     * will be overwritten below in init_for_<format> */
    BS_READER_HANDLE hBsReader = *phBsReader;
    memset( hBsReader, 0, sizeof( struct BS_Reader ) );

    /* Set function pointers to selected format */
    switch ( format )
+3 −4
Original line number Diff line number Diff line
@@ -156,16 +156,15 @@ static void init_for_mime( BS_WRITER_HANDLE hBsWriter )
static ivas_error init_for_format( BS_WRITER_HANDLE *phBsWriter, BS_WRITER_FORMAT format )
{
    /* Allocate memory under handle and check if allocation successful */
    ( *phBsWriter ) = (BS_WRITER_HANDLE) malloc( sizeof( struct BS_Writer ) );
    /* Initialize all struct members to NULL - supported functions
     * will be overwritten below in init_for_<format> */
    ( *phBsWriter ) = (BS_WRITER_HANDLE) calloc( 1, sizeof( struct BS_Writer ) );
    if ( *phBsWriter == NULL )
    {
        IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "could not allocate bitstream writer" );
    }

    /* Initialize all struct members to NULL - supported functions
     * will be overwritten below in init_for_<format> */
    BS_WRITER_HANDLE hBsWriter = *phBsWriter;
    memset( hBsWriter, 0, sizeof( struct BS_Writer ) );

    /* Set function pointers to selected format */
    switch ( format )
+0 −1
Original line number Diff line number Diff line
@@ -84,7 +84,6 @@ G192_ERROR G192_Reader_Open_filename(
    {
        return G192_MEMORY_ERROR;
    }
    memset( *phG192, 0, sizeof( struct __G192 ) );

    /* open file stream */
    ( *phG192 )->file = fopen( filename, "rb" );