Skip to content
Snippets Groups Projects
Select Git revision
  • fe46a5d72f1a24d88f774c1bb1eb6e417d0e44b9
  • master default protected
  • 9.0
  • 8.0
  • nt-tools
  • 7.8
  • 7.6
  • 7.4
  • 7.2
  • 7.0
  • 0.6
  • rosuav/latex-markdown-renderer
  • rxnpatch/rxnpatch
  • marcus/gobject-introspection
  • rxnpatch/8.0
  • rosuav/pre-listening-ports
  • rosuav/async-annotations
  • rosuav/pgsql-ssl
  • rxnpatch/rxnpatch-broken/2023-10-06T094250
  • grubba/fdlib
  • grubba/wip/sakura/8.0
  • v8.0.2020
  • v8.0.2018
  • v8.0.2016
  • v8.0.2014
  • v8.0.2012
  • v8.0.2008
  • v8.0.2006
  • v8.0.2004
  • v8.0.2002
  • v8.0.2000
  • v8.0.1998
  • v8.0.1996
  • v8.0.1994
  • v8.0.1992
  • v8.0.1990
  • v8.0.1988
  • v8.0.1986
  • rxnpatch/clusters/8.0/2025-04-29T124414
  • rxnpatch/2025-04-29T124414
  • v8.0.1984
41 results

array.h

Blame
  • array.h 14.45 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.
    */
    
    #ifndef ARRAY_H
    #define ARRAY_H
    
    #include "svalue.h"
    #include "dmalloc.h"
    
    /* This debug tool writes out messages whenever arrays with unfinished
     * type fields are encountered. */
    /* #define TRACE_UNFINISHED_TYPE_FIELDS */
    
    /**
     * A Pike array is represented as a 'struct array' with all the
     * needed svalues malloced in the same block.
     * 
     * @see type_field
     */
    struct array
    {
      PIKE_MEMORY_OBJECT_MEMBERS;
    
      struct array *next;	/**< we need to keep track of all arrays */
      struct array *prev;	/**< Another pointer, so we don't have to search
    			 * when freeing arrays */
      INT32 size;		/**< number of svalues in this array */
      INT32 malloced_size;	/**< number of svalues that can fit in this array */
      TYPE_FIELD type_field;/**< A bitfield with one bit for each type of
    			  * data in this array.
       Bits can be set that don't exist in the array. type_field is
       * initialized to BIT_MIXED|BIT_UNFINISHED for newly allocated
       * arrays so that they can be modified without having to update
       * this. It should be set accurately when that's done, though. */
      INT16 flags;          /**< ARRAY_* flags */
      struct svalue *item;  /**< the array of svalues */
      struct svalue real_item[1];
    };
    
    #define ARRAY_WEAK_FLAG 1
    #define ARRAY_CYCLIC 2
    #define ARRAY_LVALUE 4
    
    PMOD_EXPORT extern struct array empty_array, weak_empty_array;
    extern struct array *first_array;
    extern struct array *gc_internal_array;
    
    #if defined(DEBUG_MALLOC) && defined(PIKE_DEBUG)
    #define ITEM(X) (((struct array *)(debug_malloc_pass((X))))->item)
    #else
    #define ITEM(X) ((X)->item)
    #endif
    
    /* These are arguments for the function 'merge' which merges two sorted
     * set stored in arrays in the way you specify
     */
    #define PIKE_ARRAY_OP_A 1
    #define PIKE_ARRAY_OP_SKIP_A 2
    #define PIKE_ARRAY_OP_TAKE_A 3
    #define PIKE_ARRAY_OP_B 4
    #define PIKE_ARRAY_OP_SKIP_B 8
    #define PIKE_ARRAY_OP_TAKE_B 12
    #define PIKE_MINTERM(X,Y,Z) (((X)<<8)+((Y)<<4)+(Z))
    
    #define PIKE_ARRAY_OP_AND PIKE_MINTERM(PIKE_ARRAY_OP_SKIP_A,PIKE_ARRAY_OP_SKIP_A | PIKE_ARRAY_OP_TAKE_B,PIKE_ARRAY_OP_SKIP_B)
    #define PIKE_ARRAY_OP_AND_LEFT PIKE_MINTERM(PIKE_ARRAY_OP_SKIP_A,PIKE_ARRAY_OP_SKIP_B | PIKE_ARRAY_OP_TAKE_A,PIKE_ARRAY_OP_SKIP_B)
    #define PIKE_ARRAY_OP_OR  PIKE_MINTERM(PIKE_ARRAY_OP_TAKE_A,PIKE_ARRAY_OP_SKIP_A | PIKE_ARRAY_OP_TAKE_B,PIKE_ARRAY_OP_TAKE_B)