Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
728b0aa2
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
728b0aa2
编写于
1月 23, 2001
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve realloc() per idea from Karel Zak --- if chunk to be enlarged is
at end of its block, maybe we can enlarge it in-place.
上级
c0bb21b3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
2 deletion
+52
-2
src/backend/utils/mmgr/aset.c
src/backend/utils/mmgr/aset.c
+52
-2
未找到文件。
src/backend/utils/mmgr/aset.c
浏览文件 @
728b0aa2
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.3
7 2001/01/12 21:54:01
tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.3
8 2001/01/23 01:01:36
tgl Exp $
*
*
* NOTE:
* NOTE:
* This is a new (Feb. 05, 1999) implementation of the allocation set
* This is a new (Feb. 05, 1999) implementation of the allocation set
...
@@ -879,10 +879,60 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
...
@@ -879,10 +879,60 @@ AllocSetRealloc(MemoryContext context, void *pointer, Size size)
}
}
else
else
{
{
/*
* Small-chunk case. If the chunk is the last one in its block,
* there might be enough free space after it that we can just
* enlarge the chunk in-place. It's relatively painful to find
* the containing block in the general case, but we can detect
* last-ness quite cheaply for the typical case where the chunk
* is in the active (topmost) allocation block. (At least with
* the regression tests and code as of 1/2001, realloc'ing the last
* chunk of a non-topmost block hardly ever happens, so it's not
* worth scanning the block list to catch that case.)
*
* NOTE: must be careful not to create a chunk of a size that
* AllocSetAlloc would not create, else we'll get confused later.
*/
AllocPointer
newPointer
;
if
(
size
<=
ALLOC_CHUNK_LIMIT
)
{
AllocBlock
block
=
set
->
blocks
;
char
*
chunk_end
;
chunk_end
=
(
char
*
)
chunk
+
(
oldsize
+
ALLOC_CHUNKHDRSZ
);
if
(
chunk_end
==
block
->
freeptr
)
{
/* OK, it's last in block ... is there room? */
Size
freespace
=
block
->
endptr
-
block
->
freeptr
;
int
fidx
;
Size
newsize
;
Size
delta
;
fidx
=
AllocSetFreeIndex
(
size
);
newsize
=
1
<<
(
fidx
+
ALLOC_MINBITS
);
Assert
(
newsize
>=
oldsize
);
delta
=
newsize
-
oldsize
;
if
(
freespace
>=
delta
)
{
/* Yes, so just enlarge the chunk. */
block
->
freeptr
+=
delta
;
chunk
->
size
+=
delta
;
#ifdef MEMORY_CONTEXT_CHECKING
chunk
->
requested_size
=
size
;
/* set mark to catch clobber of "unused" space */
if
(
size
<
chunk
->
size
)
((
char
*
)
pointer
)[
size
]
=
0x7E
;
#endif
return
pointer
;
}
}
}
/* Normal small-chunk case: just do it by brute force. */
/* Normal small-chunk case: just do it by brute force. */
/* allocate new chunk */
/* allocate new chunk */
AllocPointer
newPointer
=
AllocSetAlloc
((
MemoryContext
)
set
,
size
);
newPointer
=
AllocSetAlloc
((
MemoryContext
)
set
,
size
);
/* transfer existing data (certain to fit) */
/* transfer existing data (certain to fit) */
memcpy
(
newPointer
,
pointer
,
oldsize
);
memcpy
(
newPointer
,
pointer
,
oldsize
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录