Beispiel #1
0
static int lump_hashcode(lts_t lts,int *map,int i){
    long j;
    uint32_t temp[2];
    uint32_t contrib[3];
    int last=lts->begin[i+1]-1;
    int hc=map[i];
    //int sigptr=0, *sig=alloca(2*(last-lts->begin[i]));
    //Warning(1,"signature for %d %x %x",i,sig,map);
    for(j=lts->begin[i];j<=last;j++){
        int block=map[lts->dest[j]];
        contrib[2]=block;
        TreeUnfold(lts->edge_idx,lts->label[j],(int*)contrib);
        //Warning(1,"collecting");
        while(j<last && block==map[lts->dest[j+1]]){
            j++;
            TreeUnfold(lts->edge_idx,lts->label[j],(int*)temp);
            uint64_t teller=((uint64_t)contrib[0])*((uint64_t)temp[1]);
                    teller+=((uint64_t)temp[0])*((uint64_t)contrib[1]);
            uint64_t noemer=((uint64_t)contrib[1])*((uint64_t)temp[1]);
            uint64_t gcd=gcd64(teller,noemer);
            contrib[0]=teller/gcd;
            contrib[1]=noemer/gcd;
        }
        hc=SuperFastHash(contrib,12,hc);
    }
    return hc;
}
Beispiel #2
0
void SIdeleteC(string_index_t si,const char*str,int len){
	uint32_t hash;
	int bucket;
	int idx,next,deleted;

	hash=SuperFastHash(str,len,0);
	bucket=hash&si->mask;
	idx=si->table[bucket];
	si->table[bucket]=END_OF_LIST;
	while(idx!=END_OF_LIST){
		if (0==strcmp(str,si->data[idx])) {
			deleted=idx;
			RTfree(si->data[idx]);
			si->count--;
			idx=si->next[idx];
			while(idx!=END_OF_LIST){
				next=si->next[idx];
				si->next[idx]=si->table[bucket];
				si->table[bucket]=idx;
				idx=next;
			}
			add_to_free_list(si,deleted);
			return;
		} else {
			next=si->next[idx];
			si->next[idx]=si->table[bucket];
			si->table[bucket]=idx;
			idx=next;
		}
	}
}
Beispiel #3
0
TCHAR * CHashedStringList::Find(TCHAR * String)
{
	TCHAR * buff;
	if (!m_bCaseSense)
	{
		buff = _wcsdup(String);
		_wcslwr(buff);
	}
	else
		buff = String;
	UINT32 hash = SuperFastHash(buff, wcslen(buff))%m_Size;	//获得模数
	CMHashItem * hashitem = m_hashitem[hash].next;
	while (hashitem && _wcsicmp(hashitem->String, buff))
		hashitem = hashitem->next;
	if (hashitem)	//找到了这一项
	{
		if (!m_bCaseSense)
			free(buff);
		return hashitem->Value;
	}
	else
	{
		if (!m_bCaseSense)
			free(buff);
		return NULL;	//找不到
	}
}
void RSManagerDX9::registerD3DXCreateTextureFromFileInMemory(LPCVOID pSrcData, UINT SrcDataSize, LPDIRECT3DTEXTURE9 pTexture) {
	SDLOG(1, "RenderstateManager: registerD3DXCreateTextureFromFileInMemory %p | %p (size %d)\n", pTexture, pSrcData, SrcDataSize);
	if(Settings::get().getEnableTextureDumping()) {
		UINT32 hash = SuperFastHash((char*)const_cast<void*>(pSrcData), SrcDataSize);
		SDLOG(1, " - size: %8u, hash: %8x\n", SrcDataSize, hash);

		IDirect3DSurface9* surf = NULL;
		((IDirect3DTexture9*)pTexture)->GetSurfaceLevel(0, &surf);
		if(surf != NULL) {
			string directory = getInstalledFileName(format("textures\\%s\\dump\\", getExeFileName().c_str()));
			SDLOG(1, "%s\n", boost::filesystem::path(directory).string().c_str())
				try {
				boost::filesystem::create_directories(boost::filesystem::path(directory));
				string fn = format("%s%08x.tga", directory.c_str(), hash);
				SDLOG(1, " - dumping texture to %s\n", fn);
				if(SUCCEEDED(D3DXSaveSurfaceToFile(fn.c_str(), D3DXIFF_TGA, surf, NULL, NULL))) {
					SDLOG(1, " - texture dumped\n");
				}
				else {
					SDLOG(-1, "ERROR while texture dumping (D3DX)\n");
				}
			}
			catch(boost::filesystem::filesystem_error e) {
				SDLOG(-1, "ERROR - Filesystem error while trying to create directory:\n%s\n", e.what());
			}
			surf->Release();
		}
Beispiel #5
0
banlist_client_entry_t *banlist_client_add (banlist_client_t * list, unsigned char *client,
					    double minVersion, double maxVersion, buffer_t * reason)
{
  banlist_client_entry_t *b;

  /* delete any prior ban of this client */
  banlist_client_del_byclient (list, client, minVersion, maxVersion);

  /* alloc and clear new element */
  b = malloc (sizeof (banlist_client_entry_t));

  /* init */
  dllist_init (&b->dllist);
  strncpy (b->client, client, NICKLENGTH);
  b->client[NICKLENGTH - 1] = 0;
  b->minVersion = minVersion;
  b->maxVersion = maxVersion;
  if (reason) {
    b->message = bf_copy (reason, 1);
  } else
    b->message = bf_alloc (1);
  *b->message->e = 0;

  /* put in hashlist */
  dlhashlist_prepend (list, SuperFastHash (client, strlen (client)) & BANLIST_NICK_HASHMASK, b);

  return b;
}
Beispiel #6
0
static void len_resize(void*arg,void*old_array,int old_size,void*new_array,int new_size){
    DEBUG("extend during len resize from %d to %d",old_size,new_size);
    (void)old_array;
    (void)new_array;
    string_index_t si=(string_index_t)arg;
    expand_free_list(si,old_size,new_size);
	if ((si->mask*FILL_OUTOF)<(si->count*FILL_MAX)){
		int i,current,next,N;
	    uint32_t hash;
    	uint32_t len;
	    int bucket;

		N=si->mask+1;
		DEBUG("resizing table from %d to %d",N,N+N);
		si->mask=(si->mask<<1)+1;
		si->table=(int*)RTrealloc(si->table,(si->mask+1)*sizeof(int));
		for(i=0;i<N;i++){
			current=si->table[i];
			si->table[i]=END_OF_LIST;
			si->table[N+i]=END_OF_LIST;
			while(current!=END_OF_LIST){
				next=si->next[current];
				len=si->len[current];
				hash=SuperFastHash(si->data[current],len,0);
				bucket=hash&si->mask;
				HREassert(bucket==i||bucket==N+i,"error");
				si->next[current]=si->table[bucket];
				si->table[bucket]=current;
				DEBUG("moving %s from %d to %d",si->data[current],i,bucket);
				current=next;
			}
		}
	}   
}
Beispiel #7
0
void CHashedStringList::Add(TCHAR * String, TCHAR * Value)
{
	TCHAR * buff;
	if (!m_bCaseSense)
	{
		buff = _wcsdup(String);
		_wcslwr(buff);
	}
	else
		 buff = String;
	UINT32 hash = SuperFastHash(buff, wcslen(buff))%m_Size;	//获得模数
	CMHashItem * hashitem = m_hashitem[hash].next;
	CMHashItem * parent = &m_hashitem[hash];
	while (hashitem && _wcsicmp(hashitem->String, buff))
	{
		parent = hashitem;
		hashitem = hashitem->next;
	}
	if (!hashitem)
	{
		parent->next = (CMHashItem*)malloc(sizeof(CMHashItem));	//还不存在这一项
		hashitem = parent->next;
		if (!m_bCaseSense)
			hashitem->String = buff;
		else
			hashitem->String = _wcsdup(buff);
		hashitem->Value = _wcsdup(Value);
		hashitem->next = NULL;
	}
	else
		if (!m_bCaseSense)
			free(buff);		//已经存在这一项了
}
Beispiel #8
0
void CHashedStringList::Delete(TCHAR * String)
{
	TCHAR * buff;
	if (!m_bCaseSense)
	{
		buff = _wcsdup(String);
		_wcslwr(buff);
	}
	else
		buff = String;
	UINT32 hash = SuperFastHash(buff, wcslen(buff))%m_Size;	//获得模数
	CMHashItem * hashitem = m_hashitem[hash].next;
	CMHashItem * parent = &m_hashitem[hash];
	while (hashitem && _wcsicmp(hashitem->String, buff))
	{
		parent = hashitem;
		hashitem = hashitem->next;
	}
	if (hashitem)	//找到了这一项
	{
		parent->next=hashitem->next;
		free(hashitem->String);
		free(hashitem->Value);
		free(hashitem);
	}
	if (!m_bCaseSense)
		free(buff);	
}
Beispiel #9
0
HRESULT RSManager::redirectD3DXCreateTextureFromFileInMemoryEx(LPDIRECT3DDEVICE9 pDevice, LPCVOID pSrcData, UINT SrcDataSize, UINT Width, UINT Height, UINT MipLevels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, DWORD Filter, DWORD MipFilter, D3DCOLOR ColorKey, D3DXIMAGE_INFO* pSrcInfo, PALETTEENTRY* pPalette, LPDIRECT3DTEXTURE9* ppTexture) {
	if(Settings::get().getEnableTextureOverride()) {
		UINT32 hash = SuperFastHash((char*)const_cast<void*>(pSrcData), SrcDataSize);
		SDLOG(4, "Trying texture override size: %8u, hash: %8x\n", SrcDataSize, hash);
		
        if (Settings::get().getEnableTexturePrefetch() && cachedTexFiles.find(hash) != cachedTexFiles.end())
        {
            SDLOG(4, "Cached texture file found! size: %ld, hash: %8x \n", cachedTexFiles[hash].size, hash);
            return TrueD3DXCreateTextureFromFileInMemoryEx(pDevice, cachedTexFiles[hash].buffer, cachedTexFiles[hash].size, D3DX_DEFAULT, D3DX_DEFAULT, MipLevels, Usage, D3DFMT_FROM_FILE, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);
        }
        else
        {
            char buffer[128];
            sprintf_s(buffer, "dsfix/tex_override/%08x.png", hash);
            if (fileExists(buffer)) {
                SDLOG(4, "Texture override (png)! hash: %08x\n", hash);
                return D3DXCreateTextureFromFileEx(pDevice, buffer, D3DX_DEFAULT, D3DX_DEFAULT, MipLevels, Usage, D3DFMT_FROM_FILE, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);
            }
            sprintf_s(buffer, "dsfix/tex_override/%08x.dds", hash);
            if (fileExists(buffer)) {
                SDLOG(4, "Texture override (dds)! hash: %08x\n", hash);
                return D3DXCreateTextureFromFileEx(pDevice, buffer, D3DX_DEFAULT, D3DX_DEFAULT, MipLevels, Usage, D3DFMT_FROM_FILE, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);
            }
        }
	}
    return TrueD3DXCreateTextureFromFileInMemoryEx(pDevice, pSrcData, SrcDataSize, Width, Height, MipLevels, Usage, Format, Pool, Filter, MipFilter, ColorKey, pSrcInfo, pPalette, ppTexture);
}
Beispiel #10
0
/**
 * _exp_file_insert -- Insert the exports directory into the file structure
 *                     using the directory as a dict. Also hashes the dirname,
 *                     stores it in a uuid type, converts the uuid type to a
 *                     string and uses that as the key to the exports map.
 *                     The exports map maps an export "uuid" to an export
 *                     directory struct.
 *
 * @file : Exports file struct to insert into
 * @dir  : Export directory to insert
 *
 * Not for external use.
 */
static void
_exp_file_insert(struct exports_file *file, struct export_dir *dir)
{
    data_t *dirdata = NULL;
    uint32_t hashedval = 0;
    uuid_t export_uuid = {
        0,
    };
    char export_uuid_str[512] = {
        0,
    };
    char *dirdup = NULL;

    GF_VALIDATE_OR_GOTO(GF_EXP, file, out);
    GF_VALIDATE_OR_GOTO(GF_EXP, dir, out);

    dirdata = bin_to_data(dir, sizeof(*dir));
    dict_set(file->exports_dict, dir->dir_name, dirdata);

    dirdup = strdupa(dir->dir_name);
    while (strlen(dirdup) > 0 && dirdup[0] == '/')
        dirdup++;

    hashedval = SuperFastHash(dirdup, strlen(dirdup));
    memset(export_uuid, 0, sizeof(export_uuid));
    memcpy(export_uuid, &hashedval, sizeof(hashedval));
    gf_uuid_unparse(export_uuid, export_uuid_str);

    dict_set(file->exports_map, export_uuid_str, dirdata);
out:
    return;
}
Beispiel #11
0
SEXP R_hash_charvec(SEXP X, SEXP NTHRD){
  PROTECT(X);
  PROTECT(NTHRD);
  int n = length(X)
    , nthrd = INTEGER(NTHRD)[0];

  SEXP H;
  PROTECT(H = allocVector(INTSXP,length(X)));

  #ifdef _OPENMP
  #pragma omp parallel num_threads(nthrd)
  #endif
  {
    int *h = INTEGER(H)
      , ID = 0
      , nthreads = 1L;
    #ifdef _OPENMP
    ID = omp_get_thread_num();
    nthreads = omp_get_num_threads();
    #endif
    for (int i = ID; i < n; i += nthreads ) {
     h[i] = (int) SuperFastHash( CHAR(STRING_ELT(X,i)), length(STRING_ELT(X,i)));
    }
  }// end of parallel region

  UNPROTECT(3);
  return H;

}
 std::string cli::url_to_id(const std::string &url)
 {
   std::string url_lc = url;
   miscutil::to_lower(url_lc);
   url_lc = cli::strip_url(url_lc);
   uint32_t id = SuperFastHash(url_lc.c_str(),url_lc.size());
   return miscutil::to_string(id);
 }
Beispiel #13
0
static inline FlowTableRecord_t *hash_lookup_FlowTable(uint32_t *index_cache, void *flowkey, master_record_t *flow_record) {
uint32_t			index;
int bsize;
FlowTableRecord_t	*record;

	*index_cache = SuperFastHash((char *)flowkey, FlowTable.keysize);
	index = *index_cache & FlowTable.IndexMask;

	if ( FlowTable.bucket[index] == NULL ) {
		hash_hit++;
		return NULL;
	}

	record = FlowTable.bucket[index];

	// skip records with different hash value ( full 32bit )
	while ( record )
		if ( record->hash != *index_cache ) {
			hash_skip++;
			record = record->next;
		} else
			break;

	bsize = 0;
	while ( record ) {
		uint64_t	*k1 = (uint64_t *)flowkey;
		uint64_t	*k2 = (uint64_t *)record->hash_key;
		int i;
		
		// compare key and break as soon as keys do not match
		i = 0;
		while ( i < FlowTable.keylen ) {
			if ( k1[i] == k2[i] )
				i++;
			else
				break;
		}
		loopcnt += i;

		if ( i == FlowTable.keylen ) {
			// hit - record found
		
			// some stats for debugging
			if ( bsize == 0 )
				hash_hit++;
			else
				hash_miss++;
			return record;
		}

		record = record->next;
		bsize++;
	}
	return NULL;

} // End of hash_lookup_FlowTable
Beispiel #14
0
// Return associated index of the value, or -1 if not found.
// In case of collision, apply quadratic probing.
NgramIndex
NgramVector::Find(NgramIndex hist, VocabIndex word) const {
    size_t     skip = 0;
    NgramIndex pos = SuperFastHash(hist, word) & _hashMask;
    NgramIndex index;
    while ((index = _indices[pos]) != Invalid &&
           !(_words[index] == word && _hists[index] == hist))
        pos = (pos + ++skip) & _hashMask;
    return index;
}
Beispiel #15
0
unsigned long HashFunction(const char* key)
{
	/*
	unsigned long hash = 5381;
	int c;
	
	while ((c = *key++))
		hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
		
	return SuperFastHash(key, strlen(key));
}
Beispiel #16
0
uint32_t lookup(uint8_t *k,  uint32_t length,  uint32_t initval)
{
#ifdef HAVE_SFHASH
  return SuperFastHash((const char*)k, length, initval);
#elif HAVE_LOOKUP3
#if LITTLE_ENDIAN
  return hashlittle(k, length, initval);
#elif BIG_ENDIAN
  return hashbig(k, length, initval);
#endif
#endif
}
Beispiel #17
0
SEXP R_hash_raw(SEXP X){
  PROTECT(X);
  
  SEXP h; 
  PROTECT(h = allocVector(INTSXP,1L));
  
  INTEGER(h)[0] = (int) SuperFastHash((char *) RAW(X),length(X));


  UNPROTECT(2);
  return h;
}
Beispiel #18
0
int SIlookupC(string_index_t si,const char*str,int len){
	uint32_t hash;
	int bucket;
	int idx;

	hash=SuperFastHash(str,len,0);
	bucket=hash&si->mask;
	for(idx=si->table[bucket];idx!=END_OF_LIST;idx=si->next[idx]){
		if (si->len[idx]!=len) continue;
		if (0==memcmp(str,si->data[idx],len)) return idx;
	}
	return SI_INDEX_FAILED;
}
Beispiel #19
0
// Resize index table to the specified capacity.
void
NgramVector::_Reindex(size_t indexSize) {
    assert(indexSize >= size() && isPowerOf2(indexSize));
    _indices.reset(indexSize, Invalid);
    _hashMask = indexSize - 1;
    for (NgramIndex i = 0; i < (NgramIndex)size(); i++) {
        size_t     skip = 0;
        NgramIndex pos  = SuperFastHash(_hists[i], _words[i]) & _hashMask;
        while (_indices[pos] != Invalid)
            pos = (pos + ++skip) & _hashMask;
        _indices[pos] = i;
    }
}
Beispiel #20
0
FSharedStringArena::Node *FSharedStringArena::FindString(const char *str, size_t strlen, unsigned int &hash)
{
	hash = SuperFastHash(str, strlen);

	for (Node *node = Buckets[hash % countof(Buckets)]; node != NULL; node = node->Next)
	{
		if (node->Hash == hash && node->String.Len() == strlen && memcmp(&node->String[0], str, strlen) == 0)
		{
			return node;
		}
	}
	return NULL;
}
Beispiel #21
0
void write_hash_to_file(int i, unsigned char* data) {
    uint32_t hashed = SuperFastHash(data, PAGE_SIZE);
    //file_write(logFile, i*4096, data, 4096);
    unsigned char charHash[4];
    charHash[0] = hashed>>24;
    charHash[1] = hashed>>16;
    charHash[2] = hashed>>8;
    charHash[3] = hashed;
    /*if(i<10){
      printk("i=%d Hash %u", i, hashed);
      printk(" Character hash %c %c %c %c\n", charHash[0], charHash[1], charHash[2], charHash[3]);
    }*/
    file_write(logFile, i*4, charHash, 4);
}
Beispiel #22
0
uint32_t HashAlgorithm::run(const char *key) {
	if (hashAlgorithmInitialized == false) {
		systemLog->sysLog(ERROR, "HashAlgorithm object is not initialized properly");
		return 0;
	}
	switch (algorithmType) {
		case ALGO_PAULHSIEH:
			return SuperFastHash(key);
			break;
	}

	// Never executed normally
	return 0;
}
Beispiel #23
0
EPUB3ManifestItemListItemPtr EPUB3ManifestFindItemWithId(EPUB3ManifestRef manifest, const char * itemId)
{
  assert(manifest != NULL);
  assert(itemId != NULL);

  int32_t bucket = SuperFastHash(itemId, (int32_t)strlen(itemId)) % MANIFEST_HASH_SIZE;
  EPUB3ManifestItemListItemPtr itemPtr = manifest->itemTable[bucket];
  while(itemPtr != NULL) {
    if(strcmp(itemId, itemPtr->item->itemId) == 0) {
      return itemPtr;
    }
    itemPtr = itemPtr->next;
  }
  return NULL;
}
Beispiel #24
0
void RSManager::registerD3DXCreateTextureFromFileInMemory(LPCVOID pSrcData, UINT SrcDataSize, LPDIRECT3DTEXTURE9 pTexture) {
	SDLOG(1, "RenderstateManager: registerD3DXCreateTextureFromFileInMemory %p\n", pTexture);
	if(Settings::get().getEnableTextureDumping()) {
		UINT32 hash = SuperFastHash((char*)const_cast<void*>(pSrcData), SrcDataSize);
		SDLOG(1, " - size: %8u, hash: %8x\n", SrcDataSize, hash);

		IDirect3DSurface9* surf;
		((IDirect3DTexture9*)pTexture)->GetSurfaceLevel(0, &surf);
		char buffer[128];
		sprintf_s(buffer, "dsfix/tex_dump/%08x.tga", hash);
		D3DXSaveSurfaceToFile(GetDirectoryFile(buffer), D3DXIFF_TGA, surf, NULL, NULL);
		surf->Release();
	}
	registerKnowTexture(pSrcData, SrcDataSize, pTexture);
}
Beispiel #25
0
void RSManager::registerKnowTexture(LPCVOID pSrcData, UINT SrcDataSize, LPDIRECT3DTEXTURE9 pTexture) {
	if(foundKnownTextures < numKnownTextures) {
		UINT32 hash = SuperFastHash((char*)const_cast<void*>(pSrcData), SrcDataSize);
		#define TEXTURE(_name, _hash) \
		if(hash == _hash) { \
			texture##_name = pTexture; \
			++foundKnownTextures; \
			SDLOG(1, "RenderstateManager: recognized known texture %s at %u\n", #_name, pTexture); \
		}
		#include "Textures.def"
		#undef TEXTURE
		if(foundKnownTextures == numKnownTextures) {
			SDLOG(1, "RenderstateManager: all known textures found!\n");
		}
	}
}
Beispiel #26
0
banlist_client_entry_t *banlist_client_find (banlist_client_t * list, unsigned char *client,
					     double version)
{
  banlist_client_entry_t *e, *l;

  l = dllist_bucket (list, SuperFastHash (client, strlen (client)) & BANLIST_NICK_HASHMASK);
  dllist_foreach (l, e)
    if (!strncmp (e->client, client, NICKLENGTH)
	&& ((version == 0) || ((version >= e->minVersion) && (version <= e->maxVersion))))
    break;

  if (e == dllist_end (l))
    return 0;

  return e;
}
Beispiel #27
0
unsigned int banlist_client_del_byclient (banlist_client_t * list, unsigned char *client,
					  double min, double max)
{
  banlist_client_entry_t *e, *l;

  l = dllist_bucket (list, SuperFastHash (client, strlen (client)) & BANLIST_NICK_HASHMASK);
  dllist_foreach (l, e)
    if ((!strncmp (e->client, client, NICKLENGTH)) && (e->minVersion == min)
	&& (e->maxVersion == max))
    break;

  if (e == dllist_end (l))
    return 0;

  dllist_del ((dllist_entry_t *) e);
  return 1;
}
Beispiel #28
0
banlist_entry_t *banlist_add (banlist_t * list, unsigned char *op, unsigned char *nick, uint32_t ip,
			      uint32_t netmask, buffer_t * reason, unsigned long expire)
{
  banlist_entry_t *b;
  uint32_t i;
  unsigned char n[NICKLENGTH];
  unsigned int l;

  /* bad netmask */
  i = netmask_to_numbits (netmask);
  if (i > 32)
    return NULL;

  l = nicktolower (n, nick);

  /* delete any earlier bans of this ip. */
  if ((b = banlist_find_exact (list, nick, ip, netmask)))
    banlist_del (list, b);

  /* alloc and clear new element */
  b = malloc (sizeof (banlist_entry_t));

  /* init */
  dllist_init (&b->list_ip);
  dllist_init (&b->list_name);
  strncpy (b->nick, nick, NICKLENGTH);
  b->nick[NICKLENGTH - 1] = 0;
  strncpy (b->op, op, NICKLENGTH);
  b->op[NICKLENGTH - 1] = 0;
  b->ip = ip & netmask;
  b->netmask = netmask;
  b->message = bf_copy (reason, 1);
  *b->message->e = 0;
  b->expire = expire;

  /* mask netmask as used */
  list->netmask_inuse[i]++;

  /* put in hashlist */
  dlhashlist_prepend (&list->list_ip, one_at_a_time (ip & netmask) & BANLIST_HASHMASK,
		      (&b->list_ip));
  dlhashlist_prepend (&list->list_name, SuperFastHash (n, l) & BANLIST_NICK_HASHMASK,
		      (&b->list_name));

  return b;
}
Beispiel #29
0
banlist_entry_t *banlist_find_bynick (banlist_t * list, unsigned char *nick)
{
  dllist_entry_t *p, *l;
  banlist_entry_t *e;
  unsigned char n[NICKLENGTH];
  unsigned int i;

  ASSERT (*nick);

  i = nicktolower (n, nick);
repeat:
  l = dllist_bucket (&list->list_name, SuperFastHash (n, i) & BANLIST_NICK_HASHMASK);
  dllist_foreach (l, p) {
    e = (banlist_entry_t *) ((char *) p - sizeof (dllist_t));
    if (!strncasecmp (e->nick, nick, NICKLENGTH))
      break;
  }
Beispiel #30
0
static void PutEntry(string_index_t si,const char*str,int s_len,int index){
	uint32_t hash;
	int bucket;

    ensure_access(si->man,index);
	HREassert (si->next[index] < 0, "Cannot put %s at %d: position occupied by %s",
	                                str,index,si->data[index]);
	cut_from_free_list(si,index);
	si->len[index]=s_len;
	si->data[index]=RTmalloc(s_len+1);
	memcpy(si->data[index],str,s_len);
	(si->data[index])[s_len]=0;
	hash=SuperFastHash(str,s_len,0);
	bucket=hash&si->mask;
	si->next[index]=si->table[bucket];
	si->table[bucket]=index;
	si->count++;
}