libc/audio/lib_buffer.c must must correct allocation for execution domain
This commit is contained in:
parent
4b998d84a7
commit
4ad7f73f54
|
@ -49,10 +49,11 @@
|
|||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/audio/audio.h>
|
||||
#include <nuttx/usb/audio.h>
|
||||
|
||||
#include "lib_internal.h"
|
||||
|
||||
#if defined(CONFIG_AUDIO)
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -113,7 +114,7 @@ static void apb_semtake(FAR struct ap_buffer_s *apb)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
int apb_alloc(FAR struct audio_buf_desc_s * bufdesc)
|
||||
int apb_alloc(FAR struct audio_buf_desc_s *bufdesc)
|
||||
{
|
||||
uint32_t bufsize;
|
||||
int ret;
|
||||
|
@ -124,13 +125,15 @@ int apb_alloc(FAR struct audio_buf_desc_s * bufdesc)
|
|||
/* Perform a user mode allocation */
|
||||
|
||||
bufsize = sizeof(struct ap_buffer_s) + bufdesc->numbytes;
|
||||
pBuf = kumalloc(bufsize);
|
||||
pBuf = lib_umalloc(bufsize);
|
||||
*bufdesc->u.ppBuffer = pBuf;
|
||||
|
||||
/* Test if the allocation was successful or not */
|
||||
|
||||
if (*bufdesc->u.ppBuffer == NULL)
|
||||
{
|
||||
ret = -ENOMEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Populate the buffer contents */
|
||||
|
@ -180,10 +183,10 @@ void apb_free(FAR struct ap_buffer_s *apb)
|
|||
refcount = apb->crefs--;
|
||||
apb_semgive(apb);
|
||||
|
||||
if (refcount == 1)
|
||||
if (refcount <= 1)
|
||||
{
|
||||
auddbg("Freeing %p\n", apb);
|
||||
kufree(apb);
|
||||
lib_ufree(apb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,16 +82,39 @@
|
|||
|
||||
#if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__)
|
||||
# include <nuttx/kmalloc.h>
|
||||
|
||||
/* Domain-specific allocations */
|
||||
|
||||
# define lib_malloc(s) kmalloc(s)
|
||||
# define lib_zalloc(s) kzalloc(s)
|
||||
# define lib_realloc(p,s) krealloc(p,s)
|
||||
# define lib_memalign(p,s) krealloc(p,s)
|
||||
# define lib_free(p) kfree(p)
|
||||
|
||||
/* User-accesssible allocations */
|
||||
|
||||
# define lib_umalloc(s) kumalloc(s)
|
||||
# define lib_uzalloc(s) kuzalloc(s)
|
||||
# define lib_urealloc(p,s) kurealloc(p,s)
|
||||
# define lib_ufree(p) kufree(p)
|
||||
|
||||
#else
|
||||
# include <stdlib.h>
|
||||
|
||||
/* Domain-specific allocations */
|
||||
|
||||
# define lib_malloc(s) malloc(s)
|
||||
# define lib_zalloc(s) zalloc(s)
|
||||
# define lib_realloc(p,s) realloc(p,s)
|
||||
# define lib_free(p) free(p)
|
||||
|
||||
/* User-accesssible allocations */
|
||||
|
||||
# define lib_umalloc(s) malloc(s)
|
||||
# define lib_uzalloc(s) zalloc(s)
|
||||
# define lib_urealloc(p,s) realloc(p,s)
|
||||
# define lib_ufree(p) free(p)
|
||||
|
||||
#endif
|
||||
|
||||
#define LIB_BUFLEN_UNKNOWN INT_MAX
|
||||
|
|
Loading…
Reference in New Issue