Example #1
0
void *obj_validate(void *object)
{  
  if (object && !obj_alive(object))
    return obj_deref(object);
  else
    return object;
}
Example #2
0
void obj_unlock_debug(void *obj, const char *file, int line)
{
  if (obj)
    {
      fprintf(stderr,"%s:%i obj_unlock(%p <%s id: %lu>)\n",file,line,obj,obj_type(obj)->name,obj_id(obj));
      obj_deref(obj);
    } 
} 
Example #3
0
void objlist_delete(struct objlist *list)
{
  int i;
  for (i=0;i<list->size;i++)
    if (list->items[i])
      obj_deref(list->items[i]);
  free(list->items);
  free(list);
}
Example #4
0
/*-------------------------------------------------------------------------
 * Function:    sym_eval
 *
 * Purpose:     Returns the variable value of a symbol if it has one.
 *
 * Return:      Success:        Ptr to a copy of the variable value.
 *
 *              Failure:        NIL
 *
 * Programmer:  Robb Matzke
 *              [email protected]
 *              Dec  4 1996
 *
 * Modifications:
 *      Robb Matzke, 4 Feb 1997
 *      Fixed the arguments for the obj_deref() call.
 *
 *      Robb Matzke, 2000-07-03
 *      The symbol `$*' evaluates to a list of all $N files for
 *      consecutive N beginning at 1.
 *-------------------------------------------------------------------------
 */
static obj_t
sym_eval (obj_t _self)
{
    obj_t       name_1=NIL, file_1=NIL, retval=NIL;
    obj_sym_t   *self = MYCLASS(_self);

    /* If the symbol has a variable value then return it. */    
    if (MYCLASS(_self)->sym->var) {
        return obj_copy (MYCLASS(_self)->sym->var, SHALLOW);
    }

    /* The symbol `$*' evaluates to a list of the first consecutive files
     * bound to the $N symbols. */
    if (!strcmp(self->sym->name, "$*")) {
        obj_t   opands[1024], retval;
        int     nopands, i;
        
        for (nopands=0; nopands<NELMTS(opands); nopands++) {
            obj_t symbol;
            char tmp[32];
            sprintf(tmp, "$%d", nopands+1);
            symbol = obj_new(C_SYM, tmp);
            opands[nopands] = sym_vboundp(symbol);
            obj_dest(symbol);
            if (!opands[nopands] || C_FILE!=opands[nopands]->pub.cls) {
                /* We reached the last file or something isn't a file */
                obj_dest(opands[nopands]);
                break;
            }
        }
        retval = V_make_list(nopands, opands);
        for (i=0; i<nopands; i++) {
            obj_dest(opands[i]);
        }
        return retval;
    }

    /* If the symbol exists in the first data file, then return
     * that SDO. */
    name_1 = obj_new (C_SYM, "$1");
    file_1 = MYCLASS(name_1)->sym->var;
    name_1 = obj_dest (name_1);

    if (file_1 && C_FILE==file_1->pub.cls) {
        retval = obj_deref (file_1, 1, &_self);
        return retval;
    }

    /* Symbol has no value. */    
    out_errorn ("eval: variable `%s' has no value", obj_name(_self));
    return NIL;
}
Example #5
0
void objlist_remove(struct objlist *list, const void *obj)
{
  int i;
  for (i = 0;i < list->size; i++)
    {
      if (obj == list->items[i])
	{
	  obj_deref(list->items[i]);
	  list->items[i] = list->items[list->size-1];
	  list->size--;
	  return;
	}
    }
}
Example #6
0
void obj_unlock(void *obj)
{
  if (obj)
    obj_deref(obj);
}