memset的函数原型是
void * memset ( void * ptr, int value, size_t num );
这个函数的功能是将ptr所指向的某一块内存中的每个字节的内容全部设置为value指定的ASCII值, 块的大小由第三个参数指定,这个函数通常为新申请的内存做初始化工作。
英文解释:Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char).
函数的实现:
#ifndef __HAVE_ARCH_MEMSET
/**
* memset - Fill a region of memory with the given value
* @ptr: Pointer to the start of the area.
* @value: The byte to fill the area with
* @num: The size of the area.
*
* Do not use memset() to access IO space, use memset_io() instead.
*/
void *memset(void *ptr, int value, size_t num)
{
char *xs = ptr;
while (num --)
*xs++ = value;
return ptr;
}
EXPORT_SYMBOL(memset);
#endif
本博客文章除特别声明,全部都是原创!原创文章版权归过往记忆大数据(过往记忆)所有,未经许可不得转载。
本文链接: 【Linux库memset函数实现】(https://www.iteblog.com/archives/248.html)

