pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:5030:    break;    }       do_abort_on_signal = delay!=0.0 && args > 1    && !UNSAFE_IS_ZERO(Pike_sp + 1-args);    pop_n_elems(args);       delaysleep(delay, do_abort_on_signal, !do_abort_on_signal && delay<10);   }    - /*! @decl int gc() + /*! @decl int gc(mapping|void quick)    *!    *! Force garbage collection.    *! -  *! This function checks all the memory for cyclic structures such +  *! @param quick +  *! Perform a quick garbage collection on just this value, +  *! which must have been made weak by @[set_weak_flag()]. +  *! All values that only have a single reference from +  *! @[quick] will then be freed. +  *! +  *! When @[quick] hasn't been specified or is @[UNDEFINED], +  *! this function checks all the memory for cyclic structures such    *! as arrays containing themselves and frees them if appropriate.    *! It also frees up destructed objects and things with only weak    *! references.    *!    *! Normally there is no need to call this function since Pike will    *! call it by itself every now and then. (Pike will try to predict    *! when 20% of all arrays/object/programs in memory is 'garbage'    *! and call this routine then.)    *!    *! @returns
pike.git/src/builtin_functions.c:5057:    *! external references during the garbage collection. It's normally    *! the same as the number of freed things, but there might be some    *! difference since destroy() functions are called during freeing,    *! which can cause more things to be freed or allocated.    *!    *! @seealso    *! @[Pike.gc_parameters], @[Debug.gc_status]    */   void f_gc(INT32 args)   { +  ptrdiff_t res = 0; +  if (args && (TYPEOF(Pike_sp[-args]) == PIKE_T_MAPPING)) { +  res = do_gc_weak_mapping(Pike_sp[-args].u.mapping);    pop_n_elems(args); -  push_int(do_gc(NULL, 1)); +  } else { +  pop_n_elems(args); +  res = do_gc(NULL, 1);    } -  +  push_int(res); + }      #ifdef TYPEP   #undef TYPEP   #endif         #define TYPEP(ID,NAME,TYPE,TYPE_NAME) \    PMOD_EXPORT void ID(INT32 args) \    { \    int t; \
pike.git/src/builtin_functions.c:10184:      /* function(:mapping(string:int)) */    ADD_EFUN("_memory_usage",f__memory_usage,    tFunc(tNone,tMap(tStr,tInt)),OPT_EXTERNAL_DEPEND);       ADD_EFUN("_size_object",f__size_object,    tFunc(tObj,tInt),OPT_EXTERNAL_DEPEND);         /* function(:int) */ -  ADD_EFUN("gc",f_gc,tFunc(tNone,tInt),OPT_SIDE_EFFECT); +  ADD_EFUN("gc", f_gc, tFunc(tMix, tInt), OPT_SIDE_EFFECT);      /* function(:string) */    ADD_EFUN("version", f_version,tFunc(tNone,tStr), OPT_TRY_OPTIMIZE);       /* Note: The last argument to the encode and decode functions is    * intentionally not part of the prototype, to keep it free for    * other uses in the future. */      /* function(mixed,void|object:string) */    ADD_EFUN("encode_value", f_encode_value,