mm/: Coding style clean-up
Run tools/nxstyle against all C files under mm/ and correct coding standard violations.
This commit is contained in:
parent
3381ecb913
commit
1382ea5447
@ -132,9 +132,9 @@ static FAR struct iob_qentry_s *iob_allocwait_qentry(void)
|
|||||||
ret = nxsem_wait_uninterruptible(&g_qentry_sem);
|
ret = nxsem_wait_uninterruptible(&g_qentry_sem);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* When we wake up from wait successfully, an I/O buffer chain container was
|
/* When we wake up from wait successfully, an I/O buffer chain
|
||||||
* freed and we hold a count for one IOB. Unless somehting
|
* container was freed and we hold a count for one IOB. Unless
|
||||||
* failed, we should have an IOB waiting for us in the
|
* something failed, we should have an IOB waiting for us in the
|
||||||
* committed list.
|
* committed list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ int iob_clone(FAR struct iob_s *iob1, FAR struct iob_s *iob2, bool throttled,
|
|||||||
* transferred?
|
* transferred?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (offset2 >= CONFIG_IOB_BUFSIZE && iob1 != NULL)
|
if (offset2 >= CONFIG_IOB_BUFSIZE && iob1 != NULL)
|
||||||
{
|
{
|
||||||
FAR struct iob_s *next;
|
FAR struct iob_s *next;
|
||||||
|
|
||||||
|
@ -250,5 +250,6 @@ int iob_trycopyin(FAR struct iob_s *iob, FAR const uint8_t *src,
|
|||||||
unsigned int len, unsigned int offset, bool throttled,
|
unsigned int len, unsigned int offset, bool throttled,
|
||||||
enum iob_user_e consumerid)
|
enum iob_user_e consumerid)
|
||||||
{
|
{
|
||||||
return iob_copyin_internal(iob, src, len, offset, throttled, false, consumerid);
|
return iob_copyin_internal(iob, src, len, offset, throttled, false,
|
||||||
|
consumerid);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,8 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob,
|
|||||||
|
|
||||||
#if CONFIG_IOB_THROTTLE > 0
|
#if CONFIG_IOB_THROTTLE > 0
|
||||||
nxsem_post(&g_throttle_sem);
|
nxsem_post(&g_throttle_sem);
|
||||||
DEBUGASSERT(g_throttle_sem.semcount <= (CONFIG_IOB_NBUFFERS - CONFIG_IOB_THROTTLE));
|
DEBUGASSERT(g_throttle_sem.semcount <=
|
||||||
|
(CONFIG_IOB_NBUFFERS - CONFIG_IOB_THROTTLE));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_IOB_NOTIFIER
|
#ifdef CONFIG_IOB_NOTIFIER
|
||||||
|
@ -78,6 +78,7 @@ int iob_navail(bool throttled)
|
|||||||
ret -= CONFIG_IOB_THROTTLE;
|
ret -= CONFIG_IOB_THROTTLE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -127,15 +127,15 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob,
|
|||||||
next->io_offset += ncopy;
|
next->io_offset += ncopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Have we consumed all of the data in the next entry? */
|
/* Have we consumed all of the data in the next entry? */
|
||||||
|
|
||||||
if (next->io_len <= 0)
|
if (next->io_len <= 0)
|
||||||
{
|
{
|
||||||
/* Yes.. free the next entry in I/O buffer chain */
|
/* Yes.. free the next entry in I/O buffer chain */
|
||||||
|
|
||||||
next = iob_free(next, producerid);
|
next = iob_free(next, producerid);
|
||||||
iob->io_flink = next;
|
iob->io_flink = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up to pack the next entry in the chain */
|
/* Set up to pack the next entry in the chain */
|
||||||
|
@ -107,7 +107,6 @@ void iob_stats_onfree(enum iob_user_e producerid)
|
|||||||
/* Increment the global statistic as well */
|
/* Increment the global statistic as well */
|
||||||
|
|
||||||
g_iobuserstats[IOBUSER_GLOBAL].totalproduced++;
|
g_iobuserstats[IOBUSER_GLOBAL].totalproduced++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -115,6 +115,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
buffer1[i] = (uint8_t)(i & 0xff);
|
buffer1[i] = (uint8_t)(i & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buffer2, 0xff, 4096);
|
memset(buffer2, 0xff, 4096);
|
||||||
|
|
||||||
iob_copyin(iob, buffer2, 47, 0, false, IOBUSER_UNITTEST);
|
iob_copyin(iob, buffer2, 47, 0, false, IOBUSER_UNITTEST);
|
||||||
|
@ -213,7 +213,8 @@ FAR void *gran_alloc(GRAN_HANDLE handle, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We know that the first free bit is now within the lower 4 bits
|
/* We know that the first free bit is now within the lower 4 bits
|
||||||
* of 'curr'. Check if we have the allocation at this bit position.
|
* of 'curr'. Check if we have the allocation at this bit
|
||||||
|
* position.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
else if ((curr & mask) == 0)
|
else if ((curr & mask) == 0)
|
||||||
|
@ -86,5 +86,4 @@ void gran_leave_critical(FAR struct gran_s *priv)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* CONFIG_GRAN */
|
#endif /* CONFIG_GRAN */
|
||||||
|
@ -115,9 +115,9 @@ void gran_free(GRAN_HANDLE handle, FAR void *memory, size_t size)
|
|||||||
/* Clear bits in the second GAT entry */
|
/* Clear bits in the second GAT entry */
|
||||||
|
|
||||||
gatmask = 0xffffffff >> (32 - ngranules);
|
gatmask = 0xffffffff >> (32 - ngranules);
|
||||||
DEBUGASSERT((priv->gat[gatidx+1] & gatmask) == gatmask);
|
DEBUGASSERT((priv->gat[gatidx + 1] & gatmask) == gatmask);
|
||||||
|
|
||||||
priv->gat[gatidx+1] &= ~gatmask;
|
priv->gat[gatidx + 1] &= ~gatmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the case where where all of the granules came from one entry */
|
/* Handle the case where where all of the granules came from one entry */
|
||||||
|
@ -124,11 +124,11 @@ static const struct nibble_info_s g_4bit_info[16] =
|
|||||||
|
|
||||||
static const struct nibble_info_s *g_info_table[5] =
|
static const struct nibble_info_s *g_info_table[5] =
|
||||||
{
|
{
|
||||||
g_0bit_info,
|
g_0bit_info,
|
||||||
g_1bit_info,
|
g_1bit_info,
|
||||||
g_2bit_info,
|
g_2bit_info,
|
||||||
g_3bit_info,
|
g_3bit_info,
|
||||||
g_4bit_info
|
g_4bit_info
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -312,7 +312,7 @@ static void gran_byte_info(uint8_t value, FAR struct valinfo_s *info,
|
|||||||
|
|
||||||
/* Handle special cases */
|
/* Handle special cases */
|
||||||
|
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
/* All free */
|
/* All free */
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ static void gran_hword_info(uint16_t value, FAR struct valinfo_s *info,
|
|||||||
|
|
||||||
/* Handle special cases */
|
/* Handle special cases */
|
||||||
|
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
/* All free */
|
/* All free */
|
||||||
|
|
||||||
|
@ -101,9 +101,9 @@ void gran_mark_allocated(FAR struct gran_s *priv, uintptr_t alloc,
|
|||||||
/* Mark bits in the second GAT entry */
|
/* Mark bits in the second GAT entry */
|
||||||
|
|
||||||
gatmask = 0xffffffff >> (32 - ngranules);
|
gatmask = 0xffffffff >> (32 - ngranules);
|
||||||
DEBUGASSERT((priv->gat[gatidx+1] & gatmask) == 0);
|
DEBUGASSERT((priv->gat[gatidx + 1] & gatmask) == 0);
|
||||||
|
|
||||||
priv->gat[gatidx+1] |= gatmask;
|
priv->gat[gatidx + 1] |= gatmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle the case where where all of the granules come from one entry */
|
/* Handle the case where where all of the granules come from one entry */
|
||||||
|
@ -51,7 +51,9 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Configuration ************************************************************/
|
/* Configuration ************************************************************/
|
||||||
|
|
||||||
/* CONFIG_MM_PGALLOC - Enable page allocator support
|
/* CONFIG_MM_PGALLOC - Enable page allocator support
|
||||||
* CONFIG_MM_PGSIZE - The page size. Must be one of {1024, 2048,
|
* CONFIG_MM_PGSIZE - The page size. Must be one of {1024, 2048,
|
||||||
* 4096, 8192, or 16384}. This is easily extensible, but only those
|
* 4096, 8192, or 16384}. This is easily extensible, but only those
|
||||||
|
@ -112,7 +112,8 @@ void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size,
|
|||||||
|
|
||||||
/* Get and initialize the new terminal node in the heap */
|
/* Get and initialize the new terminal node in the heap */
|
||||||
|
|
||||||
newnode = (FAR struct mm_allocnode_s *)(blockend - SIZEOF_MM_ALLOCNODE);
|
newnode = (FAR struct mm_allocnode_s *)
|
||||||
|
(blockend - SIZEOF_MM_ALLOCNODE);
|
||||||
newnode->size = SIZEOF_MM_ALLOCNODE;
|
newnode->size = SIZEOF_MM_ALLOCNODE;
|
||||||
newnode->preceding = oldnode->size | MM_ALLOC_BIT;
|
newnode->preceding = oldnode->size | MM_ALLOC_BIT;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
|||||||
* crazy.
|
* crazy.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEBUGASSERT(heapsize <= MMSIZE_MAX+1);
|
DEBUGASSERT(heapsize <= MMSIZE_MAX + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Adjust the provide heap start and size so that they are both aligned
|
/* Adjust the provide heap start and size so that they are both aligned
|
||||||
@ -96,7 +96,7 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
|||||||
heapend = MM_ALIGN_DOWN((uintptr_t)heapstart + (uintptr_t)heapsize);
|
heapend = MM_ALIGN_DOWN((uintptr_t)heapstart + (uintptr_t)heapsize);
|
||||||
heapsize = heapend - heapbase;
|
heapsize = heapend - heapbase;
|
||||||
|
|
||||||
minfo("Region %d: base=%p size=%u\n", IDX+1, heapstart, heapsize);
|
minfo("Region %d: base=%p size=%u\n", IDX + 1, heapstart, heapsize);
|
||||||
|
|
||||||
/* Add the size of this region to the total size of the heap */
|
/* Add the size of this region to the total size of the heap */
|
||||||
|
|
||||||
@ -114,11 +114,13 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
|||||||
heap->mm_heapstart[IDX]->size = SIZEOF_MM_ALLOCNODE;
|
heap->mm_heapstart[IDX]->size = SIZEOF_MM_ALLOCNODE;
|
||||||
heap->mm_heapstart[IDX]->preceding = MM_ALLOC_BIT;
|
heap->mm_heapstart[IDX]->preceding = MM_ALLOC_BIT;
|
||||||
|
|
||||||
node = (FAR struct mm_freenode_s *)(heapbase + SIZEOF_MM_ALLOCNODE);
|
node = (FAR struct mm_freenode_s *)
|
||||||
node->size = heapsize - 2*SIZEOF_MM_ALLOCNODE;
|
(heapbase + SIZEOF_MM_ALLOCNODE);
|
||||||
node->preceding = SIZEOF_MM_ALLOCNODE;
|
node->size = heapsize - 2*SIZEOF_MM_ALLOCNODE;
|
||||||
|
node->preceding = SIZEOF_MM_ALLOCNODE;
|
||||||
|
|
||||||
heap->mm_heapend[IDX] = (FAR struct mm_allocnode_s *)(heapend - SIZEOF_MM_ALLOCNODE);
|
heap->mm_heapend[IDX] = (FAR struct mm_allocnode_s *)
|
||||||
|
(heapend - SIZEOF_MM_ALLOCNODE);
|
||||||
heap->mm_heapend[IDX]->size = SIZEOF_MM_ALLOCNODE;
|
heap->mm_heapend[IDX]->size = SIZEOF_MM_ALLOCNODE;
|
||||||
heap->mm_heapend[IDX]->preceding = node->size | MM_ALLOC_BIT;
|
heap->mm_heapend[IDX]->preceding = node->size | MM_ALLOC_BIT;
|
||||||
|
|
||||||
@ -182,8 +184,8 @@ void mm_initialize(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
|||||||
memset(heap->mm_nodelist, 0, sizeof(struct mm_freenode_s) * MM_NNODES);
|
memset(heap->mm_nodelist, 0, sizeof(struct mm_freenode_s) * MM_NNODES);
|
||||||
for (i = 1; i < MM_NNODES; i++)
|
for (i = 1; i < MM_NNODES; i++)
|
||||||
{
|
{
|
||||||
heap->mm_nodelist[i-1].flink = &heap->mm_nodelist[i];
|
heap->mm_nodelist[i - 1].flink = &heap->mm_nodelist[i];
|
||||||
heap->mm_nodelist[i].blink = &heap->mm_nodelist[i-1];
|
heap->mm_nodelist[i].blink = &heap->mm_nodelist[i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the malloc semaphore to one (to support one-at-
|
/* Initialize the malloc semaphore to one (to support one-at-
|
||||||
|
@ -100,7 +100,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
|
|||||||
|
|
||||||
if (alignsize >= MM_MAX_CHUNK)
|
if (alignsize >= MM_MAX_CHUNK)
|
||||||
{
|
{
|
||||||
ndx = MM_NNODES-1;
|
ndx = MM_NNODES - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size)
|
|||||||
#ifdef CONFIG_MM_FILL_ALLOCATIONS
|
#ifdef CONFIG_MM_FILL_ALLOCATIONS
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
memset(ret, 0xAA, alignsize - SIZEOF_MM_ALLOCNODE);
|
memset(ret, 0xaa, alignsize - SIZEOF_MM_ALLOCNODE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -135,7 +135,8 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
|
|||||||
|
|
||||||
DEBUGASSERT(alignedchunk >= rawchunk + 8);
|
DEBUGASSERT(alignedchunk >= rawchunk + 8);
|
||||||
|
|
||||||
newnode = (FAR struct mm_allocnode_s *)(alignedchunk - SIZEOF_MM_ALLOCNODE);
|
newnode = (FAR struct mm_allocnode_s *)
|
||||||
|
(alignedchunk - SIZEOF_MM_ALLOCNODE);
|
||||||
|
|
||||||
/* Preceding size is full size of the new 'node,' including
|
/* Preceding size is full size of the new 'node,' including
|
||||||
* SIZEOF_MM_ALLOCNODE
|
* SIZEOF_MM_ALLOCNODE
|
||||||
@ -154,7 +155,8 @@ FAR void *mm_memalign(FAR struct mm_heap_s *heap, size_t alignment,
|
|||||||
if (precedingsize < SIZEOF_MM_FREENODE)
|
if (precedingsize < SIZEOF_MM_FREENODE)
|
||||||
{
|
{
|
||||||
alignedchunk += alignment;
|
alignedchunk += alignment;
|
||||||
newnode = (FAR struct mm_allocnode_s *)(alignedchunk - SIZEOF_MM_ALLOCNODE);
|
newnode = (FAR struct mm_allocnode_s *)
|
||||||
|
(alignedchunk - SIZEOF_MM_ALLOCNODE);
|
||||||
precedingsize = (size_t)newnode - (size_t)node;
|
precedingsize = (size_t)newnode - (size_t)node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
|||||||
|
|
||||||
/* Map the memory chunk into an allocated node structure */
|
/* Map the memory chunk into an allocated node structure */
|
||||||
|
|
||||||
oldnode = (FAR struct mm_allocnode_s *)((FAR char *)oldmem - SIZEOF_MM_ALLOCNODE);
|
oldnode = (FAR struct mm_allocnode_s *)
|
||||||
|
((FAR char *)oldmem - SIZEOF_MM_ALLOCNODE);
|
||||||
|
|
||||||
/* We need to hold the MM semaphore while we muck with the nodelist. */
|
/* We need to hold the MM semaphore while we muck with the nodelist. */
|
||||||
|
|
||||||
@ -139,13 +140,15 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
|||||||
* best decision
|
* best decision
|
||||||
*/
|
*/
|
||||||
|
|
||||||
next = (FAR struct mm_freenode_s *)((FAR char *)oldnode + oldnode->size);
|
next = (FAR struct mm_freenode_s *)
|
||||||
|
((FAR char *)oldnode + oldnode->size);
|
||||||
if ((next->preceding & MM_ALLOC_BIT) == 0)
|
if ((next->preceding & MM_ALLOC_BIT) == 0)
|
||||||
{
|
{
|
||||||
nextsize = next->size;
|
nextsize = next->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = (FAR struct mm_freenode_s *)((FAR char *)oldnode - (oldnode->preceding & ~MM_ALLOC_BIT));
|
prev = (FAR struct mm_freenode_s *)
|
||||||
|
((FAR char *)oldnode - (oldnode->preceding & ~MM_ALLOC_BIT));
|
||||||
if ((prev->preceding & MM_ALLOC_BIT) == 0)
|
if ((prev->preceding & MM_ALLOC_BIT) == 0)
|
||||||
{
|
{
|
||||||
prevsize = prev->size;
|
prevsize = prev->size;
|
||||||
@ -233,7 +236,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
|||||||
|
|
||||||
/* Extend the node into the previous free chunk */
|
/* Extend the node into the previous free chunk */
|
||||||
|
|
||||||
newnode = (FAR struct mm_allocnode_s *)((FAR char *)oldnode - takeprev);
|
newnode = (FAR struct mm_allocnode_s *)
|
||||||
|
((FAR char *)oldnode - takeprev);
|
||||||
|
|
||||||
/* Did we consume the entire preceding chunk? */
|
/* Did we consume the entire preceding chunk? */
|
||||||
|
|
||||||
@ -246,7 +250,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
|||||||
prev->size -= takeprev;
|
prev->size -= takeprev;
|
||||||
newnode->size = oldsize + takeprev;
|
newnode->size = oldsize + takeprev;
|
||||||
newnode->preceding = prev->size | MM_ALLOC_BIT;
|
newnode->preceding = prev->size | MM_ALLOC_BIT;
|
||||||
next->preceding = newnode->size | (next->preceding & MM_ALLOC_BIT);
|
next->preceding = newnode->size |
|
||||||
|
(next->preceding & MM_ALLOC_BIT);
|
||||||
|
|
||||||
/* Return the previous free node to the nodelist (with the new size) */
|
/* Return the previous free node to the nodelist (with the new size) */
|
||||||
|
|
||||||
@ -258,7 +263,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
|||||||
|
|
||||||
newnode->size += oldsize;
|
newnode->size += oldsize;
|
||||||
newnode->preceding |= MM_ALLOC_BIT;
|
newnode->preceding |= MM_ALLOC_BIT;
|
||||||
next->preceding = newnode->size | (next->preceding & MM_ALLOC_BIT);
|
next->preceding = newnode->size |
|
||||||
|
(next->preceding & MM_ALLOC_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we want to return newnode */
|
/* Now we want to return newnode */
|
||||||
@ -301,7 +307,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
|||||||
/* Extend the node into the next chunk */
|
/* Extend the node into the next chunk */
|
||||||
|
|
||||||
oldnode->size = oldsize + takenext;
|
oldnode->size = oldsize + takenext;
|
||||||
newnode = (FAR struct mm_freenode_s *)((FAR char *)oldnode + oldnode->size);
|
newnode = (FAR struct mm_freenode_s *)
|
||||||
|
((FAR char *)oldnode + oldnode->size);
|
||||||
|
|
||||||
/* Did we consume the entire preceding chunk? */
|
/* Did we consume the entire preceding chunk? */
|
||||||
|
|
||||||
@ -313,7 +320,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
|||||||
|
|
||||||
newnode->size = nextsize - takenext;
|
newnode->size = nextsize - takenext;
|
||||||
newnode->preceding = oldnode->size;
|
newnode->preceding = oldnode->size;
|
||||||
andbeyond->preceding = newnode->size | (andbeyond->preceding & MM_ALLOC_BIT);
|
andbeyond->preceding = newnode->size |
|
||||||
|
(andbeyond->preceding & MM_ALLOC_BIT);
|
||||||
|
|
||||||
/* Add the new free node to the nodelist (with the new size) */
|
/* Add the new free node to the nodelist (with the new size) */
|
||||||
|
|
||||||
@ -323,7 +331,8 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
|
|||||||
{
|
{
|
||||||
/* Yes, just update some pointers. */
|
/* Yes, just update some pointers. */
|
||||||
|
|
||||||
andbeyond->preceding = oldnode->size | (andbeyond->preceding & MM_ALLOC_BIT);
|
andbeyond->preceding = oldnode->size |
|
||||||
|
(andbeyond->preceding & MM_ALLOC_BIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,10 +193,10 @@ int mm_trysemaphore(FAR struct mm_heap_s *heap)
|
|||||||
|
|
||||||
ret = _SEM_TRYWAIT(&heap->mm_semaphore);
|
ret = _SEM_TRYWAIT(&heap->mm_semaphore);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
_SEM_GETERROR(ret);
|
_SEM_GETERROR(ret);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have it. Claim the heap for the current task and return */
|
/* We have it. Claim the heap for the current task and return */
|
||||||
|
|
||||||
|
@ -106,7 +106,8 @@ void mm_shrinkchunk(FAR struct mm_heap_s *heap,
|
|||||||
newnode->size = next->size + node->size - size;
|
newnode->size = next->size + node->size - size;
|
||||||
newnode->preceding = size;
|
newnode->preceding = size;
|
||||||
node->size = size;
|
node->size = size;
|
||||||
andbeyond->preceding = newnode->size | (andbeyond->preceding & MM_ALLOC_BIT);
|
andbeyond->preceding = newnode->size |
|
||||||
|
(andbeyond->preceding & MM_ALLOC_BIT);
|
||||||
|
|
||||||
/* Add the new node to the freenodelist */
|
/* Add the new node to the freenodelist */
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ int mm_size2ndx(size_t size)
|
|||||||
|
|
||||||
if (size >= MM_MAX_CHUNK)
|
if (size >= MM_MAX_CHUNK)
|
||||||
{
|
{
|
||||||
return MM_NNODES-1;
|
return MM_NNODES - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size >>= MM_MIN_SHIFT;
|
size >>= MM_MIN_SHIFT;
|
||||||
|
@ -66,3 +66,7 @@
|
|||||||
|
|
||||||
struct mm_heap_s g_mmheap;
|
struct mm_heap_s g_mmheap;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user