Rename kmemalign to kmm_memalign and krealloc to kmm_realooc for consistency with other naming

This commit is contained in:
Gregory Nutt 2014-08-31 15:27:37 -06:00
parent 5a488475a8
commit 9cd1ddada4
16 changed files with 48 additions and 41 deletions

View file

@ -1,7 +1,7 @@
/****************************************************************************
* up_deviceimage.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -272,7 +272,7 @@ char *up_deviceimage(void)
if (strm.avail_out == 0)
{
int newbufsize = bufsize + 128*1024;
char *newbuffer = krealloc(pbuffer, newbufsize);
char *newbuffer = kmm_realloc(pbuffer, newbufsize);
if (!newbuffer)
{
kfree(pbuffer);
@ -292,7 +292,7 @@ char *up_deviceimage(void)
*/
int newbufsize = bufsize - strm.avail_out;
char *newbuffer = krealloc(pbuffer, newbufsize);
char *newbuffer = kmm_realloc(pbuffer, newbufsize);
if (!newbuffer)
{
kfree(pbuffer);

View file

@ -120,7 +120,7 @@ int elf_reallocbuffer(FAR struct elf_loadinfo_s *loadinfo, size_t increment)
/* And perform the reallocation */
buffer = krealloc((FAR void *)loadinfo->iobuffer, newsize);
buffer = kmm_realloc((FAR void *)loadinfo->iobuffer, newsize);
if (!buffer)
{
bdbg("Failed to reallocate the I/O buffer\n");

View file

@ -1501,7 +1501,7 @@ int usbmsc_bindlun(FAR void *handle, FAR const char *drvrpath,
else if (priv->iosize < geo.geo_sectorsize)
{
void *tmp;
tmp = (uint8_t*)krealloc(priv->iobuffer, geo.geo_sectorsize);
tmp = (uint8_t*)kmm_realloc(priv->iobuffer, geo.geo_sectorsize);
if (!tmp)
{
usbtrace(TRACE_CLSERROR(USBMSC_TRACEERR_REALLOCIOBUFFER), geo.geo_sectorsize);

View file

@ -1343,7 +1343,7 @@ static int cc3000_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
rv = priv->rx_buffer_max_len;
flags = irqsave();
priv->rx_buffer_max_len = *psize;
priv->rx_buffer.pbuffer = krealloc(priv->rx_buffer.pbuffer,*psize);
priv->rx_buffer.pbuffer = kmm_realloc(priv->rx_buffer.pbuffer,*psize);
irqrestore(flags);
DEBUGASSERT(priv->rx_buffer.pbuffer);
*psize = rv;

View file

@ -151,7 +151,7 @@ int munmap(FAR void *start, size_t length)
/* Get the offset from the beginning of the region and the actual number
* of bytes to "unmap". All mappings must extend to the end of the region.
* There is no support for free a block of memory but leaving a block of
* memory at the end. This is a consequence of using kurealloc() to
* memory at the end. This is a consequence of using umm_realloc() to
* simulate the unmapping.
*/
@ -195,7 +195,7 @@ int munmap(FAR void *start, size_t length)
else
{
newaddr = kurealloc(curr->addr, sizeof(struct fs_rammap_s) + length);
newaddr = umm_realloc(curr->addr, sizeof(struct fs_rammap_s) + length);
DEBUGASSERT(newaddr == (FAR void*)(curr->addr));
curr->length = length;
}

View file

@ -115,7 +115,8 @@ static inline void nxbe_pushrectangle(FAR struct nxbe_clipstack_s *stack,
int mxrects = stack->mxrects ? 2 * stack->mxrects : NX_INITIAL_STACKSIZE;
struct nxbe_cliprect_s *newstack;
newstack = krealloc(stack->stack, sizeof(struct nxbe_cliprect_s) * mxrects);
newstack = kmm_realloc(stack->stack,
sizeof(struct nxbe_cliprect_s) * mxrects);
if (!newstack)
{
gdbg("Failed to reallocate stack\n");

View file

@ -96,20 +96,18 @@ extern "C"
# define kumalloc(s) malloc(s)
# define kuzalloc(s) zalloc(s)
# define kurealloc(p,s) realloc(p,s)
# define kumemalign(a,s) memalign(a,s)
# define umm_realloc(p,s) realloc(p,s)
# define umm_memalign(a,s) memalign(a,s)
# define kufree(p) free(p)
#else
/* In the kernel-phase of the kernel build, the following are defined
* in userspace.h as macros that call into user-space via a header at
* the begining of the user-space blob.
/* In the kernel-phase of the protected build, the same macros are defined
* in userspace.h as macros. Those versions call into user-space via a
* header at the beginning of the user-space blob.
*/
# define kumalloc(s) umm_malloc(s)
# define kuzalloc(s) umm_zalloc(s)
# define kurealloc(p,s) umm_realloc(p,s)
# define kumemalign(a,s) umm_memalign(a,s)
# define kufree(p) umm_free(p)
#endif
@ -128,7 +126,7 @@ extern "C"
# define kmalloc(s) malloc(s)
# define kzalloc(s) zalloc(s)
# define krealloc(p,s) realloc(p,s)
# define kmm_realloc(p,s) realloc(p,s)
# define kmm_memalign(a,s) memalign(a,s)
# define kfree(p) free(p)
@ -145,7 +143,7 @@ extern "C"
# define kmalloc(s) umm_malloc(s)
# define kzalloc(s) umm_zalloc(s)
# define krealloc(p,s) umm_realloc(p,s)
# define kmm_realloc(p,s) umm_realloc(p,s)
# define kmm_memalign(a,s) umm_memalign(a,s)
# define kfree(p) umm_free(p)
@ -154,19 +152,9 @@ extern "C"
* and we can call them directly.
*/
void kmm_initialize(FAR void *heap_start, size_t heap_size);
void kmm_addregion(FAR void *heapstart, size_t heapsize);
int kmm_trysemaphore(void);
void kmm_givesemaphore(void);
FAR void *kmalloc(size_t size);
FAR void *kzalloc(size_t size);
FAR void *krealloc(FAR void *oldmem, size_t newsize);
void kfree(FAR void *mem);
#ifdef CONFIG_DEBUG
bool kmm_heapmember(FAR void *mem);
#endif
#endif
/* Functions defined in sched/sched_kfree.c **********************************/

View file

@ -284,6 +284,12 @@ void kmm_initialize(FAR void *heap_start, size_t heap_size);
void umm_addregion(FAR void *heapstart, size_t heapsize);
#endif
/* Functions contained in kmm_addregion.c ***********************************/
#ifdef CONFIG_MM_USER_HEAP
void kmm_addregion(FAR void *heapstart, size_t heapsize);
#endif
/* Functions contained in mm_sem.c ******************************************/
void mm_seminitialize(FAR struct mm_heap_s *heap);
@ -318,6 +324,12 @@ void mm_free(FAR struct mm_heap_s *heap, FAR void *mem);
FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
size_t size);
/* Functions contained in kmm_realloc.c *************************************/
#ifdef CONFIG_MM_KERNEL_HEAP
FAR void *kmm_realloc(FAR void *oldmem, size_t newsize);
#endif
/* Functions contained in mm_calloc.c ***************************************/
FAR void *mm_calloc(FAR struct mm_heap_s *heap, size_t n, size_t elem_size);
@ -343,6 +355,12 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
FAR void *kmm_memalign(size_t alignment, size_t size);
#endif
/* Functions contained in kmm_heapmember.c **********************************/
#if defined(CONFIG_MM_KERNEL_HEAP) && defined(CONFIG_DEBUG)
bool kmm_heapmember(FAR void *mem);
#endif
/* Functions contained in mm_brkaddr.c **************************************/
FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region);

View file

@ -88,15 +88,15 @@
# 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_realloc(p,s) kmm_realloc(p,s)
# define lib_memalign(p,s) kmm_memalign(p,s)
# define lib_free(p) kfree(p)
/* User-accessible allocations */
# define lib_umalloc(s) kumalloc(s)
# define lib_uzalloc(s) kuzalloc(s)
# define lib_urealloc(p,s) kurealloc(p,s)
# define lib_urealloc(p,s) umm_realloc(p,s)
# define lib_ufree(p) kufree(p)
#else

View file

@ -70,15 +70,15 @@
# 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_realloc(p,s) kmm_realloc(p,s)
# define lib_memalign(p,s) kmm_memalign(p,s)
# define lib_free(p) kfree(p)
/* User-accessible allocations */
# define lib_umalloc(s) kumalloc(s)
# define lib_uzalloc(s) kuzalloc(s)
# define lib_urealloc(p,s) kurealloc(p,s)
# define lib_urealloc(p,s) umm_realloc(p,s)
# define lib_ufree(p) kufree(p)
#else

View file

@ -57,7 +57,7 @@
# include <nuttx/kmalloc.h>
# define lib_malloc(s) kmalloc(s)
# define lib_zalloc(s) kzalloc(s)
# define lib_realloc(p,s) krealloc(p,s)
# define lib_realloc(p,s) kmm_realloc(p,s)
# define lib_free(p) kfree(p)
#else
# include <cstdlib>

View file

@ -56,7 +56,7 @@
****************************************************************************/
/****************************************************************************
* Name: krealloc
* Name: kmm_realloc
*
* Description:
* Re-allocate memory in the kernel heap.
@ -70,7 +70,7 @@
*
****************************************************************************/
FAR void *krealloc(FAR void *oldmem, size_t newsize)
FAR void *kmm_realloc(FAR void *oldmem, size_t newsize)
{
return mm_realloc(&g_kmmheap, oldmem, newsize);
}

View file

@ -58,7 +58,7 @@
****************************************************************************/
/****************************************************************************
* Name: krealloc
* Name: realloc
*
* Description:
* Re-allocate memory in the user heap.

View file

@ -161,7 +161,7 @@ int setenv(FAR const char *name, FAR const char *value, int overwrite)
if (group->tg_envp)
{
newsize = group->tg_envsize + varlen;
newenvp = (FAR char *)kurealloc(group->tg_envp, newsize);
newenvp = (FAR char *)umm_realloc(group->tg_envp, newsize);
if (!newenvp)
{
ret = ENOMEM;

View file

@ -98,7 +98,7 @@ int unsetenv(FAR const char *name)
/* Reallocate the new environment buffer */
newsize = group->tg_envsize;
newenvp = (FAR char *)kurealloc(group->tg_envp, newsize);
newenvp = (FAR char *)umm_realloc(group->tg_envp, newsize);
if (!newenvp)
{
set_errno(ENOMEM);

View file

@ -113,7 +113,7 @@ static inline int group_addmember(FAR struct task_group_s *group, pid_t pid)
}
newmembers = (FAR pid_t *)
krealloc(group->tg_members, sizeof(pid_t) * newmax);
kmm_realloc(group->tg_members, sizeof(pid_t) * newmax);
if (!newmembers)
{