Select Git revision
Forked from
Nettle / nettle
Source project has a limited visibility.
array.c 74.96 KiB
/*
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
*/
#include "global.h"
#include "svalue.h"
#include "array.h"
#include "object.h"
#include "las.h"
#include "stralloc.h"
#include "interpret.h"
#include "opcodes.h"
#include "pike_error.h"
#include "pike_types.h"
#include "fsort.h"
#include "builtin_functions.h"
#include "pike_memory.h"
#include "gc.h"
#include "main.h"
#include "pike_security.h"
#include "stuff.h"
#include "bignum.h"
#include "cyclic.h"
#include "multiset.h"
#include "mapping.h"
/** The empty array. */
PMOD_EXPORT struct array empty_array=
{
PIKE_CONSTANT_MEMOBJ_INIT(1, PIKE_T_ARRAY), /* Never free */
&weak_empty_array, /* Next */
0, /* previous */
0, /* Size = 0 */
0, /* malloced Size = 0 */
0, /* no types */
0, /* no flags */
empty_array.real_item, /* Initialize the item pointer. */
{SVALUE_INIT_FREE},
};
/** The empty weak array. */
PMOD_EXPORT struct array weak_empty_array=
{
PIKE_CONSTANT_MEMOBJ_INIT(1, PIKE_T_ARRAY),
0, &empty_array, 0, 0, 0, ARRAY_WEAK_FLAG,
weak_empty_array.real_item,
{SVALUE_INIT_FREE},
};
struct array *first_array = &empty_array;
struct array *gc_internal_array = 0;
static struct array *gc_mark_array_pos;
#ifdef TRACE_UNFINISHED_TYPE_FIELDS
PMOD_EXPORT int accept_unfinished_type_fields = 0;
PMOD_EXPORT void dont_accept_unfinished_type_fields (void *orig)
{
accept_unfinished_type_fields = (int) orig;
}
#endif
/**
* Allocate an array. This might be changed in the future to allocate
* linked lists or something. The new array has zero references.
*
* When building arrays, it is recommended that you push the values on
* the stack and call aggregate_array or f_aggregate instead of