Ejemplo n.º 1
0
void soldel( solidtyp* solp )
{
  solidtyp sol;
  int i;

  sol = *solp;
  if ( !sol || --sol->refcnt )
    return;
  if ( sol->isleaf )
  {
    for ( i = 0; i < nrlatr; i++ )
      delitem( ULlist, &sol->tpart.leaf.latrb[i] );
  /*
    if ( sol->tpart.leaf.isop )
      destroy_iso_data( sol->tpart.leaf.isop );
  */
  }
  else
  {
    soldel( &sol->tpart.node.lnode );
    soldel( &sol->tpart.node.rnode );
  }
  if ( sol->ttyp == ULmap )
    delitem( ULmap, &sol->trf.trfi );
  for ( i = 0; i < nrnatr; i++ )
    delitem( ULlist, &sol->natrb[i] );
  free( sol );
}
Ejemplo n.º 2
0
static void ulputlatr( int parcnt, genpar *pars, void *d0, void *d1, mapevalenviron* mapenv, evalcontext* ecntxt )
{
  inttyp ai;
  solidtyp sol;
  listtyp l;

  sol = *(solidtyp*)pars[0].parp;
  ai = *(inttyp*)pars[1].parp;
  l = *(listtyp*)pars[2].parp;
  if ( ai < 0 || ai >= nrlatr )
  {
    soldel( &sol );
    delitem( ULlist, &l );
    ecntxt->cycles->errormsg( 178 );
    return;
  }
  if ( !sol->isleaf )
  {
    soldel( &sol );
    delitem( ULlist, &l );
    ecntxt->cycles->errormsg( 179 );
    return;
  }
  delitem( ULlist, &sol->tpart.leaf.latrb[ai] );
  sol->tpart.leaf.latrb[ai] = l;
  ecntxt->stacks->pushand( ULsol, &sol );
}
Ejemplo n.º 3
0
ILThread::~ILThread()
{
  delete mThreadContext;
  delitem( ULcom, &threadcom );
  if ( syncWin )
    delitem( ULwin, &renderSync );
}
Ejemplo n.º 4
0
static void ultrfrm( int parcnt, genpar *pars, void *d0, void *d1, mapevalenviron* mapenv, evalcontext* ecntxt )
{
  maptyp mp, mp0;
  int mtyp;
  solidtyp sol;
  implinst coercf;

  mp0 = mp = *(maptyp*)pars[1].parp;
  sol = *(solidtyp*)pars[0].parp;
  mtyp = mp->type;
  if ( mtyp != ULtrf3 )
    if ( coercf = coercible( ULtrf3, mtyp, -1 ) )
      mp0 = newmap( ULtrf3, 1, pars+1, 0, coercf, ecntxt, 0 );
    else
      ecntxt->cycles->errormsg( 149 );
  if ( ecntxt->cycles->error )
  {
    soldel( &sol );
    delitem( ULmap, &mp );
    return;
  }
  mp = mp0;
  if ( !sol->ttyp )
  {
    sol->ttyp = ULmap;
    sol->trf.trfi = mp;
  }
  else
  {
    *(maptyp*)pars[1].parp = mp;
    if ( sol->ttyp == ULmap )
    {
      *(maptyp*)pars[0].parp = sol->trf.trfi;
      pars[0].type = ULmap;
    }
    else
    {
      *(trf3typ*)pars[0].parp = sol->trf.trfe;
      pars[0].type = ULtrf3;
    }
    sol->ttyp = ULmap;
    sol->trf.trfi = newmap( ULtrf3, 2, pars, 0, (implinst)ult3prd, ecntxt, 0 );
    if ( mp->idep & DEP3c )
      sol->trf.trfi->mpar[1].ppeval = true;
  }
  if ( ecntxt->cycles->error )
  {
    soldel( &sol );
    delitem( ULmap, &mp );
  }
  ecntxt->stacks->pushand( ULsol, &sol );
}
Ejemplo n.º 5
0
int
dbm_delete(DBM *db, datum key)
{
	int i;

	if (dbm_error(db))
		return (-1);
	if (dbm_rdonly(db)) {
		errno = EPERM;
		return (-1);
	}
	dbm_access(db, dcalchash(key));
	if ((i = finddatum(db->dbm_pagbuf, key)) < 0)
		return (-1);
	if (!delitem(db->dbm_pagbuf, i))
		goto err;
	db->dbm_pagbno = db->dbm_blkno;
	if (dbm_defwrite(db)) {
		dbm_setdirty(db);
	}
	else {
	(void) lseek(db->dbm_pagf, (long)(db->dbm_blkno*PBLKSIZ), L_SET);
	if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
	err:
		db->dbm_flags |= _DBM_IOERR;
		return (-1);
	}
	}
	return (0);
}
Ejemplo n.º 6
0
/* Delete window client from workspace ws. */
void delfromworkspace(struct client *client, uint32_t ws)
{
    delitem(&wslist[ws], client->wsitem[ws]);

    /* Reset our place in the workspace window list. */
    client->wsitem[ws] = NULL;
}
Ejemplo n.º 7
0
static void ultrfr0( int parcnt, genpar *pars, void *d0, void *d1, mapevalenviron* mapenv, evalcontext* ecntxt )
{
  trf3typ trf;
  solidtyp sol;

  trf = *(trf3typ*)pars[1].parp;
  sol = *(solidtyp*)pars[0].parp;
  if ( sol->ttyp == ULmap )
  {
    pars[0].type = ULmap;
    *(maptyp*)pars[0].parp = sol->trf.trfi;
    sol->trf.trfi = newmap( ULtrf3, 2, pars, 0, (implinst)ult3prd, ecntxt, 0 );
    if ( ecntxt->cycles->error )
    {
      soldel( &sol );
      delitem( ULmap, pars[0].parp );
    }
  }
  else if ( sol->ttyp == ULtrf3 )
  {
    sethomo4( sol->trf.trfe.hom &= trf.hom );
    mat4mulx( sol->trf.trfe.tr, trf.tr );
  }
  else
  {
    sol->ttyp = ULtrf3;
    sol->trf.trfe = trf;
  }
  ecntxt->stacks->pushand( ULsol, &sol );
}
Ejemplo n.º 8
0
void
inventory_manager::upditem (u08 flags, u32 location, data::item const &item)
{
  data::item *current = get (item.tag);

  return_unless (current != NULL);

  if (flags & UPD_LOCATION)
    {
      data::item save = *current;
      delitem ({ item.tag });
      current = &merge (inventories[location], save);
    }

  if (flags & UPD_ANIM)      current->anim      = item.anim;
  if (flags & UPD_ANIMSPEED) current->animspeed = item.animspeed;
  if (flags & UPD_FACE)      current->face      = item.face;
  if (flags & UPD_FLAGS)     current->flags     = item.flags;
  if (flags & UPD_NROF)      current->nrof      = item.nrof;
  if (flags & UPD_WEIGHT)    current->weight    = item.weight;

  if (flags & UPD_NAME)
    {
      current->singular = item.singular;
      current->plural   = item.plural;
    }

  update ();
}
Ejemplo n.º 9
0
static void dellink(link_t *t)
{
    if (*t == NULL) {
        return ;
    }

    delitem(&(*t)->item);
    free(*t);
    *t = NULL;
}
Ejemplo n.º 10
0
void ilparser::ilass( comndtyp cp, void* d, int t, bool def )
{
    cnvidcom( (char*)mContext->scanner->symid+2, cp, IDLEN );
    delitem( ULcom, &cp );
    codmodl( mContext->scanner->symid, 1 );
    symptyp sympnt = mContext->hasher->hashhash( mContext->scanner->symid, true );
    if ( sympnt.prtd )
    {
        mContext->cycles->errormsg( 275 );
        return;
    }
    mContext->stacks->pushand( ULsymp, &sympnt );
    mContext->stacks->pushand( t, d );
    assign( def );
}
Ejemplo n.º 11
0
/* store a record */
int dbm_store(DBM *db, datum key, datum dat, int replace){
  int i;
  datum item, item1;
  char ovfbuf[PBLKSIZ];
  if(dbm_error(db))
    return (-1);
  if(dbm_rdonly(db)){
    errno = EPERM;
    return (-1);
  }
 loop:
  dbm_access(db, dcalchash(key));
  if((i = finddatum(db->dbm_pagbuf, key)) >= 0){
    if(!replace)
      return (1);
    if(!delitem(db->dbm_pagbuf, i)){
      db->dbm_flags |= _DBM_IOERR;
      return (-1);
    }
  }
  if(!additem(db->dbm_pagbuf, key, dat))
    goto split;
  db->dbm_pagbno = db->dbm_blkno;
  (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, SEEK_SET);
  if(write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ){
    db->dbm_flags |= _DBM_IOERR;
    return (-1);
  }
  return (0);
 split:
  if(key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ){
    db->dbm_flags |= _DBM_IOERR;
    errno = ENOSPC;
    return (-1);
  }
  memset(ovfbuf, 0, PBLKSIZ);
  for(i=0;;){
    item = makdatum(db->dbm_pagbuf, i);
    if(item.dptr == NULL)
      break;
    if(dcalchash(item) & (db->dbm_hmask+1)){
      item1 = makdatum(db->dbm_pagbuf, i+1);
      if(item1.dptr == NULL){
        db->dbm_flags |= _DBM_IOERR;
        break;
      }
      if(!additem(ovfbuf, item, item1) ||
         !delitem(db->dbm_pagbuf, i)){
        db->dbm_flags |= _DBM_IOERR;
        return (-1);
      }
      continue;
    }
    i += 2;
  }
  db->dbm_pagbno = db->dbm_blkno;
  (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, SEEK_SET);
  if(write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ){
    db->dbm_flags |= _DBM_IOERR;
    return (-1);
  }
  (void) lseek(db->dbm_pagf, (db->dbm_blkno+db->dbm_hmask+1)*PBLKSIZ, SEEK_SET);
  if(write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ){
    db->dbm_flags |= _DBM_IOERR;
    return (-1);
  }
  setbit(db);
  goto loop;
}
Ejemplo n.º 12
0
void ilparser::parsecom()
{
    if ( mContext->cycles->error )
    {
        mContext->frames->popbotm();
        return;
    }
    pushop.symclass = mContext->scanner->symclass;
    pushop.parsval = parsval;
#ifdef _DEBUG
    if ( mContext->debuglevel & 1 )
        printf( "%s\n", SymStr[mContext->scanner->symclass] );
#endif
    switch ( mContext->scanner->symclass )
    {
    case EOCOM:
        if ( mContext->cycles->console && !eolmode )
        {
            mContext->cycles->newline( 2 );
            mContext->scanner->rstrscan( parsval );
        }
        else if ( parsval )
            mContext->cycles->errormsg( 137 );
        else if ( evalst( true ) )
            parseocom();
        break;
    case PARNTOP:
        parsparntop();
        break;
    case PARNTCLS:
        if ( evalst( true ) )
            parsparntcls();
        break;
    case COMMA:
        if ( parsval )
            mContext->cycles->errormsg( 132 );
        else if ( evalst( true ) )
            parscomma();
        break;
    case CONDIT:
        if ( parsval )
            mContext->cycles->errormsg( 143 );
        else if ( evalst( false ) )
            parscondit();
        break;
    case ALTERN:
        if ( parsval )
            mContext->cycles->errormsg( 144 );
        else if ( evalst( true ) )
            parsaltern();
        break;
    case ASGNMNT:
    case DEFNTN:
        if ( !parsval )
            mContext->cycles->errormsg( 133 );
        else
            parsasgnmnt( mContext->scanner->symclass );
        break;
    case OPRT:
        iloperator.optornr = -1;
        iloperator.unaropt = parsval;
        iloperator.opt = mContext->scanner->symopt;
        parsoprt( &iloperator );
        break;
    case RCONST:
        if ( parsval )
        {
#ifdef _DEBUG
            if ( mContext->debuglevel & 1 )
                printf( "  %f\n", mContext->scanner->symval );
#endif
            mContext->stacks->pushand( ULreal, &mContext->scanner->symval );
            if ( evalun() )
            {
                parsval = false;
                mContext->scanner->scancom();
            }
        }
        else
            mContext->cycles->errormsg( 136 );
        break;
    case ICONST:
        if ( parsval )
        {
#ifdef _DEBUG
            if ( mContext->debuglevel & 1 )
                printf( "  %d\n", mContext->scanner->symcnt );
#endif
            mContext->stacks->pushand( ULint, &mContext->scanner->symcnt );
            if ( evalun() )
            {
                parsval = false;
                mContext->scanner->scancom();
            }
        }
        else
            mContext->cycles->errormsg( 136 );
        break;
    case STRINGP:
        if ( parsval )
        {
#ifdef _DEBUG
            if ( mContext->debuglevel & 1 )
                printf( "  %s\n", mContext->scanner->symcomp );
#endif
            mContext->stacks->pushand( ULcom, &mContext->scanner->symcomp );
            parsval = false;
            mContext->scanner->scancom();
        }
        else
        {
            delitem( ULcom, &mContext->scanner->symcomp );
            mContext->cycles->errormsg( 155 );
        }
        break;
    case IDFER:
        if( !parsval )
            mContext->cycles->errormsg( 128 );
        else
        {
#ifdef _DEBUG
            if ( mContext->debuglevel & 1 )
                printf( "  %s\n", mContext->scanner->symid );
#endif
            parsidfer();
            if ( !mContext->cycles->error && evalun() )
            {
                parsval = false;
                mContext->scanner->scancom();
            }
        }
        break;
    case SEMICOL:
        if ( parsval )
            mContext->cycles->errormsg( 138 );
        else if ( evalst( true ) )
            parssemicol();
        break;
    default:
        ;
    }
    if ( mContext->cycles->error )
        mContext->frames->popbotm();
}
Ejemplo n.º 13
0
void ilparser::parscondit()
{
    booltyp cond;
    inttyp icond;
    realtyp rcond;
    datpnt cndadr;
    int cndtyp;
    maptyp cndm;
    listtyp cndl;
    int altfound = 0;

    mContext->stacks->popd( OPADR, &cndadr );
    if ( mContext->cycles->error )
        return;
    cndtyp = cndadr.tp;
    if ( cndtyp == ULbool )
    {
        mContext->stacks->pop( OPAND, &cond, typesize( ULbool ) );
        if ( !( mContext->cycles->error || cond ) )
            altfound = mContext->scanner->srchalt();
    }
    else if ( cndtyp == ULint )
    {
        mContext->stacks->pop( OPAND, &icond, typesize( ULint ) );
        if ( !( mContext->cycles->error || icond ) )
            altfound = mContext->scanner->srchalt();
    }
    else if ( cndtyp == ULreal )
    {
        mContext->stacks->pop( OPAND, &rcond, typesize( ULreal ) );
        if ( !( mContext->cycles->error || rcond ) )
            altfound = mContext->scanner->srchalt();
    }
    else if ( cndtyp == ULlist )
    {
        mContext->stacks->pop( OPAND, &cndl, typesize( ULlist ) );
        delitem( ULlist, &cndl );
        if ( !( mContext->cycles->error || cndl ) )
            altfound = mContext->scanner->srchalt();
    }
    else if ( cndtyp == ULmap )
    {
        mContext->stacks->pop( OPAND, &cndm, typesize( ULmap ) );
        if ( cndm->type != ULbool && cndm->type != ULint && cndm->type != ULreal && cndm->type != ULbsampbuf )
            mContext->cycles->errormsg( 228 );
        else
        {
            mContext->stacks->pushand( ULmap, &cndm );
            iloperator.optornr = cndm->type == ULbsampbuf ? SMPCONDIT : CONDIT;
            iloperator.unaropt = false;
            mContext->stacks->pushd( OPTOR, &iloperator );
        }
    }
    else
    {
        mContext->stacks->chkdel( OPAND, &cndadr );
        mContext->cycles->errormsg( 149 );
    }
    if ( altfound < 0 )
    {
        cndl = 0;
        mContext->stacks->pushand( ULlist, &cndl );
        parsval = false;
    }
    else
        parsval = true;
    mContext->scanner->scancom();
}
Ejemplo n.º 14
0
inline void item_policies::del(
    object const& target
    , object const& key)
{
    delitem(target, key);
}
Ejemplo n.º 15
0
void delitem(object const& target, Key const& key)
{
    delitem(target, object(key));
}
Ejemplo n.º 16
0
void makfract( unsigned char* car, maptyp mph0, realtyp h0, int bmp,
		      int szx, int szy, ush3 rv, evalcontext* ecntxt )
{
  int i, j, sfr, frsmin, frsmax, ymax;
  realtyp rc, of, fri, d0, d1;

  fracbump = bmp;
  fracsizx = szx;
  fracsizy = szy;
  for ( i = 0; i < 3; i++ )
    rndvl[i] = rv[i];
  if ( !( land = (float*)malloc( fracsizx * fracsizy * sizeof( float ) ) ) )
  {
    ecntxt->cycles->errormsg( 205 );
    if ( mph0 )
      delitem( ULmap, &mph0 );
    return;
  }
  if ( fracsizx < fracsizy )
  {
    ymax = 1;
    frsmax = fracsizy;
    frsmin = fracsizx;
  }
  else
  {
    ymax = 0;
    frsmax = fracsizx;
    frsmin = fracsizy;
  }
  if ( fracsizx != fracsizy )
    if ( ymax )
      for ( j = 0; j < frsmax; j += frsmin )
        *( adrarar( 0, j ) ) = 0.0;
    else
      for ( i = 0; i < frsmax; i += frsmin )
        *( adrarar( i, 0 ) ) = 0.0;
  else
    *adrarar( 0, 0 ) = 0.0;
  sfr = frsmin / 2;
  mapevalenviron mapenv;
  if ( mph = mph0 )
  {
    if ( ( mph->idep & DEP2d ) &&
	 ( mph->dbnd2.i2[0] != fracsizx || mph->dbnd2.i2[1] != fracsizy ) )
      dtoc2map( &mph, ecntxt );
    ddep = mph->idep & DEP2d;
    cdep = mph->idep & DEP2c;
    dep1 = mph->idep & DEP1c;
    calcmdep1( mph, DEP1c | DEP2c | DEP2d, mapenv, ecntxt );
  }
  else
    h = h0;
  lmin = lmax = dmin = dmax = 0.0;
  dist = 1.0;
  for ( i = sfr; !ecntxt->cycles->error && i > 0; i /= 2 )
  {
    diag( i, mapenv, ecntxt );
    dist /= M_SQRT2;
    rect( i, mapenv, ecntxt );
    dist /= M_SQRT2;
  }
  if ( ecntxt->cycles->error )
  {
    free( land );
    if ( mph0 )
      delitem( ULmap, &mph );
    return;
  }
  if ( fracbump )
  {
    fri = dmax - dmin;
    for ( j = 0; j < fracsizy; j++ )
    {
      d1 = *(adrarar( fracsizx - 1, j ));
      for ( i = 0; i < fracsizx; i++ )
      {
        d0 = d1;
        d1 = *(adrarar( i, j ));
        *( car + 2 * ( j * fracsizx + i ) ) = 
          realtochar( ( d1 - d0 - dmin ) / fri );
      }
    }
    for ( i = 0; i < fracsizx; i++ )
    {
      d1 = *(adrarar( i, fracsizy - 1 ));
      for ( j = 0; j < fracsizy; j++ )
      {
        d0 = d1;
        d1 = *(adrarar( i, j ));
        *( car + 2 * ( j * fracsizx + i ) + 1 ) = 
   realtochar( (  d1 - d0 - dmin ) / fri );
      }
    }
  }
  else
  {
    rc = 1.0 / ( lmax - lmin );
    of = - rc * lmin;
    for ( i = 0; i < fracsizx; i++ )
      for ( j = 0; j < fracsizy; j++ )
        *( car + ( j * fracsizx + i ) ) = 
   realtochar( rc * *adrarar( i, j ) + of );
  }
  if ( mph0 )
    delitem( ULmap, &mph );
  free( land );
}
Ejemplo n.º 17
0
int
dbm_store(DBM *db, datum key, datum dat, int replace)
{
	int i;
	datum item, item1;
	char ovfbuf[PBLKSIZ];

	if (dbm_error(db))
		return (-1);
	if (dbm_rdonly(db)) {
		errno = EPERM;
		return (-1);
	}
loop:
	dbm_access(db, dcalchash(key));
	if ((i = finddatum(db->dbm_pagbuf, key)) >= 0) {
		if (!replace)
			return (1);
		if (!delitem(db->dbm_pagbuf, i)) {
			db->dbm_flags |= _DBM_IOERR;
			return (-1);
		}
	}
	if (!additem(db->dbm_pagbuf, key, dat))
		goto split;
	db->dbm_pagbno = db->dbm_blkno;
	if (dbm_defwrite(db)) {
		dbm_setdirty(db);
	}
	else {

		(void) lseek(db->dbm_pagf, (long)(db->dbm_blkno*PBLKSIZ), L_SET);
		if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
			db->dbm_flags |= _DBM_IOERR;
			return (-1);
		}
	}
	return (0);

