Encode the length 'l' writing it in 'p'. If p is NULL it just returns * the amount of bytes required to encode such a length. */
| 118 | /* Encode the length 'l' writing it in 'p'. If p is NULL it just returns |
| 119 | * the amount of bytes required to encode such a length. */ |
| 120 | static unsigned int zipmapEncodeLength(unsigned char *p, unsigned int len) { |
| 121 | if (p == NULL) { |
| 122 | return ZIPMAP_LEN_BYTES(len); |
| 123 | } else { |
| 124 | if (len < ZIPMAP_BIGLEN) { |
| 125 | p[0] = len; |
| 126 | return 1; |
| 127 | } else { |
| 128 | p[0] = ZIPMAP_BIGLEN; |
| 129 | memcpy(p+1,&len,sizeof(len)); |
| 130 | memrev32ifbe(p+1); |
| 131 | return 1+sizeof(len); |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /* Search for a matching key, returning a pointer to the entry inside the |
| 137 | * zipmap. Returns NULL if the key is not found. |
no outgoing calls
no test coverage detected