Пример #1
0
int
aio_fd (buffer_desc_t * buf, dk_hash_t * aio_ht, OFF_T * off)
{
  dbe_storage_t * dbs = buf->bd_storage;
  dk_hash_t * dbs_ht = (dk_hash_t *) gethash ((void*) buf->bd_storage, aio_ht);
  if (buf->bd_storage->dbs_disks)
    {
      int fd;
      disk_stripe_t * dst;
      if (!dbs_ht)
	{
	  dbs_ht = hash_table_allocate (10);
	  sethash ((void*)dbs, aio_ht, (void*) dbs_ht);
	}
      dst = dp_disk_locate (buf->bd_storage, buf->bd_physical_page, off);
      fd = (int)(ptrlong) gethash ((void*)dst, dbs_ht);
      if (!fd)
	{
	  fd = dst_fd (dst);
	  sethash ((void*)dst, dbs_ht, (void*)(ptrlong)fd);
	}
      return fd;
    }
  else
    {
      if (!dbs_ht)
	{
	  sethash ((void*)buf->bd_storage, aio_ht, (void*) 1);
	  mutex_enter (buf->bd_storage->dbs_file_mtx);
	}
      *off = ((int64)PAGE_SZ) * buf->bd_physical_page;
      return buf->bd_storage->dbs_fd;
    }
}
Пример #2
0
bool check(int a,int b){
     int l = from[b],r = to[b];
     while(from[a] <= to[a] && l <=r && str[from[a]] != '*'){
      if(str[from[a]] != str[l])
       return false;
      ++from[a],++l;
     }
     while(from[a] <= to[a] && l<=r && str[to[a]] != '*')
     {
      if(str[to[a]] != str[r])
       return false;
      --to[a],--r;
     }
     while(from[a] <= to[a]){
       while(str[from[a]] == '*' && from[a] <= to[a])
        ++ from[a];
       if(from[a] > to[a]) break;
       int st = from[a],ed;
       for(ed = st;str[ed] != '*';++ed);
       ull val = gethash(from[a],ed-1);
       int len = ed-st;
       for(int i = l;i<=r+1;++i)
       {
        if(i+len-1>r) return false;
        if(gethash(i,i+len-1)==val){
        l = i+len;
        break;
        }
       }
       from[a] = ed;
     }
     return true;
}
Пример #3
0
int main()
{
	int n;
	int T=0;
	while(~scanf("%d",&n) && n!=0)
	{
		++T;
		hcnt=segcnt=0;
		double x1,y1,x2,y2;
		for(int i=1;i<=n;i++)
		{
			scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
			hash[++hcnt]=x1;hash[++hcnt]=x2;
			seg[++segcnt]=(Segment){x1,x2,y1,1};
			seg[++segcnt]=(Segment){x1,x2,y2,-1};
		}
		std::sort(seg+1,seg+segcnt+1);
		std::sort(hash+1,hash+hcnt+1);
		settree(1,1,hcnt);
		double covered=0,ans=0;
		for(int i=1;i<=segcnt-1;i++)
		{
			covered+=add(1,1,hcnt,gethash(seg[i].l)+1,gethash(seg[i].r),seg[i].tp);
			ans+=covered*(seg[i+1].h-seg[i].h);
		}
		printf("Test case #%d\nTotal explored area: %.2f\n\n",T,ans);
	}
}
Пример #4
0
int main()
{
	int n;
	int T; scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		hcnt=segcnt=0;
		double x1,y1,x2,y2;
		for(int i=1;i<=n;i++)
		{
			scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
			hash[++hcnt]=x1;hash[++hcnt]=x2;
			seg[++segcnt]=(Segment){x1,x2,y1,1};
			seg[++segcnt]=(Segment){x1,x2,y2,-1};
		}
		std::sort(seg+1,seg+segcnt+1);
		std::sort(hash+1,hash+hcnt+1);
		settree(1,1,hcnt);
		double covered=0,ans=0;
		for(int i=1;i<=segcnt-1;i++)
		{
			covered+=add(1,1,hcnt,gethash(seg[i].l)+1,gethash(seg[i].r),seg[i].tp);
			ans+=covered*(seg[i+1].h-seg[i].h);
		}
		printf("%.2f\n",ans);
	}
}
Пример #5
0
int Hashhandler(char* cmd){
	char* tok = strtok(NULL,DELIM);	
	if(!strcmp(tok,"--verify")){
		tok = strtok(NULL,DELIM);
		strcpy(files[0].name,tok);
		gethash(parse2(files[0].name));
		for(int j=0;j<MD5_DIGEST_LENGTH;++j){
			files[0].hash[j]=h[j];
		}
		files[0].timestamp = findtime(files[0].name);
		return 1;
	}
	else if(!strcmp(tok,"--checkall")){
		int nu = IndexGet();
		for(int i=0;i<nu;++i){
			gethash(parse2(files[i].name));
			for(int j=0;j<MD5_DIGEST_LENGTH;++j){
				files[i].hash[j]=h[j];
			}
			files[i].timestamp = findtime(parse2(files[i].name));
		}
		return nu;
	}
	else{
		//printf("wrong input\n");
		return -1;
	}
}
Пример #6
0
void polacz(long x1,long y1,long x2, long y2)
{
	long h1=gethash(x1,y1);
	long h2=gethash(x2,y2);
	long r1=find(hash[h1],x1,y1);
	long r2=find(hash[h2],x2,y2);
	un(r1,r2);
}
Пример #7
0
buffer_desc_t *
itc_delta_this_buffer (it_cursor_t * itc, buffer_desc_t * buf, int stay_in_map)
{
  /* The caller has no access but intends to change the parent link. */
  it_map_t * itm;
  dp_addr_t remap_to;
#ifdef PAGE_TRACE
  dp_addr_t old_dp = buf->bd_physical_page;
#endif
#ifdef _NOT
  FAILCK (itc);
#endif
  ASSERT_IN_MAP (itc->itc_tree, buf->bd_page);
  itm = IT_DP_MAP (itc->itc_tree, buf->bd_page);
#ifdef MTX_DEBUG
  if (buf->bd_is_dirty && !gethash (DP_ADDR2VOID (buf->bd_page), &itm->itm_remap))
    GPF_T1 ("dirty but not remapped in checking delta");
#endif
  if (gethash (DP_ADDR2VOID (buf->bd_page), &itm->itm_remap))
    {
      buf->bd_is_dirty = 1;
      return (buf);
    }
  if (it_can_reuse_logical (itc->itc_tree, buf->bd_page))
    remap_to = buf->bd_page;
  else
    remap_to = em_new_dp (itc->itc_tree->it_extent_map, EXT_REMAP, 0, &itc->itc_n_pages_on_hold);

  if (!remap_to)
    {
      if (LT_CLOSING == itc->itc_ltrx->lt_status)
	{
	  log_error ("Out if disk during commit.  The transaction is in effect and will be replayed from the log at restart.  Exiting due to no disk space, thus cannot maintain separation of checkpoint and commit space and transactional semantic."
		     "This happens due to running out of safety margin, which is not expected to happen.  If this takes place without in fact being out of disk on the database or consistently in a given situation, the condition may be reported to support.   This is a planned exit and not a database corruption.  A core will be made for possible support.");
	  GPF_T1 ("Deliberately made core for possible support");
	}
      if (itc->itc_n_pages_on_hold)
	GPF_T1 ("The database is out of disk during an insert.  The insert has exceeded its space safety margin.  This does not normally happen.  This is a planned exit and not a corruption. Make more disk space available.  If this occurs continuously or without in fact running out of space, this may be reported to support.");
      if (DELTA_STAY_INSIDE == stay_in_map)
	GPF_T1 ("out of disk on reloc_right_leaves.");
      log_error ("Out of disk space for database");
      itc->itc_ltrx->lt_error = LTE_NO_DISK;
      itc_bust_this_trx (itc, &buf, ITC_BUST_THROW);
    }

  buf->bd_physical_page = remap_to;
  sethash (DP_ADDR2VOID (buf->bd_page), &itm->itm_remap,
	   DP_ADDR2VOID (remap_to));
  buf->bd_is_dirty = 1;
  DBG_PT_DELTA_CLEAN (buf, old_dp);
  return buf;
}
Пример #8
0
void hasher(List* L,List* H[101],int functionnumber)
{
    assert(L);
    assert(H);
    gotofirst(L);
    while (L->current->next!=NULL)
    {
        gotonext(L);
        if(listcontainsthis(H[gethash(L->current->data,functionnumber)],L->current->data)==0)
        {
            input(H[gethash(L->current->data,functionnumber)],L->current->data);   //printf("%d\n",gethash(L->current->data,functionnumber));
        }
    }
}
Пример #9
0
static void luaB_call (void) {
  lua_Object f = luaL_nonnullarg(1);
  Hash *arg = gethash(2);
  char *options = luaL_opt_string(3, "");
  lua_Object err = lua_getparam(4);
  int narg = (int)getnarg(arg);
  int i, status;
  if (err != LUA_NOOBJECT) {  /* set new error method */
    lua_pushobject(err);
    err = lua_seterrormethod();
  }
  /* push arg[1...n] */
  luaD_checkstack(narg);
  for (i=0; i<narg; i++)
    *(L->stack.top++) = *luaH_getint(arg, i+1);
  status = lua_callfunction(f);
  if (err != LUA_NOOBJECT) {  /* restore old error method */
    lua_pushobject(err);
    lua_seterrormethod();
  }
  if (status != 0) {  /* error in call? */
    if (strchr(options, 'x')) {
      lua_pushnil();
      return;  /* return nil to signal the error */
    }
    else
      lua_error(NULL);
  }
  else {  /* no errors */
    if (strchr(options, 'p'))
      luaA_packresults();
    else
      luaA_passresults();
  }
}
Пример #10
0
void lunascan::addhash(int serial)
   {
   int i;

   unsigned int hash;

   hash=gethash(POOL[serial].string)%HASHSIZE;

   for (i=0; i<HASH[hash].num; i++)
      if (HASH[hash].serial[i]>=POOLSIZE)
         {
         HASH[hash].serial[i]=serial;
         return;
         }

   if (HASH[hash].num>=HASH[hash].maxnum)
      if (HASH[hash].serial==NULL)
         {
         if ((HASH[hash].serial=(int *)malloc(2*sizeof(int)))==NULL) MEMERROR();
         HASH[hash].maxnum=2;
         }
      else
         {
         if ((HASH[hash].serial=(int *)realloc(HASH[hash].serial,2*HASH[hash].maxnum*sizeof(int)))==NULL) MEMERROR();
         HASH[hash].maxnum*=2;
         }

   HASH[hash].serial[HASH[hash].num]=serial;
   HASH[hash].num++;
   }
