Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions components/libc/compilers/armlibc/syscall_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Date Author Notes
* 2014-08-03 bernard Add file header
* 2021-11-13 Meco Man implement no-heap warning
* 2025-11-1 MaChengyang Add detailed function comments
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Date format is inconsistent with other entries. Should use 'YYYY-MM-DD' format (2025-11-01) instead of 'YYYY-MM-D' (2025-11-1). / 日期格式与其他条目不一致。应使用 'YYYY-MM-DD' 格式(2025-11-01)而不是 'YYYY-MM-D'(2025-11-1)。

Suggested change
* 2025-11-1 MaChengyang Add detailed function comments
* 2025-11-01 MaChengyang Add detailed function comments

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected at the end of the line. Remove the extra spaces after 'comments'. / 检测到行尾有多余的空格。请删除 'comments' 之后的空格。

Suggested change
* 2025-11-1 MaChengyang Add detailed function comments
* 2025-11-1 MaChengyang Add detailed function comments

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议不要更新这种列表了,不理解为啥 RTT 还在用这种很古老的方式。现在有 git,在git 的 commit 里加上你的签名就好了,可以看一下其他用 git的开源项目里的加签名的方式 ”Signed-off-by: Your name "。

*/

#include <rtthread.h>
Expand All @@ -27,6 +28,22 @@
#pragma import(__use_no_heap)
#endif /* __CC_ARM */

/**
* @brief Allocate memory block
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two spaces between '@brief' and the description. According to Doxygen conventions, only one space should be used. This inconsistency appears in all added function comments (lines 32, 59, 94, 122). / '@brief' 和描述之间有两个空格。根据 Doxygen 惯例,应该只使用一个空格。这个不一致出现在所有添加的函数注释中(第 32、59、94、122 行)。

Copilot uses AI. Check for mistakes.
*
* Allocates a block of size bytes of memory, returning a pointer to the
* beginning of the block. The content of the newly allocated block of
* memory is not initialized, remaining with indeterminate values.
*
* @param n the size of the memory block, in bytes.
*
* @return On success, a pointer to the memory block allocated by the function.
* If the system is configured without heap (RT_USING_HEAP is not defined),
* the function will assert and return RT_NULL.
*
* @note The returned pointer is always suitably aligned for any built-in type.
* @see rt_malloc
*/
Comment thread
ChengyangMa marked this conversation as resolved.
void *malloc(size_t n)
{
#ifdef RT_USING_HEAP
Expand All @@ -38,6 +55,30 @@ void *malloc(size_t n)
}
RTM_EXPORT(malloc);

/**
* @brief Reallocate memory block
*
* Changes the size of the memory block pointed to by rmem.
* The function may move the memory block to a new location
* (whose address is returned by the function).
* The content of the memory block is preserved up to the
* lesser of the new and old sizes, even if the block is
* moved to a new location. If the new size is larger,
* the value of the newly allocated portion is indeterminate.
*
* @param rmem pointer to a memory block previously allocated with
* malloc, calloc or realloc to be reallocated.
* If this is RT_NULL, a new block is allocated and
* a pointer to it is returned by the function.
* @param newsize new size for the memory block, in bytes.
*
* @return A pointer to the reallocated memory block, which may be either
* the same as the rmem pointer or a new location.
* If the system is configured without heap (RT_USING_HEAP is not defined),
* the function will assert and return RT_NULL.
*
* @see rt_realloc
*/
void *realloc(void *rmem, size_t newsize)
{
#ifdef RT_USING_HEAP
Expand All @@ -49,6 +90,23 @@ void *realloc(void *rmem, size_t newsize)
}
RTM_EXPORT(realloc);

/**
* @brief Allocate and zero-initialize array
*
* Allocates a block of memory for an array of nelem elements, each of them
* elsize bytes long, and initializes all its bits to zero.
* The effective result is the allocation of a zero-initialized memory block
* of (nelem*elsize) bytes.
*
* @param nelem number of elements to allocate.
* @param elsize size of each element.
*
* @return On success, a pointer to the memory block allocated by the function.
* If the system is configured without heap (RT_USING_HEAP is not defined),
* the function will assert and return RT_NULL.
*
* @see rt_calloc
*/
void *calloc(size_t nelem, size_t elsize)
{
#ifdef RT_USING_HEAP
Expand All @@ -60,6 +118,20 @@ void *calloc(size_t nelem, size_t elsize)
}
RTM_EXPORT(calloc);

/**
* @brief Deallocate memory block
*
* A block of memory previously allocated by a call to malloc, calloc or realloc
* is deallocated, making it available again for further allocations.
*
* @param rmem pointer to a memory block previously allocated with malloc,
* calloc or realloc to be deallocated. If a null pointer is
* passed as argument, no action occurs.
*
* @note If the system is configured without heap (RT_USING_HEAP is not defined),
* the function will assert.
* @see rt_free
*/
void free(void *rmem)
{
#ifdef RT_USING_HEAP
Expand Down
Loading