pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:2649:    get_all_args("allocate", args, "%+.%*", &size, &init);    if (size > MAX_INT32)    SIMPLE_ARG_ERROR ("allocate", 1, "Integer too large to use as array size.");       a=allocate_array(size);    if(args>1)    {    INT32 e;    push_array (a);    if (init) { +  if ((1 << TYPEOF(*init)) & (BIT_BASIC|BIT_FUNCTION| +  BIT_OBJECT|BIT_PROGRAM)) { + #ifdef PIKE_RUN_UNLOCKED + # warning NOT SAFE + #endif +  if (TYPEOF(*init) <= MAX_REF_TYPE) +  *(init->u.refs) += size; +  cmemset(a->item, init, sizeof(struct svalue), size); +  // add size references +  } else    for(e=0;e<size;e++)    copy_svalues_recursively_no_free(a->item+e, init, 1, 0);    a->type_field = 1 << TYPEOF(*init);    }    else {    /* It's somewhat quirky that allocate(17) and allocate(17, UNDEFINED)    * have different behavior, but it's of some use, and it's compatible    * with previous versions. */ -  for(e=0;e<size;e++) -  ITEM (a)[e] = svalue_undefined; +  cmemset(ITEM(a), &svalue_undefined, sizeof(struct svalue), size);    a->type_field = BIT_INT;    }    stack_pop_n_elems_keep_top (args);    }    else {    a->type_field = BIT_INT;    pop_n_elems(args);    push_array(a);    }   }