Пример #11
0
/*
 * delete key/value
 */
int ConfigDel(tConfigDB* db,const void* pKey,int KeySize)
{
    tCluster * cluster = (tCluster*)db->cluster;
    tKey key;
    key.str = (char*)pKey;
    key.len = KeySize;
    unsigned int hash = gethash(key.str,key.len);
    hash = hash%MAX_NODE_NUM;/* distribute strategy */
    tNode* pNode = (tNode*)GetNode(cluster,hash);
    if(pNode->fd == 0)
    {
        return DBDelKeyValue(db->db,key);
    }
    else if(pNode->fd == -1)
    {
        pNode->fd = RemoteDBCreate(db->filename,pNode->addr,pNode->port);
        if(pNode->fd == -1)
        {
            return -1;
        }
        return RemoteDBDelKeyValue(pNode->fd,key);
    }
    else
    {
        return RemoteDBDelKeyValue(pNode->fd,key);
    }
}
Пример #12
0
/*
 * Get key/value
 */
int ConfigGet(tConfigDB* db,const void* pKey,int KeySize,void* pValue,int *pValueSize)
{
    tCluster * cluster = (tCluster*)db->cluster;
    int ret = -1;
    tKey key;
    key.str = (char*)pKey;
    key.len = KeySize;
    tValue value;
    value.str = (char*)pValue;
    value.len = *pValueSize;
    unsigned int hash = gethash(key.str,key.len);
    hash = hash%MAX_NODE_NUM;/* distribute strategy */
    tNode* pNode = (tNode*)GetNode(cluster,hash);
    /* hit local */
    if(pNode->fd == 0)
    {
        ret = DBGetKeyValue(db->db,key,&value);
    }
    else if(pNode->fd > 0)
    {
        ret = RemoteDBGetKeyValue(pNode->fd,key,&value);
    }
    else
    {
        pNode->fd = RemoteDBCreate(db->filename,pNode->addr,pNode->port);
        if(pNode->fd == -1)
        {
            return -1;
        }
        ret = RemoteDBGetKeyValue(pNode->fd,key,&value);
    }
    /* fail to get,get from master */
    if(ret == -1)
    {
        if(pNode == (tNode*)GetNode(cluster,MAX_NODE_NUM))
        {
            return -1;
        }
        tNode* pNode = (tNode*)GetNode(cluster,MAX_NODE_NUM);
        if(pNode->fd == 0)
        {
            ret = DBGetKeyValue(db->db,key,&value);
        }
        else if(pNode->fd > 0)
        {
            ret = RemoteDBGetKeyValue(pNode->fd,key,&value);
        }
        else
        {
            pNode->fd = RemoteDBCreate(db->filename,pNode->addr,pNode->port);
            if(pNode->fd == -1)
            {
                return -1;
            }
            ret = RemoteDBGetKeyValue(pNode->fd,key,&value);
        }  
    }
    *pValueSize = value.len;
    return SUCCESS;
}
Пример #13
0
static void luaB_next (void) {
  Hash *a = gethash(1);
  TObject *k = luaA_Address(luaL_nonnullarg(2));
  int i = (ttype(k) == LUA_T_NIL) ? 0 : luaH_pos(a, k)+1;
  if (luaA_next(a, i) == 0)
    lua_pushnil();
}
Пример #14
0
/// <summary>
///   Retreive type macro expansion
///   <para>
///     Note: We don't allow to put nil to m_types. If we detect it, we put
///     (lambda () nil) instead of nil.
///   </para>
/// </summary>
Val find_type(Val typespec, Val errorp, Val env)
{
    Val name = consp(typespec) ? car(typespec) : typespec;

    for (;;)
    {
        Environment* pEnv = env->DynamicCast<Environment>();
        if (NULL == pEnv)
        {
            if (nil != errorp)
            {
                error("Undefined type specifier: ~S", typespec);
            }
            return nil;
        }

        if (hash_table_p(pEnv->m_types))
        {
            Val found;
            Val thing = gethash(name, pEnv->m_types, nil, &found);
            if (nil != found)
            {
                return thing;
            }
        }

        env = pEnv->m_outer;
    } // for
} // find_type
Пример #15
0
static void *
check_realloc (void * ptr, size_t size)
{
  EMACS_INT present;
  size_t old_size;
  void *result = malloc (size);

  if (!ptr) return result;
  present = (EMACS_INT) gethash (ptr, pointer_table, (const void **) &old_size);
  if (!present)
    {
    /* This can only happen by reallocing a pointer that didn't
       come from malloc. */
#if !defined(__linux__)
      /* see comment in check_free(). */
      ABORT ();
#endif
      printf("Realloc'ing unmalloc'ed pointer at %p\n", ptr);
    }

  if (result == 0)
    goto end;
  memcpy (result, ptr, MIN (size, old_size));
  free (ptr);
 end:
  return result;
}
Пример #16
0
void bk_minimizeGraph(bk_Graph *f) {
	uint32_t rear = (uint32_t)(f->length - 1);
	while (rear > 0) {
		uint32_t front = rear;
		while (f->entries[front].height == f->entries[rear].height && front > 0) {
			front--;
		}
		front++;
		for (uint32_t j = front; j <= rear; j++) {
			f->entries[j].hash = gethash(f->entries[j].block);
		}
		for (uint32_t j = front; j <= rear; j++) {
			bk_GraphNode *a = &(f->entries[j]);
			if (a->alias == j) {
				for (uint32_t k = j + 1; k <= rear; k++) {
					bk_GraphNode *b = &(f->entries[k]);
					if (b->alias == k && compareEntry(a, b)) { b->alias = j; }
				}
			}
		}
		// replace pointers with aliased
		for (uint32_t j = 0; j < front; j++) {
			replaceptr(f, f->entries[j].block);
		}
		rear = front - 1;
	}
}
Пример #17
0
void
setoneicon (ControlHandle c)
{
  CInfoPBRec pb;
  item **ih;
  typeinfo *tip;

  ih = (item **) (*c)->contrlData;
  pb.hFileInfo.ioFDirIndex = 0;
  pb.hFileInfo.ioVRefNum = (*ih)->vrefnum;
  pb.hFileInfo.ioDirID = (*ih)->ioparid;
  pb.hFileInfo.ioNamePtr = (*c)->contrlTitle;
  PBGetCatInfo (&pb, false);
  if (pb.hFileInfo.ioFlAttrib & DIRBIT)
    {
      (*ih)->iconfam = &g_foldericonsptr;
      (*ih)->action = OPENDIR;
      (*ih)->size = 0;
      (*ih)->moddate = pb.dirInfo.ioDrMdDat;
    }
  else
    {
      (*ih)->iconfam = gethash (pb.hFileInfo.ioFlFndrInfo.fdType,
				pb.hFileInfo.ioFlFndrInfo.fdCreator);
      tip = gettypeinfo (pb.hFileInfo.ioFlFndrInfo.fdType);
      (*ih)->action = tip->action;
      (*ih)->size = pb.hFileInfo.ioFlLgLen;
      (*ih)->moddate = pb.hFileInfo.ioFlMdDat;
    }
}
Пример #18
0
void check(void)
{
	if(gethash()==myhash)
	{
		int flag=1;
		for(int i=qstart;getnext(i)!=qstart;i=getnext(i))
		{
			if(mystr[i-qstart]!=strq[i])
			{
				flag=0;
				return;
			}
		}
		if(flag==1)
		{
			k++;
			printf("No.%d: %d~%d\n",k,loc-mylen+1,loc);
			if(k>=32)
			{
				printf("Too many. \n");
                                exit(0);
			}
		}
	}
}
Пример #19
0
void main()
{
    char string[512];
    DWORD hash;
    printf("-----------Hash-calc---------\n");
    gets(string);
    hash=gethash(string);
    printf("result:0x%.8x\n",hash);
}
Пример #20
0
bool check()
{
     if(com != -1){
       for(int i = 1;i<=n;++i){
        if(cnt[i] > cnt[com]) return false; //case 1 length not satisfy
        if(cnt[i] == to[i]-from[i]+1 && (cnt[i] < cnt[com] || gethash(from[i],to[i]) != gethash(from[com],to[com])))
         return false;//case 2 without * string && len satisfy
        if(cnt[i] != to[i]-from[i]+1 && check(i,com)==false)
         return false;//case 3 *string
       }
       return true;
     }else {
      static int prev[MM],next[MM];
      int head = 1,tail = n;
      for(int i = 1;i<=n;++i)
       prev[i] = i-1,next[i] = i+1;
      while(head <= tail){
        char c = 0;
        for(int i = head;i<=tail;i=next[i])
        {
         if(str[from[i]] == '*')
         {
          prev[next[i]] = prev[i],next[prev[i]] = next[i];
          if(i == head )
           head = next[i];
          if(i == tail)
           tail = prev[i];
         }//delete invalid
         else if(c == 0)
          c = str[from[i]];
         else if(c != str[from[i]])
          return false;
         ++from[i];
        }
      }
      head = 1,tail = n;
      for(int i = 1;i<=n;++i)
       prev[i] = i-1,next[i] = i+1;
      while(head <= tail){
       char c = 0;
       for(int i = head;i<=tail;i=next[i])
       {
        if(str[to[i]] == '*'){
         prev[next[i]] = prev[i],next[prev[i]] = next[i];
         if(i == head) head = next[i];
         if(i == tail) tail = prev[i];
        }else if(c == 0)
         c = str[to[i]];
        else if(c != str[to[i]])
         return false;
        --to[i];
       }
      }
     }
     return true;
}
Пример #21
0
/*
 * Put key/value
 */	
