本文整理汇总了C++中MojAllocCheck函数的典型用法代码示例。如果您正苦于以下问题:C++ MojAllocCheck函数的具体用法?C++ MojAllocCheck怎么用?C++ MojAllocCheck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MojAllocCheck函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: engine
MojErr MojDbQuotaTest::testErrors()
{
#ifdef MOJ_USE_BDB
MojRefCountedPtr<MojDbStorageEngine> engine(new MojDbBerkeleyEngine());
#elif MOJ_USE_LDB
MojRefCountedPtr<MojDbStorageEngine> engine(new MojDbLevelEngine());
#else
MojRefCountedPtr<MojDbStorageEngine> engine;
#endif
MojAllocCheck(engine.get());
MojRefCountedPtr<MojDbTestStorageEngine> testEngine(new MojDbTestStorageEngine(engine.get()));
MojAllocCheck(testEngine.get());
MojErr err = testEngine->open(MojDbTestDir);
MojTestErrCheck(err);
MojDb db;
err = db.open(MojDbTestDir, testEngine.get());
MojTestErrCheck(err);
// test that failed put does not affect quota
MojInt64 quotaUsage1 = 0;
err = getQuotaUsage(db, _T("com.foo.*"), quotaUsage1);
MojTestErrCheck(err);
err = testEngine->setNextError(_T("txn.commit"), MojErrDbDeadlock);
MojTestErrCheck(err);
err = put(db, MojTestKind3Objects[1]);
MojTestErrExpected(err, MojErrDbDeadlock);
MojInt64 quotaUsage2 = 0;
err = getQuotaUsage(db, _T("com.foo.*"), quotaUsage2);
MojTestErrCheck(err);
MojTestAssert(quotaUsage2 == quotaUsage1);
// test that failed putQuota has no effect
err = testEngine->setNextError(_T("txn.commit"), MojErrDbDeadlock);
MojTestErrCheck(err);
MojObject obj;
err = obj.fromJson(_T("{\"owner\":\"com.foo.boo\",\"size\":1000}"));
MojErrCheck(err);
err = db.putQuotas(&obj, &obj + 1);
MojTestErrExpected(err, MojErrDbDeadlock);
MojInt64 quotaUsage3 = 0;
err = getQuotaUsage(db, _T("com.foo.*"), quotaUsage3);
MojTestErrCheck(err);
MojTestAssert(quotaUsage3 == quotaUsage1);
// test that failed putKind has no effect
err = testEngine->setNextError(_T("txn.commit"), MojErrDbDeadlock);
MojTestErrCheck(err);
err = obj.fromJson(MojTestKind3Str2);
MojTestErrCheck(err);
err = db.putKind(obj);
MojTestErrExpected(err, MojErrDbDeadlock);
MojInt64 quotaUsage4 = 0;
err = getQuotaUsage(db, _T("com.foo.*"), quotaUsage4);
MojTestErrCheck(err);
MojTestAssert(quotaUsage4 == quotaUsage1);
err = db.close();
MojTestErrCheck(err);
return MojErrNone;
}
示例2: MojAssert
MojErr MojDbBerkeleyEngine::open(const MojChar* path)
{
MojAssert(path);
MojAssert(m_env.get());
MojAssert(!m_isOpen);
MojLogTrace(s_log);
MojErr err;
err = m_path.assign(path);
MojErrCheck(err);
// open seqence db
bool created = false;
m_seqDb.reset(new MojDbBerkeleyDatabase);
MojAllocCheck(m_seqDb.get());
err = m_seqDb->open(defs::MojEnvSeqDbName, this, created, NULL);
MojErrCheck(err);
// open index db
m_indexDb.reset(new MojDbBerkeleyDatabase);
MojAllocCheck(m_indexDb.get());
err = m_indexDb->open(defs::MojEnvIndexDbName, this, created, NULL);
MojErrCheck(err);
m_isOpen = true;
return MojErrNone;
}
示例3: MojAssert
MojErr MojObjectFilter::init(const StringSet& selectProps)
{
MojAssert(m_root.get() == NULL);
//create the root node
m_root.reset(new Node(MojString()));
MojAllocCheck(m_root.get());
for (StringSet::ConstIterator i = selectProps.begin(); i != selectProps.end(); i++) {
MojVector<MojString> parts;
MojErr err = i->split(_T('.'), parts);
MojErrCheck(err);
Node* curNode = m_root.get();
for (MojVector<MojString>::ConstIterator pi = parts.begin(); pi != parts.end(); ++pi) {
Node* child = curNode->find(*pi);
if (child) {
if (child->m_children.empty()) {
break;
} else {
curNode = child;
}
} else {
MojAutoPtr<Node> node(new Node(*pi));
MojAllocCheck(node.get());
Node* nextNode = node.get();
MojErr err = curNode->addChild(node);
MojErrCheck(err);
curNode = nextNode;
}
}
}
return MojErrNone;
}
示例4: source
MojErr MojSignalTest::test2()
{
// one handler fire
MojRefCountedPtr<TestSource> source(new TestSource);
MojAllocCheck(source.get());
MojRefCountedPtr<TestHandler> handler1(new TestHandler);
MojAllocCheck(handler1.get());
source->add2Slot(handler1->m_slot2);
MojTestAssert(handler1->refCount() == 2);
source->fire2(200, "hello");
MojTestAssert(handler1->m_handle2Count == 1);
MojTestAssert(handler1->m_lastInt == 200);
MojTestAssert(!MojStrCmp(handler1->m_lastStr, "hello"));
MojTestAssert(handler1->refCount() == 1);
source->fire2(200, "hello");
MojTestAssert(handler1->m_handle2Count == 1);
// two handlers
MojRefCountedPtr<TestHandler> handler2(new TestHandler);
MojAllocCheck(handler2.get());
source->add2Slot(handler1->m_slot2);
source->add2Slot(handler2->m_slot2);
source->fire2(201, "hello2");
MojTestAssert(handler1->m_lastInt == 201);
MojTestAssert(handler2->m_lastInt == 201);
MojTestAssert(!MojStrCmp(handler1->m_lastStr, "hello2"));
MojTestAssert(!MojStrCmp(handler2->m_lastStr, "hello2"));
// cancel
source->add2Slot(handler1->m_slot2);
source->add2Slot(handler2->m_slot2);
MojTestAssert(source->m_numCancels == 0);
handler1->m_slot2.cancel();
source->fire2(202, "hello3");
MojTestAssert(source->m_numCancels == 1);
MojTestAssert(handler1->m_lastInt == 201);
MojTestAssert(handler2->m_lastInt == 202);
MojTestAssert(!MojStrCmp(handler1->m_lastStr, "hello2"));
MojTestAssert(!MojStrCmp(handler2->m_lastStr, "hello3"));
// cancel from callback
source->add2Slot(handler2->m_slot2);
source->add2Slot(handler1->m_slot2Cancel);
source->fire2(203, "hello4");
MojTestAssert(source->m_numCancels == 1);
MojTestAssert(handler1->m_lastInt == 203);
MojTestAssert(handler2->m_lastInt == 203);
MojTestAssert(!MojStrCmp(handler1->m_lastStr, "hello4"));
MojTestAssert(!MojStrCmp(handler2->m_lastStr, "hello4"));
source->add2Slot(handler2->m_slot2);
source->fire2(204, "hello5");
MojTestAssert(handler1->m_lastInt == 203);
MojTestAssert(handler2->m_lastInt == 204);
MojTestAssert(!MojStrCmp(handler1->m_lastStr, "hello4"));
MojTestAssert(!MojStrCmp(handler2->m_lastStr, "hello5"));
return MojErrNone;
}
示例5: LOG_TRACE
MojErr MojDbMultiExtractor::fromObject(const MojObject& obj, const MojChar* locale)
{
LOG_TRACE("Entering function %s", __FUNCTION__);
MojErr err = MojDbExtractor::fromObject(obj, locale);
MojErrCheck(err);
// load the default config
MojDbPropExtractor defaultExtractor;
err = defaultExtractor.fromObject(obj, locale);
MojErrCheck(err);
MojObject include;
err = obj.getRequired(IncludeKey, include);
MojErrCheck(err);
for (MojObject::ConstArrayIterator i = include.arrayBegin();
i != include.arrayEnd(); ++i) {
MojString includeName;
err = i->stringValue(includeName);
MojErrCheck(err);
MojRefCountedPtr<MojDbPropExtractor> propExtractor(new MojDbPropExtractor);
MojAllocCheck(propExtractor.get());
err = propExtractor->fromObjectImpl(*i, defaultExtractor, locale);
MojErrCheck(err);
err = m_extractors.push(propExtractor);
MojErrCheck(err);
}
return MojErrNone;
}
示例6: MojTestErrCheck
MojErr MojDbTextTokenizerTest::check(const MojChar* text, const MojChar* tokens)
{
// tokenize string
MojString textStr;
MojErr err = textStr.assign(text);
MojTestErrCheck(err);
MojSet<MojDbKey> set;
MojRefCountedPtr<MojDbTextTokenizer> tokenizer(new MojDbTextTokenizer);
MojAllocCheck(tokenizer.get());
err = tokenizer->init(_T("en_US"));
MojTestErrCheck(err);
err = tokenizer->tokenize(textStr, NULL, set);
MojTestErrCheck(err);
// check that tokens match
MojObject obj;
err = obj.fromJson(tokens);
MojTestErrCheck(err);
MojSize objSize = obj.size();
MojSize setSize = set.size();
MojTestAssert(objSize == setSize);
for (MojObject::ConstArrayIterator i = obj.arrayBegin(); i != obj.arrayEnd(); ++i) {
MojDbKey key;
err = key.assign(*i);
MojTestErrCheck(err);
MojTestAssert(set.contains(key));
}
return MojErrNone;
}
示例7: MojTestErrCheck
MojErr MojDbIndexTest::assertCanAnswer(const MojChar* propsJson, const MojChar* queryJson,
bool result, bool indexIncludeDeleted)
{
MojObject propsObj;
MojErr err = propsObj.fromJson(propsJson);
MojTestErrCheck(err);
MojObject queryObj;
err = queryObj.fromJson(queryJson);
MojTestErrCheck(err);
MojDbIndex index(NULL, NULL);
MojObject prop;
MojSize i = 0;
for (;;) {
if(propsObj.at(i++, prop)) {
err = index.addProp(prop);
MojTestErrCheck(err);
} else {
break;
}
}
index.incDel(indexIncludeDeleted);
MojRefCountedPtr<MojDbStorageIndex> storageIndex(new TestIndex(false));
MojAllocCheck(storageIndex.get());
MojDbReq req;
err = index.open(storageIndex.get(), (MojInt64) 0, req);
MojTestErrCheck(err);
MojDbQuery query;
err = query.fromObject(queryObj);
MojTestErrCheck(err);
MojTestAssert(index.canAnswer(query) == result);
return MojErrNone;
}
示例8: MojErrCheck
MojErr MojDbIndexTest::assertContainsText(TestIndex& ti, MojObject id, const MojChar* str)
{
MojString strObj;
MojErr err = strObj.assign(str);
MojErrCheck(err);
MojRefCountedPtr<MojDbTextCollator> collator(new MojDbTextCollator);
MojAllocCheck(collator.get());
err = collator->init(_T("en_US"), MojDbCollationPrimary);
MojTestErrCheck(err);
MojDbKey key;
err = collator->sortKey(strObj, key);
MojTestErrCheck(err);
MojObjectWriter writer;
err = id.visit(writer);
MojTestErrCheck(err);
const MojByte* idData = NULL;
MojSize idSize = 0;
err = writer.buf().data(idData, idSize);
MojTestErrCheck(err);
err = key.byteVec().append(idData, idData + idSize);
MojTestErrCheck(err);
err = assertContains(ti, id, key);
MojTestErrCheck(err);
return MojErrNone;
}
示例9: index
MojErr MojDbIndexTest::tokenizeTest()
{
MojDbIndex index(NULL, NULL);
MojRefCountedPtr<TestIndex> storageIndex(new TestIndex(false));
MojAllocCheck(storageIndex.get());
TestIndex& ti = *storageIndex;
MojErr err = indexFromObject(index,
_T("{\"name\":\"test\",\"props\":[")
_T("{\"name\":\"foo\",\"tokenize\":\"all\",\"collate\":\"primary\"}")
_T("]}"));
MojErrCheck(err);
MojDbReq req;
err = index.open(storageIndex.get(), (MojInt64) 0, req);
MojTestErrCheck(err);
err = put(index, 1, _T("{\"foo\":\"four score and seven years ago\"}"), NULL);
MojTestErrCheck(err);
err = assertContainsText(ti, 1, _T("four"));
MojTestErrCheck(err);
err = assertContainsText(ti, 1, _T("score"));
MojTestErrCheck(err);
MojTestAssert(ti.m_putCount == 6 && ti.m_delCount == 0 && ti.m_set.size() == 6);
err = put(index, 1, _T("{\"foo\":\"our fathers put\"}"), _T("{\"foo\":\"four score and seven years ago\"}"));
MojTestErrCheck(err);
err = assertContainsText(ti, 1, _T("fathers"));
MojTestErrCheck(err);
MojTestAssert(ti.m_putCount == 9 && ti.m_delCount == 6 && ti.m_set.size() == 3);
err = index.close();
MojTestErrCheck(err);
return MojErrNone;
}
示例10: serviceThread
MojErr serviceThread(void*)
{
MojErr err = MojErrNone;
bool stop = false;
#ifdef USE_SOCKET_SERVICE
MojEpollReactor reactor;
MojSocketService msgService(reactor);
err = reactor.init();
MojErrCheck(err);
#else
MojGmainReactor reactor;
err = reactor.init();
MojErrCheck(err);
MojLunaService msgService;
#endif
MojRefCountedPtr<MojLunaTestService> service(new MojLunaTestService(stop, msgService));
MojAllocCheck(service.get());
err = service->open(ServiceName);
MojErrCheck(err);
err = msgService.attach(reactor.impl());
MojErrCheck(err);
while (!stop) {
err = msgService.dispatch();
MojErrCatchAll(err);
}
err = msgService.close();
MojErrCheck(err);
return MojErrNone;
}
示例11: testMultiEcho
MojErr testMultiEcho()
{
const MojChar* echoStr = _T("{\"hello\":\"world\"}");
MojObject expectedResponse;
MojErr err = formatEchoResponse(echoStr, expectedResponse);
MojTestErrCheck(err);
MojRefCountedPtr<MojServiceRequest> req;
err = m_service.createRequest(req);
MojTestErrCheck(err);
m_pendingResponseCount+= multiResponseCount;
MojRefCountedPtr<EchoMultiResponseHdlr> hdlr(new EchoMultiResponseHdlr(expectedResponse, m_pendingResponseCount, multiResponseCount));
MojAllocCheck(hdlr.get());
MojObject payload;
err = payload.fromJson(echoStr);
MojTestErrCheck(err);
err = req->send(hdlr->m_slot, ServiceName, _T("multiecho"), payload, MojServiceRequest::Unlimited);
MojTestErrCheck(err);
err = receiveResponses();
MojTestErrCheck(err);
return MojErrNone;
}
示例12: MojAssert
MojErr MojService::CategoryHandler::addMethod(const MojChar* methodName, Callback callback, bool pub, const MojChar* schemaJson)
{
MojAssert(methodName && callback);
MojString str;
MojErr err = str.assign(methodName);
MojErrCheck(err);
MojRefCountedPtr<MojSchema> schema;
if (schemaJson) {
MojObject schemaObj;
err = schemaObj.fromJson(schemaJson);
MojErrCheck(err);
// add implicit $activity property
MojObject properties;
schemaObj.get(MojSchema::PropertiesKey, properties);
MojObject activityProp;
err = activityProp.putBool(MojSchema::OptionalKey, true);
MojErrCheck(err);
err = properties.put(_T("$activity"), activityProp);
MojErrCheck(err);
err = schemaObj.put(MojSchema::PropertiesKey, properties);
MojErrCheck(err);
schema.reset(new MojSchema);
MojAllocCheck(schema.get());
err = schema->fromObject(schemaObj);
MojErrCheck(err);
}
MojAssert(!m_callbackMap.contains(str));
err = m_callbackMap.put(str, CallbackInfo(callback, schema.get(), pub));
MojErrCheck(err);
return MojErrNone;
}
示例13: MojLogTrace
MojErr MojDbKind::configureRevSets(const MojObject& obj)
{
MojLogTrace(s_log);
m_revSets.clear();
MojSet<MojString> setNames;
MojObject array;
if (obj.get(RevisionSetsKey, array)) {
MojObject::ConstArrayIterator end = array.arrayEnd();
for (MojObject::ConstArrayIterator i = array.arrayBegin(); i != end; ++i) {
MojRefCountedPtr<MojDbRevisionSet> set(new MojDbRevisionSet());
MojAllocCheck(set.get());
MojErr err = set->fromObject(*i);
MojErrCheck(err);
if (setNames.contains(set->name())) {
MojErrThrowMsg(MojErrDbInvalidRevisionSet, _T("db: cannot repeat revSet name: '%s'"), set->name().data());
}
err = setNames.put(set->name());
MojErrCheck(err);
err = m_revSets.push(set);
MojErrCheck(err);
}
}
return MojErrNone;
}
示例14: MojDbLevelEngine
MojErr MojDbLevelFactory::create(MojRefCountedPtr<MojDbStorageEngine>& engineOut)
{
engineOut.reset(new MojDbLevelEngine());
MojAllocCheck(engineOut.get());
return MojErrNone;
}
示例15: MojErrCheck
MojErr MojDbSearchCursor::loadObjects(const ObjectSet& ids)
{
MojInt32 warns = 0;
for (ObjectSet::ConstIterator i = ids.begin(); i != ids.end(); ++i) {
// get item by id
MojObject obj;
MojDbStorageItem* item = NULL;
bool found = false;
MojErr err = m_storageQuery->getById(*i, item, found);
if (err == MojErrInternalIndexOnFind) {
warns++;
continue;
}
MojErrCheck(err);
if (found) {
// get object from item
err = item->toObject(obj, *m_kindEngine);
MojErrCheck(err);
// filter results
if (m_queryFilter.get() && !m_queryFilter->test(obj))
continue;
// create object item
MojRefCountedPtr<MojDbObjectItem> item(new MojDbObjectItem(obj));
MojAllocCheck(item.get());
// add to vec
err = m_items.push(item);
MojErrCheck(err);
}
}
if (warns > 0)
MojLogWarning(MojDb::s_log, _T("Search warnings: %d \n"), warns);
return MojErrNone;
}