xv6-simplified 0.1
简化版xv6
Loading...
Searching...
No Matches
Functions
string.c File Reference

字符串与内存空间赋值相关操作 More...

#include "include/types.h"
#include "include/riscv.h"
#include "include/defs.h"
Include dependency graph for string.c:

Functions

void * memset (void *dst, int c, uint n)
 给指定n大小的内存空间批量赋值
 
char * safestrcpy (char *s, const char *t, int n)
 类似于strncpy但保证一遇到'\0'就终止复制字符,且将'\0'也计入字符数量n
 
int strlen (const char *s)
 返回字符串长度
 
void * memmove (void *dst, const void *src, uint n)
 将src指向的字符串挪到dst指向的指针
 
int strncmp (const char *p, const char *q, uint n)
 比较q和p字符串大小
 
char * strncpy (char *s, const char *t, int n)
 从t字符串赋值n个字符到s指向字符串
 
char * strchr (const char *s, char c)
 在一个字符串中查找一个特定字符
 
void strw2u (char *dst, const uint16 *src, int n)
 将16bit的wchar字符串转化为8bit的char字符串
 

Detailed Description

字符串与内存空间赋值相关操作

Date
23.05.27
Author
xin
Version
0.2 @status Stable

Function Documentation

◆ memmove()

void * memmove ( void *  dst,
const void *  src,
uint  n 
)

将src指向的字符串挪到dst指向的指针

Parameters
dst目标指针
src源指针
Returns
目标指针
Here is the caller graph for this function:

◆ memset()

void * memset ( void *  dst,
int  c,
uint  n 
)

给指定n大小的内存空间批量赋值

将指针指向的地址统一赋值为c

Parameters
dst待赋值的内存开始指针
c将赋值的值
n赋值空间的大小
Returns
赋值后的内存开始指针
Here is the caller graph for this function:

◆ safestrcpy()

char * safestrcpy ( char *  s,
const char *  t,
int  n 
)

类似于strncpy但保证一遇到'\0'就终止复制字符,且将'\0'也计入字符数量n

Parameters
s目标字符指针
t源字符指针
n复制字符数量
Returns
复制的结果指针
Here is the caller graph for this function:

◆ strchr()

char * strchr ( const char *  s,
char  c 
)

在一个字符串中查找一个特定字符

Parameters
s目标字符串
c查找字符
Returns
0:未找到 n:第一个字符的地址
Here is the caller graph for this function:

◆ strlen()

int strlen ( const char *  s)

返回字符串长度

计算字符串长度(不包含'\0')

Parameters
s
Returns
字符串s的长度
Here is the caller graph for this function:

◆ strncmp()

int strncmp ( const char *  p,
const char *  q,
uint  n 
)

比较q和p字符串大小

Parameters
p字符串(前)
q字符串(后)
n比较字符数目
Returns
p大:正数 q大:负数 一样大:0
Here is the caller graph for this function:

◆ strncpy()

char * strncpy ( char *  s,
const char *  t,
int  n 
)

从t字符串赋值n个字符到s指向字符串

Parameters
s目标字符串
t源字符串
n欲复制的字符数量
Returns
目标字符串指针
Here is the caller graph for this function:

◆ strw2u()

void strw2u ( char *  dst,
const uint16 src,
int  n 
)

将16bit的wchar字符串转化为8bit的char字符串

Parameters
dst目标存放地址
src源数据存放地址
n转化的src字符串长度