| 42 | /* ===================== Creation and parsing of objects ==================== */ |
| 43 | |
| 44 | robj *createObject(int type, void *ptr) { |
| 45 | size_t mvccExtraBytes = g_pserver->fActiveReplica ? sizeof(redisObjectExtended) : 0; |
| 46 | char *oB = (char*)zcalloc(sizeof(robj)+mvccExtraBytes, MALLOC_SHARED); |
| 47 | robj *o = reinterpret_cast<robj*>(oB + mvccExtraBytes); |
| 48 | |
| 49 | new (o) redisObject; |
| 50 | o->type = type; |
| 51 | o->encoding = OBJ_ENCODING_RAW; |
| 52 | o->m_ptr = ptr; |
| 53 | o->setrefcount(1); |
| 54 | setMvccTstamp(o, OBJ_MVCC_INVALID); |
| 55 | |
| 56 | /* Set the LRU to the current lruclock (minutes resolution), or |
| 57 | * alternatively the LFU counter. */ |
| 58 | if (g_pserver->maxmemory_policy & MAXMEMORY_FLAG_LFU) { |
| 59 | o->lru = (LFUGetTimeInMinutes()<<8) | LFU_INIT_VAL; |
| 60 | } else { |
| 61 | o->lru = LRU_CLOCK(); |
| 62 | } |
| 63 | return o; |
| 64 | } |
| 65 | |
| 66 | /* Set a special refcount in the object to make it "shared": |
| 67 | * incrRefCount and decrRefCount() will test for this special refcount |
no test coverage detected