示例#1
0
IoSymbol *IoState_addSymbol_(IoState *self, IoSymbol *s)
{
	CHash_at_put_(self->symbols, IoSeq_rawUArray(s), s);
	IoObject_isSymbol_(s, 1);
	s->hash1 = RandomGen_randomInt(self->randomGen) | 0x1;
	s->hash2 = RandomGen_randomInt(self->randomGen) << 1;
	return s;
}
示例#2
0
文件: CHash.c 项目: doublec/io
int CHash_insertRecords(CHash *self, unsigned char *oldRecords, size_t oldSize)
{
    size_t i;

    for (i = 0; i < oldSize; i ++)
    {
        CHashRecord *r = CRecords_recordAt_(oldRecords, i);

        if (r->k)
        {
            if(CHash_at_put_(self, r->k, r->v)) return 1;
        }
    }
    return 0;
}
示例#3
0
void HttpRequest_parseUri_(HttpRequest *self, const char *uri)
{
	Datum_setCString_(self->uri, uri);
	
	int index;
	Datum *uriDatum = Datum_poolNew();
	Datum_setCString_(uriDatum, uri);
	
	//if (self->debug) { Log_Printf_("request: %s\n", uri); }
	
	CHash_clear(self->query);
	
	Datum_setSize_(self->uriPath, 0);
	index = Datum_from_beforeChar_into_(uriDatum, 1, '?', self->uriPath);
	Datum_decodeUri(self->uriPath);
	
	for (;;)
	{
		Datum *key   = Datum_poolNew();
		Datum *value = Datum_poolNew();
		
		index = Datum_from_beforeChar_into_(uriDatum, index + 1, '=', key);
		Datum_decodeUri(key);
		Datum_nullTerminate(key);
		if (Datum_size(key) == 0) break;
		
		index = Datum_from_beforeChar_into_(uriDatum, index + 1, '&', value);
		Datum_decodeUri(value);
		Datum_nullTerminate(value);

		CHash_at_put_(self->query, key, value);
		
		if(self->requestParameterCallback)
		{
			self->requestParameterCallback(self->delegate, key, value);
		}
		
		if (Datum_size(value) == 0) break;
	}	
}
示例#4
0
文件: CHash.c 项目: doublec/io
int CHash_insert_(CHash *self, CHashRecord *x)
{
    int n;

    for (n = 0; n < CHASH_MAXLOOP; n ++)
    {
        CHashRecord *r;

        //pos = self->hash1(x->k) & self->mask;
        //printf("1 x->k = %p-> %i\n", x->k, pos);
        r = CHash_record1_(self, x->k);
        CHashRecord_swapWith_(x, r); //x ↔ T1 [h1 (x)]
        if(x->k == 0x0) {
            self->keyCount ++;
            return 0;
        }

        //pos = self->hash2(x->k) & self->mask;
        //printf("2 x->k = %p-> %i\n\n", x->k, pos);
        r = CHash_record2_(self, x->k);
        CHashRecord_swapWith_(x, r); //x ↔ T2 [h2 (x)]
        if(x->k == 0x0) {
            self->keyCount ++;
            return 0;
        }
    }

    if(self->isResizing)
    {
        return -1;
    }

    CHash_grow(self);
    CHash_at_put_(self, x->k, x->v);
    return 0;
}