pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:7679:    *!    *! Return the aproximate size of the object, in bytes.    *! This might not work very well for native objects    *!    *!    *! The function tries to estimate the memory usage of variables    *! belonging to the object.    *!    *! It will not, however, include the size of objects assigned to    *! variables in the object. +  *! +  *! +  *! If the object has a the lfun _size_object it will be called +  *! without arguments, and the return value will be added to the final +  *! size. It is primarily intended to be used by C-objects that +  *! allocate memory that is not normally visible to pike.    */   static void f__size_object( INT32 args )   {    size_t sum;    unsigned int i; -  +  ptrdiff_t fun;    struct object *o;    struct program *p;    struct mapping *map = NULL;    if( Pike_sp[-1].type != PIKE_T_OBJECT )    Pike_error("Expected an object as argument\n");    o = Pike_sp[-1].u.object;       if( !(p=o->prog) )    {    pop_stack();    push_int(0);    return;    }    sum = sizeof(struct object);    sum += p->storage_needed;    -  +  if( (fun = low_find_lfun( p, LFUN__SIZE_OBJECT)) != -1 ) +  { +  apply_low( o, fun, 0 ); +  if( Pike_sp[-1].type == PIKE_T_INT ) +  sum += Pike_sp[-1].u.integer; +  pop_stack(); +  } +     Pike_sp++;    for (i = 0; i < p->num_identifier_references; i++)    {    struct reference *ref = PTR_FROM_INT(p, i);    struct identifier *id = ID_FROM_PTR(p, ref);    struct inherit *inh = p->inherits;    if (!IDENTIFIER_IS_VARIABLE(id->identifier_flags) ||    id->run_time_type == PIKE_T_GET_SET)    {    continue;