The not copy on write friendly version but easy to use version * of setTypeNext() is setTypeNextObject(), returning new SDS * strings. So if you don't retain a pointer to this object you should call * sdsfree() against it. * * This function is the way to go for write operations where COW is not * an issue. */
| 178 | * This function is the way to go for write operations where COW is not |
| 179 | * an issue. */ |
| 180 | sds setTypeNextObject(setTypeIterator *si) { |
| 181 | int64_t intele; |
| 182 | const char *sdsele; |
| 183 | int encoding; |
| 184 | |
| 185 | encoding = setTypeNext(si,&sdsele,&intele); |
| 186 | switch(encoding) { |
| 187 | case -1: return NULL; |
| 188 | case OBJ_ENCODING_INTSET: |
| 189 | return sdsfromlonglong(intele); |
| 190 | case OBJ_ENCODING_HT: |
| 191 | return sdsdup(sdsele); |
| 192 | default: |
| 193 | serverPanic("Unsupported encoding"); |
| 194 | } |
| 195 | return NULL; /* just to suppress warnings */ |
| 196 | } |
| 197 | |
| 198 | /* Return random element from a non empty set. |
| 199 | * The returned element can be an int64_t value if the set is encoded |
no test coverage detected