Is it ok to call free() for memory allocated by heap_caps_calloc_prefer()?

axellin
Posts: 205
Joined: Mon Sep 17, 2018 9:09 am

Is it ok to call free() for memory allocated by heap_caps_calloc_prefer()?

Postby axellin » Tue Dec 17, 2024 3:04 am

If I have called
buf = heap_caps_calloc_prefer(8, 2048, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
Is it ok to free buf by calling free(buf)?
Or I need to call heap_caps_free() instead?

What's the difference of calling free() v.s. heap_caps_free()?

Sprite
Espressif staff
Espressif staff
Posts: 10593
Joined: Thu Nov 26, 2015 4:08 am

Re: Is it ok to call free() for memory allocated by heap_caps_calloc_prefer()?

Postby Sprite » Tue Dec 17, 2024 4:31 am

Yes. I think free() actually is an alias for heap_caps_free() (as malloc()'ed memory also is allocated using a heap_caps_malloc call)

Who is online

Users browsing this forum: Amazon [Bot], PetalBot and 8 guests