Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
2a78d8e2
提交
2a78d8e2
4月 02, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
realloc, vsnprintf
上级
2bb471ef
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
0 行删除
+14
-0
user.h
include/user.h
+3
-0
umalloc.cc
lib/umalloc.cc
+11
-0
没有找到文件。
include/user.h
浏览文件 @
2a78d8e2
#include <stdarg.h>
BEGIN_DECLS
BEGIN_DECLS
struct
stat
;
struct
stat
;
struct
ipcmsg
;
struct
ipcmsg
;
...
@@ -61,6 +63,7 @@ void forkt_setup(u64 pid);
...
@@ -61,6 +63,7 @@ void forkt_setup(u64 pid);
void
printf
(
const
char
*
,
...);
void
printf
(
const
char
*
,
...);
void
fprintf
(
int
,
const
char
*
,
...);
void
fprintf
(
int
,
const
char
*
,
...);
void
snprintf
(
char
*
buf
,
unsigned
int
n
,
const
char
*
fmt
,
...);
void
snprintf
(
char
*
buf
,
unsigned
int
n
,
const
char
*
fmt
,
...);
void
vsnprintf
(
char
*
buf
,
u32
n
,
const
char
*
fmt
,
va_list
ap
);
void
die
(
const
char
*
errstr
,
...)
__attribute__
((
noreturn
));
void
die
(
const
char
*
errstr
,
...)
__attribute__
((
noreturn
));
#define assert(c) if (!(c)) { fprintf(2, "%s:%d: ", __FILE__, __LINE__); die("assertion failure"); }
#define assert(c) if (!(c)) { fprintf(2, "%s:%d: ", __FILE__, __LINE__); die("assertion failure"); }
...
...
lib/umalloc.cc
浏览文件 @
2a78d8e2
...
@@ -109,3 +109,14 @@ initmalloc(void)
...
@@ -109,3 +109,14 @@ initmalloc(void)
{
{
initlock
(
&
lock
);
initlock
(
&
lock
);
}
}
extern
"C"
void
*
realloc
(
void
*
ap
,
size_t
nbytes
);
void
*
realloc
(
void
*
ap
,
size_t
nbytes
)
{
Header
*
bp
=
(
header
*
)
ap
-
1
;
void
*
n
=
malloc
(
nbytes
);
memcpy
(
n
,
ap
,
bp
->
s
.
size
);
free
(
ap
);
return
n
;
}
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论