This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP-EXP430FR5994: msp_sinusoid_q15() in dsplib from msp430ware_3_80_09_03 appears to have a memory leak on the LEA stack

Part Number: MSP-EXP430FR5994

I was stepping through the vector_ex1_max_q15 example to try and understand how the stack of the LEA is used.

In the msp_sinusoid_q15() function prior to the the following allocations LEACNF2 (LEA stack pointer value) was 0x00000F00:

    /* Allocate coefficients in LEA memory and set parameters */
    df1Params.length = params->length;
    df1Params.coeffs = (msp_biquad_df1_q15_coeffs *)msp_lea_allocMemory(sizeof(msp_biquad_df1_q15_coeffs)/sizeof(uint32_t));
    df1Params.states = (msp_biquad_df1_q15_states *)msp_lea_allocMemory(sizeof(msp_biquad_df1_q15_coeffs)/sizeof(uint32_t));

At the end of the msp_sinusoid_q15() function after execution of the following LEACNF2 was 0x00000EFF (i.e. not the same as the initial value prior to the allocations):

    /* Free coefficients and states from LEA memory */

I.e. the msp_sinusoid_q15() function seems to cause a "memory leak" on the LEA stack.

I think there is a typo on the following memory allocation:

    df1Params.states = (msp_biquad_df1_q15_states *)msp_lea_allocMemory(sizeof(msp_biquad_df1_q15_coeffs)/sizeof(uint32_t));

Where the sizeof(msp_biquad_df1_q15_coeffs) should be sizeof(msp_biquad_df1_q15_states):

    df1Params.states = (msp_biquad_df1_q15_states *)msp_lea_allocMemory(sizeof(msp_biquad_df1_q15_states)/sizeof(uint32_t));

**Attention** This is a public forum