资源简介
perl-5.24.0.tar.gz
代码片段和文件信息
/* av.c
*
* Copyright (C) 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
* 2001 2002 2003 2004 2005 2006 2007 2008 by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License as specified in the README file.
*
*/
/*
* ‘...for the Entwives desired order and plenty and peace (by which they
* meant that things should remain where they had set them).‘ --Treebeard
*
* [p.476 of _The Lord of the Rings_ III/iv: “Treebeard“]
*/
/*
=head1 Array Manipulation Functions
*/
#include “EXTERN.h“
#define PERL_IN_AV_C
#include “perl.h“
void
Perl_av_reify(pTHX_ AV *av)
{
SSize_t key;
PERL_ARGS_ASSERT_AV_REIFY;
assert(SvTYPE(av) == SVt_PVAV);
if (AvREAL(av))
return;
#ifdef DEBUGGING
if (SvTIED_mg((const SV *)av PERL_MAGIC_tied))
Perl_ck_warner_d(aTHX_ packWARN(WARN_DEBUGGING) “av_reify called on tied array“);
#endif
key = AvMAX(av) + 1;
while (key > AvFILLp(av) + 1)
AvARRAY(av)[--key] = NULL;
while (key) {
SV * const sv = AvARRAY(av)[--key];
if (sv != &PL_sv_undef)
SvREFCNT_inc_simple_void(sv);
}
key = AvARRAY(av) - AvALLOC(av);
while (key)
AvALLOC(av)[--key] = NULL;
AvREIFY_off(av);
AvREAL_on(av);
}
/*
=for apidoc av_extend
Pre-extend an array. The C is the index to which the array should be
extended.
=cut
*/
void
Perl_av_extend(pTHX_ AV *av SSize_t key)
{
MAGIC *mg;
PERL_ARGS_ASSERT_AV_EXTEND;
assert(SvTYPE(av) == SVt_PVAV);
mg = SvTIED_mg((const SV *)av PERL_MAGIC_tied);
if (mg) {
SV *arg1 = sv_newmortal();
sv_setiv(arg1 (IV)(key + 1));
Perl_magic_methcall(aTHX_ MUTABLE_SV(av) mg SV_CONST(EXTEND) G_DISCARD 1
arg1);
return;
}
av_extend_guts(avkey&AvMAX(av)&AvALLOC(av)&AvARRAY(av));
}
/* The guts of av_extend. *Not* for general use! */
void
Perl_av_extend_guts(pTHX_ AV *av SSize_t key SSize_t *maxp SV ***allocp
SV ***arrayp)
{
PERL_ARGS_ASSERT_AV_EXTEND_GUTS;
if (key < -1) /* -1 is legal */
Perl_croak(aTHX_
“panic: av_extend_guts() negative count (%“IVdf“)“ (IV)key);
if (key > *maxp) {
SV** ary;
SSize_t tmp;
SSize_t newmax;
if (av && *allocp != *arrayp) {
ary = *allocp + AvFILLp(av) + 1;
tmp = *arrayp - *allocp;
Move(*arrayp *allocp AvFILLp(av)+1 SV*);
*maxp += tmp;
*arrayp = *allocp;
if (AvREAL(av)) {
while (tmp)
ary[--tmp] = NULL;
}
if (key > *maxp - 10) {
newmax = key + *maxp;
goto resize;
}
}
else {
if (*allocp) {
#ifdef Perl_safesysmalloc_size
/* Whilst it would be quite possible to move this logic around
(as I did in the SV code) so as to set AvMAX(av) early
based on calling Perl_safesysmalloc_size() immediately after
allocation I‘m not convinced that it is a great idea here.
In an array we have to loop round setting everything to
NULL which means wr
- 上一篇:黑客锁机源码.rar
- 下一篇:[CocosCreator]扑克翻牌效果
相关资源
- PID_AutoTune_v0.rar
- vspd7.2.308.zip
- 价值2k的H漫画小说系统
- Pythonamp;课堂amp;笔记(高淇amp;400;集第
- ddos压力测试工具99657
- UML建模大全
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
评论
共有 条评论