split:
	if (key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ) {
		db->dbm_flags |= _DBM_IOERR;
		errno = ENOSPC;
		return (-1);
	}
	bzero(ovfbuf, PBLKSIZ);
	for (i=0;;) {
		item = makdatum(db->dbm_pagbuf, i);
		if (item.dptr == NULL)
			break;
		if (dcalchash(item) & (db->dbm_hmask+1)) {
			item1 = makdatum(db->dbm_pagbuf, i+1);
			if (item1.dptr == NULL) {
				/*(void) fprintf(stderr, "ndbm: split not paired\n");*/
				db->dbm_flags |= _DBM_IOERR;
				break;
			}
			if (!additem(ovfbuf, item, item1) ||
			    !delitem(db->dbm_pagbuf, i)) {
				db->dbm_flags |= _DBM_IOERR;
				return (-1);
			}
			continue;
		}
		i += 2;
	}
	db->dbm_pagbno = db->dbm_blkno;
	(void) lseek(db->dbm_pagf, (long)(db->dbm_blkno*PBLKSIZ), L_SET);
	if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
		db->dbm_flags |= _DBM_IOERR;
		return (-1);
	}
	dbm_clrdirty(db); /*clear dirty*/
	(void) lseek(db->dbm_pagf, 
		(long)((db->dbm_blkno+db->dbm_hmask+1)*PBLKSIZ), L_SET);
	if (write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ) {
		db->dbm_flags |= _DBM_IOERR;
		return (-1);
	}
	if (setbit(db) < 0) {
		db->dbm_flags |= _DBM_IOERR;
		return (-1);
	}
	goto loop;
}