int ConfigPut(tConfigDB* db,const void* pKey,int KeySize,const void* pValue,int ValueSize)
{
    tCluster * cluster = (tCluster*)db->cluster;
    int ret = -1;
    tKey key;
    key.str = (char*)pKey;
    key.len = KeySize;
    tValue value;
    value.str = (char*)pValue;
    value.len = ValueSize;
    unsigned int hash = gethash(key.str,key.len);
    hash = hash%MAX_NODE_NUM;/* distribute strategy */
    tNode* pNode = (tNode*)GetNode(cluster,hash);
    /* Put Data */
    if(pNode->fd == 0)
    {
        ret = DBSetKeyValue(db->db,key,value);
    }
    else if(pNode->fd == -1)
    {
        pNode->fd = RemoteDBCreate(db->filename,pNode->addr,pNode->port);
        if(pNode->fd == -1)
        {
            return -1;
        }
        ret = RemoteDBSetKeyValue(pNode->fd,key,value);
    }
    else
    {
        ret = RemoteDBSetKeyValue(pNode->fd,key,value);
    }
    /* Put Master */
    if(pNode != (tNode*)GetNode(cluster,MAX_NODE_NUM))
    {
        pNode = (tNode*)GetNode(cluster,MAX_NODE_NUM);
        if(pNode->fd == 0)
        {
            ret = DBSetKeyValue(db->db,key,value);
        }
        else if(pNode->fd == -1)
        {
            pNode->fd = RemoteDBCreate(db->filename,pNode->addr,pNode->port);
            if(pNode->fd == -1)
            {
                return -1;
            }
            ret = RemoteDBSetKeyValue(pNode->fd,key,value);
        }
        else
        {
            ret = RemoteDBSetKeyValue(pNode->fd,key,value);
        }
    }
    return ret;
}
Пример #22
0
static void luaB_tremove (void) {
  Hash *a = gethash(1);
  int n = (int)getnarg(a);
  int pos = luaL_opt_int(2, n);
  if (n <= 0) return;  /* table is "empty" */
  luaA_pushobject(luaH_getint(a, pos));  /* result = a[pos] */
  for ( ;pos<n; pos++)
    luaH_move(a, pos+1, pos);  /* a[pos] = a[pos+1] */
  luaV_setn(a, n-1);  /* a.n = n-1 */
  luaH_setint(a, n, &luaO_nilobject);  /* a[n] = nil */
}
Пример #23
0
static void luaB_sort (void) {
  lua_Object t = lua_getparam(1);
  Hash *a = gethash(1);
  int n = (int)getnarg(a);
  lua_Object func = lua_getparam(2);
  luaL_arg_check(func == LUA_NOOBJECT || lua_isfunction(func), 2,
                 "function expected");
  luaD_checkstack(4);  /* for Pivot, f, a, b (sort_comp) */
  auxsort(a, 1, n, func);
  lua_pushobject(t);
}
Пример #24
0
void
it_free_page (index_tree_t * it, buffer_desc_t * buf)
{
  short l;
  it_map_t * itm;
  dp_addr_t remap;
  ASSERT_IN_MAP (buf->bd_tree, buf->bd_page);
  itm = IT_DP_MAP (buf->bd_tree, buf->bd_page);
  remap = (dp_addr_t) (ptrlong) gethash (DP_ADDR2VOID (buf->bd_page), &itm->itm_remap);
  if (!buf->bd_is_write)
    GPF_T1 ("isp_free_page without write access to buffer.");
  dp_may_compact (buf->bd_storage, buf->bd_page); /* no need to keep deld buffers in checked for compact list */
  l=SHORT_REF (buf->bd_buffer + DP_FLAGS);
  if (!(l == DPF_BLOB || l == DPF_BLOB_DIR)
      && !remap)
    GPF_T1 ("Freeing a page that is not remapped");
  if (DPF_INDEX == l)
    it->it_n_index_est--;
  else
    it->it_n_blob_est--;
  if (buf->bd_page != buf->bd_physical_page && (DPF_BLOB_DIR == l || DPF_BLOB == l))
    GPF_T1 ("blob is not supposed to be remapped");
  DBG_PT_PRINTF (("    Delete %ld remap %ld FL=%d buf=%p\n", buf->bd_page, buf->bd_physical_page, l, buf));
  if (buf->bd_iq)
    {
      mutex_leave (&itm->itm_mtx);
      buf_cancel_write (buf);
      mutex_enter (&itm->itm_mtx);
    }

  if (!remap)
    {
      /* a blob in checkpoint space can be deleted without a remap existing in commit space. */
      if (DPF_BLOB != l && DPF_BLOB_DIR != l )
	GPF_T1 ("not supposed to delete a buffer in a different space unless it's a blob");
      if (buf->bd_is_dirty)
	GPF_T1 ("blob in checkpoint space can't be dirty - has no remap, in commit, hence is in checkpoint");
      sethash (DP_ADDR2VOID (buf->bd_page), &itm->itm_remap, (void*) (ptrlong) DP_DELETED);
      remhash (DP_ADDR2VOID (buf->bd_page), &itm->itm_dp_to_buf);
      page_leave_as_deleted (buf);
      return;
    }
  if (IS_NEW_BUFFER (buf))
    /* if this was CREATED AND DELETED without intervening checkpoint the delete
     * does not carry outside the commit space. */
    remhash (DP_ADDR2VOID (buf->bd_page), &itm->itm_remap);
  else
    sethash (DP_ADDR2VOID (buf->bd_page), &itm->itm_remap, (void *) (ptrlong) DP_DELETED);
  if (!remhash (DP_ADDR2VOID (buf->bd_page), &itm->itm_dp_to_buf))
    GPF_T1 ("it_free_page does not hit the buffer in tree cache");

  it_free_remap (it, buf->bd_page, buf->bd_physical_page, l);
  page_leave_as_deleted (buf);
}
Пример #25
0
void osiedl(long x,long y)
{
	long h=gethash(x,y);
	rycerz[r].x=x;
	rycerz[r].y=y;
	addtolist(hash[h],r);
	j[r].miny=y;
	j[r].maxy=y;
	coxadd(r);
	r++;
	rc++;
}
Пример #26
0
static void installVarType(Val const name, Val const typespec)
{
    Environment* const pEnv = VAR(Aruntime_environmentA)->
        StaticCast<Environment>();

    Val const frob = gethash(name, pEnv->m_variables);
    if (! consp(frob))
    {
        CAN_NOT_HAPPEN();
    }

    setf_cdr(cons(cons(Qtype, typespec), cdr(frob)), frob);
} // installVarType
Пример #27
0
int
puthash(Hash **ht, uint n, void *v)
{
	Hash *h;

	if(gethash(ht, n))
		return -1;
	h = emalloc(sizeof(Hash));
	h->next = ht[n%NHASH];
	h->n = n;
	h->v = v;
	ht[n%NHASH] = h;
	return 0;
}
Пример #28
0
int add_node (Node *table, Node *n){
	int hash = gethash(n->val);
	Node* tmp = &table[hash];
	while (tmp->next != NULL){
		if (tmp->val == n->val){
			printf ("ERROR: The value is already in the hash table\n");
			printf ("value in table %d, val to enter %d\n", tmp->val, n->val);
			return 0;
		}
		tmp = tmp->next;
	}
	tmp->next = n;
	return 1;
}
Пример #29
0
static void luaB_tinsert (void) {
  Hash *a = gethash(1);
  lua_Object v = lua_getparam(3);
  int n = (int)getnarg(a);
  int pos;
  if (v != LUA_NOOBJECT)
    pos = luaL_check_int(2);
  else {  /* called with only 2 arguments */
    v = luaL_nonnullarg(2);
    pos = n+1;
  }
  luaV_setn(a, n+1);  /* a.n = n+1 */
  for ( ;n>=pos; n--)
    luaH_move(a, n, n+1);  /* a[n+1] = a[n] */
  luaH_setint(a, pos, luaA_Address(v));  /* a[pos] = v */
}
Пример #30
0
unsigned char
WCHAR_TO_CHAR (wchar_t wchar, wcharset_t *charset)
{
  unsigned char value;
  if (charset && charset != CHARSET_UTF8 && wchar)
    {
      value = (unsigned char) ((ptrlong) gethash ((void *) (ptrlong) wchar, charset->chrs_ht));
      if (!value)
	value = '?';
    }
  else if (((unsigned long)wchar) < 0x100L)
    value = (unsigned char) wchar;
  else
    value = '?';

  return (value);
}