Skip to content
Snippets Groups Projects
Select Git revision
  • 6bc6ed2f77ebb7d53ac8c38133d5f622a199e629
  • master default protected
  • 9.0
  • marcus/wix3
  • 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
  • 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.c

Blame
  • array.c 41.60 KiB
    /*\
    ||| This file a part of uLPC, and is copyright by Fredrik Hubinette
    ||| uLPC is distributed as GPL (General Public License)
    ||| See the files COPYING and DISCLAIMER 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 "language.h"
    #include "error.h"
    #include "lpc_types.h"
    #include "fsort.h"
    #include "builtin_efuns.h"
    #include "memory.h"
    
    struct array empty_array=
    {
      1,                     /* Never free */
      &empty_array,          /* Next */
      &empty_array,          /* previous (circular) */
      0,                     /* Size = 0 */
      0,                     /* malloced Size = 0 */
      0,                     /* no types */
      T_MIXED,                 /* mixed array */
      0,                     /* no flags */
    };
    
    
    
    /* Allocate an array, this might be changed in the future to
     * allocate linked lists or something
     * NOTE: the new array have zero references
     */
    
    struct array *allocate_array_no_init(INT32 size,INT32 extra_space,TYPE_T type)
    {
      struct array *v;
    
      if(size == 0 && type == T_MIXED)
      {
        empty_array.refs++;
        return &empty_array;
      }
    
      if(type == T_FUNCTION || type == T_MIXED)
      {
        v=(struct array *)malloc(sizeof(struct array_of_svalues)+
                                 (size+extra_space-1)*sizeof(struct svalue));
        if(!v)
          error("Couldn't allocate array, out of memory.\n");
        v->array_type=T_MIXED;
        /* for now, we don't know what will go in here */
        v->type_field=BIT_MIXED;
      }else{
        v=(struct array *)malloc(sizeof(struct array_of_short_svalues)+
                                 (size+extra_space-1)*sizeof(union anything));
        if(!v)
          error("Couldn't allocate array, out of memory.\n");
        v->array_type=type;
        /* This array can only contain zeros and 'type' */
        v->type_field=BIT_INT | (1 << type);
      }
      v->malloced_size=size+extra_space;
      v->size=size;
      v->flags=0;
      v->refs=1;