Compare element in sorted set with given element. */
| 763 | |
| 764 | /* Compare element in sorted set with given element. */ |
| 765 | int zzlCompareElements(unsigned char *eptr, unsigned char *cstr, unsigned int clen) { |
| 766 | unsigned char *vstr; |
| 767 | unsigned int vlen; |
| 768 | long long vlong; |
| 769 | unsigned char vbuf[32]; |
| 770 | int minlen, cmp; |
| 771 | |
| 772 | serverAssert(ziplistGet(eptr,&vstr,&vlen,&vlong)); |
| 773 | if (vstr == NULL) { |
| 774 | /* Store string representation of long long in buf. */ |
| 775 | vlen = ll2string((char*)vbuf,sizeof(vbuf),vlong); |
| 776 | vstr = vbuf; |
| 777 | } |
| 778 | |
| 779 | minlen = (vlen < clen) ? vlen : clen; |
| 780 | cmp = memcmp(vstr,cstr,minlen); |
| 781 | if (cmp == 0) return vlen-clen; |
| 782 | return cmp; |
| 783 | } |
| 784 | |
| 785 | unsigned int zzlLength(const unsigned char *zl) { |
| 786 | return ziplistLen(zl)/2; |
no test coverage detected