Skip to content

Commit 51ec75f

Browse files
committed
[update]format memheap.c
1 parent 4d21325 commit 51ec75f

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

src/memheap.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,31 @@
4242
rt_inline void rt_memheap_setname(struct rt_memheap_item *item, const char *name)
4343
{
4444
int index;
45-
rt_uint8_t* ptr;
45+
rt_uint8_t *ptr;
4646

47-
ptr = (rt_uint8_t*)&(item->next_free);
48-
for (index = 0; index < sizeof(void*); index ++)
47+
ptr = (rt_uint8_t *) & (item->next_free);
48+
for (index = 0; index < sizeof(void *); index ++)
4949
{
5050
if (name[index] == '\0') break;
5151
ptr[index] = name[index];
5252
}
5353
if (name[index] == '\0') ptr[index] = '\0';
54-
else
54+
else
5555
{
56-
ptr = (rt_uint8_t*)&(item->prev_free);
57-
for (index = 0; index < sizeof(void*) && (index + sizeof(void*))< RT_NAME_MAX; index ++)
56+
ptr = (rt_uint8_t *) & (item->prev_free);
57+
for (index = 0; index < sizeof(void *) && (index + sizeof(void *)) < RT_NAME_MAX; index ++)
5858
{
59-
if (name[sizeof(void*) + index] == '\0') break;
60-
ptr[index] = name[sizeof(void*) + index];
59+
if (name[sizeof(void *) + index] == '\0') break;
60+
ptr[index] = name[sizeof(void *) + index];
6161
}
6262

63-
if (name[sizeof(void*) + index] == '\0') ptr[index] = '\0';
63+
if (name[sizeof(void *) + index] == '\0') ptr[index] = '\0';
6464
}
6565
}
6666

67-
void rt_mem_set_tag(void* ptr, const char* name)
67+
void rt_mem_set_tag(void *ptr, const char *name)
6868
{
69-
struct rt_memheap_item* item;
69+
struct rt_memheap_item *item;
7070

7171
if (ptr && name)
7272
{
@@ -668,17 +668,17 @@ void rt_memheap_free(void *ptr)
668668
RTM_EXPORT(rt_memheap_free);
669669

670670
#ifdef RT_USING_FINSH
671-
static void _memheap_dump_tag(struct rt_memheap_item* item)
671+
static void _memheap_dump_tag(struct rt_memheap_item *item)
672672
{
673-
rt_uint8_t name[2 * sizeof(void*)];
674-
rt_uint8_t* ptr;
673+
rt_uint8_t name[2 * sizeof(void *)];
674+
rt_uint8_t *ptr;
675675

676-
ptr = (rt_uint8_t*)&(item->next_free);
677-
rt_memcpy(name, ptr, sizeof(void*));
678-
ptr = (rt_uint8_t*)&(item->prev_free);
679-
rt_memcpy(&name[sizeof(void*)], ptr, sizeof(void*));
676+
ptr = (rt_uint8_t *) & (item->next_free);
677+
rt_memcpy(name, ptr, sizeof(void *));
678+
ptr = (rt_uint8_t *) & (item->prev_free);
679+
rt_memcpy(&name[sizeof(void *)], ptr, sizeof(void *));
680680

681-
rt_kprintf("%.*s", 2 * sizeof(void*), name);
681+
rt_kprintf("%.*s", 2 * sizeof(void *), name);
682682
}
683683

684684
int rt_memheap_dump(struct rt_memheap *heap)
@@ -688,15 +688,15 @@ int rt_memheap_dump(struct rt_memheap *heap)
688688
if (heap == RT_NULL) return 0;
689689
RT_ASSERT(rt_object_get_type(&heap->parent) == RT_Object_Class_MemHeap);
690690

691-
rt_kprintf("\n[%.*s] [0x%08x - 0x%08x]->\n", RT_NAME_MAX, heap->parent.name,
692-
(rt_ubase_t)heap->start_addr, (rt_ubase_t)heap->start_addr + heap->pool_size);
691+
rt_kprintf("\n[%.*s] [0x%08x - 0x%08x]->\n", RT_NAME_MAX, heap->parent.name,
692+
(rt_ubase_t)heap->start_addr, (rt_ubase_t)heap->start_addr + heap->pool_size);
693693
rt_kprintf("------------------------------\n");
694694

695695
/* lock memheap */
696696
rt_sem_take(&(heap->lock), RT_WAITING_FOREVER);
697697
item = heap->block_list;
698698

699-
end = (struct rt_memheap_item *) ((rt_uint8_t *)heap->start_addr + heap->pool_size - RT_MEMHEAP_SIZE);
699+
end = (struct rt_memheap_item *)((rt_uint8_t *)heap->start_addr + heap->pool_size - RT_MEMHEAP_SIZE);
700700

701701
/* for each memory block */
702702
while ((rt_ubase_t)item < ((rt_ubase_t)end))
@@ -732,13 +732,13 @@ int memheaptrace(void)
732732
int index;
733733
extern int list_memheap(void);
734734

735-
heaps = (struct rt_memheap**)rt_malloc(sizeof(struct rt_memheap*) * count);
735+
heaps = (struct rt_memheap **)rt_malloc(sizeof(struct rt_memheap *) * count);
736736
if (heaps == RT_NULL) return 0;
737737

738738
list_memheap();
739739

740740
rt_kprintf("memheap header size: %d\n", RT_MEMHEAP_SIZE);
741-
count = rt_object_get_pointers(RT_Object_Class_MemHeap, (rt_object_t*)heaps, count);
741+
count = rt_object_get_pointers(RT_Object_Class_MemHeap, (rt_object_t *)heaps, count);
742742
for (index = 0; index < count; index++)
743743
{
744744
rt_memheap_dump(heaps[index]);
@@ -968,15 +968,15 @@ void dump_used_memheap(struct rt_memheap *mh)
968968
{
969969
/* dump information */
970970
rt_kprintf("[0x%08x - %d - %c%c%c%c] used\n", header_ptr, block_size,
971-
header_ptr->owner_thread_name[0], header_ptr->owner_thread_name[1],
972-
header_ptr->owner_thread_name[2], header_ptr->owner_thread_name[3]);
971+
header_ptr->owner_thread_name[0], header_ptr->owner_thread_name[1],
972+
header_ptr->owner_thread_name[2], header_ptr->owner_thread_name[3]);
973973
}
974974
else
975975
{
976976
/* dump information */
977977
rt_kprintf("[0x%08x - %d - %c%c%c%c] free\n", header_ptr, block_size,
978-
header_ptr->owner_thread_name[0], header_ptr->owner_thread_name[1],
979-
header_ptr->owner_thread_name[2], header_ptr->owner_thread_name[3]);
978+
header_ptr->owner_thread_name[0], header_ptr->owner_thread_name[1],
979+
header_ptr->owner_thread_name[2], header_ptr->owner_thread_name[3]);
980980
}
981981

982982
/* move to next used memory block */

0 commit comments

Comments
 (0)