diff --git a/pwrapic/test/demo_main.c b/pwrapic/test/demo_main.c index c4b23ac859dc337851ba6f21908997350b61f5fd..7af21628ea0f6e5fe58509a506611fdcb722fdb1 100644 --- a/pwrapic/test/demo_main.c +++ b/pwrapic/test/demo_main.c @@ -236,12 +236,16 @@ static void TEST_PWR_CPU_SetAndGetFreqGov(void) } // PWR_CPU_GetFreq PWR_CPU_SetFreq - static void TEST_PWR_CPU_SetAndGetCurFreq(void) { int ret = 0; uint32_t len = TEST_CORE_NUM; - PWR_CPU_CurFreq curFreq[len]; + PWR_CPU_CurFreq *curFreq = (PWR_CPU_CurFreq *)malloc(len * sizeof(PWR_CPU_CurFreq)); + if (!curFreq) { + printf("Memory allocation failed.\n"); + return; + } + bzero(curFreq, len * sizeof(PWR_CPU_CurFreq)); int spec = 0; ret = PWR_CPU_GetFreq(curFreq, &len, spec); @@ -249,17 +253,21 @@ static void TEST_PWR_CPU_SetAndGetCurFreq(void) for (int i = 0; i < len; i++) { printf("Freq Policy %d curFreq:%lf\n", curFreq[i].policyId, curFreq[i].curFreq); } + len = TEST_CORE_NUM; bzero(curFreq, len * sizeof(PWR_CPU_CurFreq)); curFreq[0].policyId = 0; curFreq[0].curFreq = TEST_FREQ; ret = PWR_CPU_SetFreq(curFreq, 1); printf("PWR_CPU_SetFreq ret: %d\n", ret); + len = 1; spec = 1; curFreq[0].curFreq = 0; ret = PWR_CPU_GetFreq(curFreq, &len, spec); printf("Freq Policy %d curFreq:%lf\n", curFreq[0].policyId, curFreq[0].curFreq); + + free(curFreq); // Don't forget to free the allocated memory. } static void TEST_PWR_CPU_DmaSetAndGetLatency(void)