Lines Matching refs:p

105 static unsigned int zipmapDecodeLength(unsigned char *p) {  in zipmapDecodeLength()  argument
106 unsigned int len = *p; in zipmapDecodeLength()
109 memcpy(&len,p+1,sizeof(unsigned int)); in zipmapDecodeLength()
116 static unsigned int zipmapEncodeLength(unsigned char *p, unsigned int len) { in zipmapEncodeLength() argument
117 if (p == NULL) { in zipmapEncodeLength()
121 p[0] = len; in zipmapEncodeLength()
124 p[0] = ZIPMAP_BIGLEN; in zipmapEncodeLength()
125 memcpy(p+1,&len,sizeof(len)); in zipmapEncodeLength()
126 memrev32ifbe(p+1); in zipmapEncodeLength()
139 unsigned char *p = zm+1, *k = NULL; in zipmapLookupRaw() local
142 while(*p != ZIPMAP_END) { in zipmapLookupRaw()
146 l = zipmapDecodeLength(p); in zipmapLookupRaw()
148 if (key != NULL && k == NULL && l == klen && !memcmp(p+llen,key,l)) { in zipmapLookupRaw()
152 k = p; in zipmapLookupRaw()
154 return p; in zipmapLookupRaw()
157 p += llen+l; in zipmapLookupRaw()
159 l = zipmapDecodeLength(p); in zipmapLookupRaw()
160 p += zipmapEncodeLength(NULL,l); in zipmapLookupRaw()
161 free = p[0]; in zipmapLookupRaw()
162 p += l+1+free; /* +1 to skip the free byte */ in zipmapLookupRaw()
164 if (totlen != NULL) *totlen = (unsigned int)(p-zm)+1; in zipmapLookupRaw()
178 static unsigned int zipmapRawKeyLength(unsigned char *p) { in zipmapRawKeyLength() argument
179 unsigned int l = zipmapDecodeLength(p); in zipmapRawKeyLength()
185 static unsigned int zipmapRawValueLength(unsigned char *p) { in zipmapRawValueLength() argument
186 unsigned int l = zipmapDecodeLength(p); in zipmapRawValueLength()
190 used += p[used] + 1 + l; in zipmapRawValueLength()
197 static unsigned int zipmapRawEntryLength(unsigned char *p) { in zipmapRawEntryLength() argument
198 unsigned int l = zipmapRawKeyLength(p); in zipmapRawEntryLength()
199 return l + zipmapRawValueLength(p+l); in zipmapRawEntryLength()
215 unsigned char *p; in zipmapSet() local
219 p = zipmapLookupRaw(zm,key,klen,&zmlen); in zipmapSet()
220 if (p == NULL) { in zipmapSet()
223 p = zm+zmlen-1; in zipmapSet()
232 freelen = zipmapRawEntryLength(p); in zipmapSet()
237 offset = p-zm; in zipmapSet()
239 p = zm+offset; in zipmapSet()
243 memmove(p+reqlen, p+freelen, zmlen-(offset+freelen+1)); in zipmapSet()
257 offset = p-zm; in zipmapSet()
258 memmove(p+reqlen, p+freelen, zmlen-(offset+freelen+1)); in zipmapSet()
261 p = zm+offset; in zipmapSet()
269 p += zipmapEncodeLength(p,klen); in zipmapSet()
270 memcpy(p,key,klen); in zipmapSet()
271 p += klen; in zipmapSet()
273 p += zipmapEncodeLength(p,vlen); in zipmapSet()
274 *p++ = vempty; in zipmapSet()
275 memcpy(p,val,vlen); in zipmapSet()
283 unsigned char *p = zipmapLookupRaw(zm,key,klen,&zmlen); in zipmapDel() local
284 if (p) { in zipmapDel()
285 freelen = zipmapRawEntryLength(p); in zipmapDel()
286 memmove(p, p+freelen, zmlen-((p-zm)+freelen+1)); in zipmapDel()
335 unsigned char *p; in zipmapGet() local
337 if ((p = zipmapLookupRaw(zm,key,klen,NULL)) == NULL) return 0; in zipmapGet()
338 p += zipmapRawKeyLength(p); in zipmapGet()
339 *vlen = zipmapDecodeLength(p); in zipmapGet()
340 *value = p + ZIPMAP_LEN_BYTES(*vlen) + 1; in zipmapGet()
355 unsigned char *p = zipmapRewind(zm); in zipmapLen() local
356 while((p = zipmapNext(p,NULL,NULL,NULL,NULL)) != NULL) len++; in zipmapLen()
374 static void zipmapRepr(unsigned char *p) { in zipmapRepr() argument
377 printf("{status %u}",*p++); in zipmapRepr()
379 if (p[0] == ZIPMAP_END) { in zipmapRepr()
385 l = zipmapDecodeLength(p); in zipmapRepr()
387 p += zipmapEncodeLength(NULL,l); in zipmapRepr()
388 if (l != 0 && fwrite(p,l,1,stdout) == 0) perror("fwrite"); in zipmapRepr()
389 p += l; in zipmapRepr()
391 l = zipmapDecodeLength(p); in zipmapRepr()
393 p += zipmapEncodeLength(NULL,l); in zipmapRepr()
394 e = *p++; in zipmapRepr()
395 if (l != 0 && fwrite(p,l,1,stdout) == 0) perror("fwrite"); in zipmapRepr()
396 p += l+e; in zipmapRepr()