mirror of https://gitee.com/bigwinds/arangodb
nullptr
This commit is contained in:
parent
483862240f
commit
57b5cde21e
|
@ -333,7 +333,7 @@ Handler::status_t RestBatchHandler::execute() {
|
|||
|
||||
HttpResponse* partResponse = handler->getResponse();
|
||||
|
||||
if (partResponse == 0) {
|
||||
if (partResponse == nullptr) {
|
||||
delete handler;
|
||||
generateError(HttpResponse::BAD, TRI_ERROR_INTERNAL, "could not create a response for batch part request");
|
||||
|
||||
|
@ -489,10 +489,10 @@ bool RestBatchHandler::getBoundary (string* result) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool RestBatchHandler::extractPart (SearchHelper* helper) {
|
||||
TRI_ASSERT(helper->searchStart != NULL);
|
||||
TRI_ASSERT(helper->searchStart != nullptr);
|
||||
|
||||
// init the response
|
||||
helper->foundStart = NULL;
|
||||
helper->foundStart = nullptr;
|
||||
helper->foundLength = 0;
|
||||
helper->containsMore = false;
|
||||
helper->contentId = 0;
|
||||
|
@ -508,7 +508,7 @@ bool RestBatchHandler::extractPart (SearchHelper* helper) {
|
|||
// search for boundary
|
||||
char* found = strstr(helper->searchStart, helper->message->boundary);
|
||||
|
||||
if (found == NULL) {
|
||||
if (found == nullptr) {
|
||||
// not contained. this is an error
|
||||
return false;
|
||||
}
|
||||
|
@ -635,7 +635,7 @@ bool RestBatchHandler::extractPart (SearchHelper* helper) {
|
|||
// search for the end of the boundary
|
||||
found = strstr(helper->foundStart, helper->message->boundary);
|
||||
|
||||
if (found == NULL || found >= searchEnd) {
|
||||
if (found == nullptr || found >= searchEnd) {
|
||||
// did not find the end. this is an error
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -111,35 +111,32 @@ static bool EqualKeyAuthCache (TRI_associative_pointer_t* array,
|
|||
static char* ExtractStringShapedJson (TRI_shaper_t* shaper,
|
||||
TRI_shaped_json_t const* document,
|
||||
char const* path) {
|
||||
TRI_json_t* json;
|
||||
TRI_shape_pid_t pid;
|
||||
TRI_shape_t const* shape;
|
||||
TRI_shaped_json_t shaped;
|
||||
bool ok;
|
||||
char* result;
|
||||
|
||||
pid = shaper->lookupAttributePathByName(shaper, path);
|
||||
TRI_shape_pid_t pid = shaper->lookupAttributePathByName(shaper, path);
|
||||
|
||||
if (pid == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ok = TRI_ExtractShapedJsonVocShaper(shaper, document, 0, pid, &shaped, &shape);
|
||||
bool ok = TRI_ExtractShapedJsonVocShaper(shaper, document, 0, pid, &shaped, &shape);
|
||||
|
||||
if (! ok || shape == NULL) {
|
||||
return NULL;
|
||||
if (! ok || shape == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
json = TRI_JsonShapedJson(shaper, &shaped);
|
||||
TRI_json_t* json = TRI_JsonShapedJson(shaper, &shaped);
|
||||
|
||||
if (json == NULL) {
|
||||
return NULL;
|
||||
if (json == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (! TRI_IsStringJson(json)) {
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
result = TRI_DuplicateString2(json->_value._string.data,
|
||||
|
@ -158,32 +155,28 @@ static bool ExtractBooleanShapedJson (TRI_shaper_t* shaper,
|
|||
TRI_shaped_json_t const* document,
|
||||
char const* path,
|
||||
bool* found) {
|
||||
TRI_json_t* json;
|
||||
TRI_shape_pid_t pid;
|
||||
TRI_shape_t const* shape;
|
||||
TRI_shaped_json_t shaped;
|
||||
bool result;
|
||||
bool ok;
|
||||
|
||||
if (found != NULL) {
|
||||
if (found != nullptr) {
|
||||
*found = false;
|
||||
}
|
||||
|
||||
pid = shaper->lookupAttributePathByName(shaper, path);
|
||||
TRI_shape_pid_t pid = shaper->lookupAttributePathByName(shaper, path);
|
||||
|
||||
if (pid == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ok = TRI_ExtractShapedJsonVocShaper(shaper, document, 0, pid, &shaped, &shape);
|
||||
bool ok = TRI_ExtractShapedJsonVocShaper(shaper, document, 0, pid, &shaped, &shape);
|
||||
|
||||
if (! ok || shape == NULL) {
|
||||
if (! ok || shape == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
json = TRI_JsonShapedJson(shaper, &shaped);
|
||||
TRI_json_t* json = TRI_JsonShapedJson(shaper, &shaped);
|
||||
|
||||
if (json == NULL) {
|
||||
if (json == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -193,11 +186,11 @@ static bool ExtractBooleanShapedJson (TRI_shaper_t* shaper,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (found != NULL) {
|
||||
if (found != nullptr) {
|
||||
*found = true;
|
||||
}
|
||||
|
||||
result = json->_value._boolean;
|
||||
bool result = json->_value._boolean;
|
||||
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
|
||||
|
@ -219,11 +212,11 @@ static void FreeAuthInfo (TRI_vocbase_auth_t* auth) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void FreeAuthCacheInfo (TRI_vocbase_auth_cache_t* cached) {
|
||||
if (cached->_hash != NULL) {
|
||||
if (cached->_hash != nullptr) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, cached->_hash);
|
||||
}
|
||||
|
||||
if (cached->_username == NULL) {
|
||||
if (cached->_username == nullptr) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, cached->_username);
|
||||
}
|
||||
|
||||
|
@ -237,43 +230,38 @@ static void FreeAuthCacheInfo (TRI_vocbase_auth_cache_t* cached) {
|
|||
static TRI_vocbase_auth_t* ConvertAuthInfo (TRI_vocbase_t* vocbase,
|
||||
TRI_document_collection_t* document,
|
||||
TRI_shaped_json_t const* shapedJson) {
|
||||
char* user;
|
||||
char* password;
|
||||
bool active;
|
||||
bool found;
|
||||
bool mustChange;
|
||||
|
||||
TRI_shaper_t* shaper = document->getShaper(); // PROTECTED by trx in caller, checked by RUNTIME
|
||||
|
||||
// extract username
|
||||
user = ExtractStringShapedJson(shaper, shapedJson, "user");
|
||||
char* user = ExtractStringShapedJson(shaper, shapedJson, "user");
|
||||
|
||||
if (user == NULL) {
|
||||
if (user == nullptr) {
|
||||
LOG_DEBUG("cannot extract username");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// extract password
|
||||
password = ExtractStringShapedJson(shaper, shapedJson, "password");
|
||||
char* password = ExtractStringShapedJson(shaper, shapedJson, "password");
|
||||
|
||||
if (password == NULL) {
|
||||
if (password == nullptr) {
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, user);
|
||||
LOG_DEBUG("cannot extract password");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// extract active flag
|
||||
active = ExtractBooleanShapedJson(shaper, shapedJson, "active", &found);
|
||||
bool found;
|
||||
bool active = ExtractBooleanShapedJson(shaper, shapedJson, "active", &found);
|
||||
|
||||
if (! found) {
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, user);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, password);
|
||||
LOG_DEBUG("cannot extract active flag");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// extract must-change-password flag
|
||||
mustChange = ExtractBooleanShapedJson(shaper, shapedJson, "changePassword", &found);
|
||||
bool mustChange = ExtractBooleanShapedJson(shaper, shapedJson, "changePassword", &found);
|
||||
|
||||
if (! found) {
|
||||
mustChange = false;
|
||||
|
@ -281,12 +269,12 @@ static TRI_vocbase_auth_t* ConvertAuthInfo (TRI_vocbase_t* vocbase,
|
|||
|
||||
TRI_vocbase_auth_t* result = static_cast<TRI_vocbase_auth_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_vocbase_auth_t), true));
|
||||
|
||||
if (result == NULL) {
|
||||
if (result == nullptr) {
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, user);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, password);
|
||||
LOG_ERROR("couldn't load auth information - out of memory");
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
result->_username = user;
|
||||
|
@ -304,21 +292,17 @@ static TRI_vocbase_auth_t* ConvertAuthInfo (TRI_vocbase_t* vocbase,
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void ClearAuthInfo (TRI_vocbase_t* vocbase) {
|
||||
void** beg;
|
||||
void** end;
|
||||
void** ptr;
|
||||
|
||||
// clear auth info table
|
||||
beg = vocbase->_authInfo._table;
|
||||
end = vocbase->_authInfo._table + vocbase->_authInfo._nrAlloc;
|
||||
ptr = beg;
|
||||
void** beg = vocbase->_authInfo._table;
|
||||
void** end = vocbase->_authInfo._table + vocbase->_authInfo._nrAlloc;
|
||||
void** ptr = beg;
|
||||
|
||||
for (; ptr < end; ++ptr) {
|
||||
if (*ptr) {
|
||||
TRI_vocbase_auth_t* auth = static_cast<TRI_vocbase_auth_t*>(*ptr);
|
||||
|
||||
FreeAuthInfo(auth);
|
||||
*ptr = NULL;
|
||||
*ptr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,7 +318,7 @@ static void ClearAuthInfo (TRI_vocbase_t* vocbase) {
|
|||
TRI_vocbase_auth_cache_t* auth = static_cast<TRI_vocbase_auth_cache_t*>(*ptr);
|
||||
|
||||
FreeAuthCacheInfo(auth);
|
||||
*ptr = NULL;
|
||||
*ptr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -355,14 +339,14 @@ int TRI_InitAuthInfo (TRI_vocbase_t* vocbase) {
|
|||
HashKey,
|
||||
HashElementAuthInfo,
|
||||
EqualKeyAuthInfo,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
TRI_InitAssociativePointer(&vocbase->_authCache,
|
||||
TRI_CORE_MEM_ZONE,
|
||||
HashKey,
|
||||
HashElementAuthCache,
|
||||
EqualKeyAuthCache,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
TRI_InitReadWriteLock(&vocbase->_authInfoLock);
|
||||
|
||||
|
@ -386,18 +370,15 @@ void TRI_DestroyAuthInfo (TRI_vocbase_t* vocbase) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_InsertInitialAuthInfo (TRI_vocbase_t* vocbase) {
|
||||
TRI_json_t* json;
|
||||
TRI_json_t* user;
|
||||
TRI_json_t* json = TRI_CreateList2Json(TRI_UNKNOWN_MEM_ZONE, 1);
|
||||
|
||||
json = TRI_CreateList2Json(TRI_UNKNOWN_MEM_ZONE, 1);
|
||||
|
||||
if (json == NULL) {
|
||||
if (json == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
user = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE);
|
||||
TRI_json_t* user = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE);
|
||||
|
||||
if (user == NULL) {
|
||||
if (user == nullptr) {
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
return false;
|
||||
}
|
||||
|
@ -527,7 +508,7 @@ bool TRI_PopulateAuthInfo (TRI_vocbase_t* vocbase,
|
|||
|
||||
TRI_vocbase_auth_t* auth = static_cast<TRI_vocbase_auth_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_vocbase_auth_t), true));
|
||||
|
||||
if (auth == NULL) {
|
||||
if (auth == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -581,12 +562,12 @@ void TRI_ClearAuthInfo (TRI_vocbase_t* vocbase) {
|
|||
char* TRI_CheckCacheAuthInfo (TRI_vocbase_t* vocbase,
|
||||
char const* hash,
|
||||
bool* mustChange) {
|
||||
char* username = NULL;
|
||||
char* username = nullptr;
|
||||
|
||||
TRI_ReadLockReadWriteLock(&vocbase->_authInfoLock);
|
||||
TRI_vocbase_auth_cache_t* cached = static_cast<TRI_vocbase_auth_cache_t*>(TRI_LookupByKeyAssociativePointer(&vocbase->_authCache, hash));
|
||||
|
||||
if (cached != NULL) {
|
||||
if (cached != nullptr) {
|
||||
username = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, cached->_username);
|
||||
*mustChange = cached->_mustChange;
|
||||
}
|
||||
|
@ -613,13 +594,13 @@ bool TRI_CheckAuthenticationAuthInfo (TRI_vocbase_t* vocbase,
|
|||
size_t len;
|
||||
size_t sha256Len;
|
||||
|
||||
TRI_ASSERT(vocbase != NULL);
|
||||
TRI_ASSERT(vocbase != nullptr);
|
||||
|
||||
// look up username
|
||||
TRI_ReadLockReadWriteLock(&vocbase->_authInfoLock);
|
||||
TRI_vocbase_auth_t* auth = static_cast<TRI_vocbase_auth_t*>(TRI_LookupByKeyAssociativePointer(&vocbase->_authInfo, username));
|
||||
|
||||
if (auth == NULL || ! auth->_active) {
|
||||
if (auth == nullptr || ! auth->_active) {
|
||||
TRI_ReadUnlockReadWriteLock(&vocbase->_authInfoLock);
|
||||
return false;
|
||||
}
|
||||
|
@ -676,27 +657,25 @@ bool TRI_CheckAuthenticationAuthInfo (TRI_vocbase_t* vocbase,
|
|||
|
||||
TRI_ReadUnlockReadWriteLock(&vocbase->_authInfoLock);
|
||||
|
||||
if (res && hash != NULL) {
|
||||
if (res && hash != nullptr) {
|
||||
// insert item into the cache
|
||||
TRI_vocbase_auth_cache_t* cached = static_cast<TRI_vocbase_auth_cache_t*>(TRI_Allocate(TRI_CORE_MEM_ZONE, sizeof(TRI_vocbase_auth_cache_t), false));
|
||||
|
||||
if (cached != NULL) {
|
||||
void* old;
|
||||
|
||||
if (cached != nullptr) {
|
||||
cached->_hash = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, hash);
|
||||
cached->_username = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, username);
|
||||
cached->_mustChange = auth->_mustChange;
|
||||
|
||||
if (cached->_hash == NULL || cached->_username == NULL) {
|
||||
if (cached->_hash == nullptr || cached->_username == nullptr) {
|
||||
FreeAuthCacheInfo(cached);
|
||||
return res;
|
||||
}
|
||||
|
||||
TRI_WriteLockReadWriteLock(&vocbase->_authInfoLock);
|
||||
old = TRI_InsertKeyAssociativePointer(&vocbase->_authCache, cached->_hash, cached, false);
|
||||
void* old = TRI_InsertKeyAssociativePointer(&vocbase->_authCache, cached->_hash, cached, false);
|
||||
|
||||
// duplicate entry?
|
||||
if (old != NULL) {
|
||||
if (old != nullptr) {
|
||||
FreeAuthCacheInfo(cached);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ static bool UpgradeShapeIterator (TRI_df_marker_t const* marker,
|
|||
TRI_shape_t const* shape = (TRI_shape_t const*) ((char const*) marker + sizeof(TRI_df_shape_marker_t));
|
||||
|
||||
// if the shape is of basic type, don't copy it
|
||||
if (TRI_LookupSidBasicShapeShaper(shape->_sid) != NULL) {
|
||||
if (TRI_LookupSidBasicShapeShaper(shape->_sid) != nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -146,8 +146,8 @@ static int DatafileComparator (const void* lhs, const void* rhs) {
|
|||
TRI_datafile_t* l = *((TRI_datafile_t**) lhs);
|
||||
TRI_datafile_t* r = *((TRI_datafile_t**) rhs);
|
||||
|
||||
const uint64_t numLeft = (l->_filename != NULL ? GetNumericFilenamePart(l->_filename) : 0);
|
||||
const uint64_t numRight = (r->_filename != NULL ? GetNumericFilenamePart(r->_filename) : 0);
|
||||
uint64_t const numLeft = (l->_filename != nullptr ? GetNumericFilenamePart(l->_filename) : 0);
|
||||
uint64_t const numRight = (r->_filename != nullptr ? GetNumericFilenamePart(r->_filename) : 0);
|
||||
|
||||
if (numLeft != numRight) {
|
||||
return numLeft < numRight ? -1 : 1;
|
||||
|
@ -297,7 +297,7 @@ static TRI_col_file_structure_t ScanCollectionDirectory (char const* path) {
|
|||
|
||||
filename = TRI_Concatenate2File(path, file);
|
||||
|
||||
if (filename != NULL) {
|
||||
if (filename != nullptr) {
|
||||
LOG_TRACE("removing .dead file '%s'", filename);
|
||||
TRI_UnlinkFile(filename);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, filename);
|
||||
|
@ -968,36 +968,32 @@ char* TRI_GetDirectoryCollection (char const* path,
|
|||
char const* name,
|
||||
TRI_col_type_e type,
|
||||
TRI_voc_cid_t cid) {
|
||||
char* filename;
|
||||
char* tmp1;
|
||||
char* tmp2;
|
||||
TRI_ASSERT(path != nullptr);
|
||||
TRI_ASSERT(name != nullptr);
|
||||
|
||||
TRI_ASSERT(path != NULL);
|
||||
TRI_ASSERT(name != NULL);
|
||||
char* tmp1 = TRI_StringUInt64(cid);
|
||||
|
||||
tmp1 = TRI_StringUInt64(cid);
|
||||
|
||||
if (tmp1 == NULL) {
|
||||
if (tmp1 == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tmp2 = TRI_Concatenate2String("collection-", tmp1);
|
||||
char* tmp2 = TRI_Concatenate2String("collection-", tmp1);
|
||||
|
||||
if (tmp2 == NULL) {
|
||||
if (tmp2 == nullptr) {
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, tmp1);
|
||||
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
filename = TRI_Concatenate2File(path, tmp2);
|
||||
char* filename = TRI_Concatenate2File(path, tmp2);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, tmp1);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, tmp2);
|
||||
|
||||
if (filename == NULL) {
|
||||
if (filename == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
|
@ -1188,7 +1184,7 @@ int TRI_IterateJsonIndexesCollectionInfo (TRI_vocbase_col_t* collection,
|
|||
for (i = 0; i < n; ++i) {
|
||||
char const* file = files._buffer[i];
|
||||
|
||||
if (regexec(&re, file, (size_t) 0, NULL, 0) == 0) {
|
||||
if (regexec(&re, file, (size_t) 0, nullptr, 0) == 0) {
|
||||
char* fqn = TRI_Concatenate2File(collection->_path, file);
|
||||
|
||||
res = filter(collection, fqn, data);
|
||||
|
@ -1380,7 +1376,7 @@ int TRI_UpdateCollectionInfo (TRI_vocbase_t* vocbase,
|
|||
|
||||
TRI_LOCK_JOURNAL_ENTRIES_DOC_COLLECTION((TRI_document_collection_t*) collection);
|
||||
|
||||
if (parameter != NULL) {
|
||||
if (parameter != nullptr) {
|
||||
collection->_info._doCompact = parameter->_doCompact;
|
||||
collection->_info._maximalSize = parameter->_maximalSize;
|
||||
collection->_info._waitForSync = parameter->_waitForSync;
|
||||
|
@ -1437,31 +1433,26 @@ int TRI_RenameCollection (TRI_collection_t* collection,
|
|||
bool TRI_IterateCollection (TRI_collection_t* collection,
|
||||
bool (*iterator)(TRI_df_marker_t const*, void*, TRI_datafile_t*),
|
||||
void* data) {
|
||||
TRI_vector_pointer_t* datafiles;
|
||||
TRI_vector_pointer_t* journals;
|
||||
TRI_vector_pointer_t* compactors;
|
||||
bool result;
|
||||
TRI_vector_pointer_t* datafiles = TRI_CopyVectorPointer(TRI_UNKNOWN_MEM_ZONE, &collection->_datafiles);
|
||||
|
||||
datafiles = TRI_CopyVectorPointer(TRI_UNKNOWN_MEM_ZONE, &collection->_datafiles);
|
||||
|
||||
if (datafiles == NULL) {
|
||||
if (datafiles == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
journals = TRI_CopyVectorPointer(TRI_UNKNOWN_MEM_ZONE, &collection->_journals);
|
||||
TRI_vector_pointer_t* journals = TRI_CopyVectorPointer(TRI_UNKNOWN_MEM_ZONE, &collection->_journals);
|
||||
|
||||
if (journals == NULL) {
|
||||
if (journals == nullptr) {
|
||||
TRI_FreeVectorPointer(TRI_UNKNOWN_MEM_ZONE, datafiles);
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
compactors = TRI_CopyVectorPointer(TRI_UNKNOWN_MEM_ZONE, &collection->_compactors);
|
||||
TRI_vector_pointer_t* compactors = TRI_CopyVectorPointer(TRI_UNKNOWN_MEM_ZONE, &collection->_compactors);
|
||||
|
||||
if (compactors == NULL) {
|
||||
if (compactors == nullptr) {
|
||||
TRI_FreeVectorPointer(TRI_UNKNOWN_MEM_ZONE, datafiles);
|
||||
TRI_FreeVectorPointer(TRI_UNKNOWN_MEM_ZONE, journals);
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -1469,6 +1460,7 @@ bool TRI_IterateCollection (TRI_collection_t* collection,
|
|||
return false;
|
||||
}
|
||||
|
||||
bool result;
|
||||
if (! IterateDatafilesVector(datafiles , iterator, data) ||
|
||||
! IterateDatafilesVector(compactors, iterator, data) ||
|
||||
! IterateDatafilesVector(journals, iterator, data)) {
|
||||
|
@ -1492,17 +1484,12 @@ bool TRI_IterateCollection (TRI_collection_t* collection,
|
|||
void TRI_IterateIndexCollection (TRI_collection_t* collection,
|
||||
bool (*iterator)(char const* filename, void*),
|
||||
void* data) {
|
||||
size_t i, n;
|
||||
|
||||
// iterate over all index files
|
||||
n = collection->_indexFiles._length;
|
||||
size_t const n = collection->_indexFiles._length;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
char const* filename;
|
||||
bool ok;
|
||||
|
||||
filename = collection->_indexFiles._buffer[i];
|
||||
ok = iterator(filename, data);
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
char const* filename = collection->_indexFiles._buffer[i];
|
||||
bool ok = iterator(filename, data);
|
||||
|
||||
if (! ok) {
|
||||
LOG_ERROR("cannot load index '%s' for collection '%s'",
|
||||
|
@ -1644,7 +1631,7 @@ int TRI_UpgradeCollection20 (TRI_vocbase_t* vocbase,
|
|||
outfile = TRI_Concatenate2File(path, fname);
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, fname);
|
||||
|
||||
if (outfile == NULL) {
|
||||
if (outfile == nullptr) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, shapes);
|
||||
regfree(&re);
|
||||
|
||||
|
|
|
@ -281,12 +281,9 @@ static void InitDatafile (TRI_datafile_t* datafile,
|
|||
|
||||
static int TruncateAndSealDatafile (TRI_datafile_t* datafile,
|
||||
TRI_voc_size_t vocSize) {
|
||||
char* filename;
|
||||
char* oldname;
|
||||
char zero;
|
||||
int fd;
|
||||
int res;
|
||||
size_t maximalSize;
|
||||
void* data;
|
||||
void* mmHandle;
|
||||
|
||||
|
@ -294,7 +291,7 @@ static int TruncateAndSealDatafile (TRI_datafile_t* datafile,
|
|||
TRI_ASSERT(datafile->isPhysical(datafile));
|
||||
|
||||
// use multiples of page-size
|
||||
maximalSize = ((vocSize + sizeof(TRI_df_footer_marker_t) + PageSize - 1) / PageSize) * PageSize;
|
||||
size_t maximalSize = ((vocSize + sizeof(TRI_df_footer_marker_t) + PageSize - 1) / PageSize) * PageSize;
|
||||
|
||||
// sanity check
|
||||
if (sizeof(TRI_df_header_marker_t) + sizeof(TRI_df_footer_marker_t) > maximalSize) {
|
||||
|
@ -303,9 +300,9 @@ static int TruncateAndSealDatafile (TRI_datafile_t* datafile,
|
|||
}
|
||||
|
||||
// open the file
|
||||
filename = TRI_Concatenate2String(datafile->_filename, ".new");
|
||||
char* filename = TRI_Concatenate2String(datafile->_filename, ".new");
|
||||
|
||||
fd = TRI_CREATE(filename, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
int fd = TRI_CREATE(filename, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
|
||||
if (fd < 0) {
|
||||
LOG_ERROR("cannot create new datafile '%s': '%s'", filename, TRI_last_error());
|
||||
|
@ -837,7 +834,7 @@ static TRI_datafile_t* OpenDatafile (char const* filename,
|
|||
|
||||
if (! ignoreErrors) {
|
||||
TRI_CLOSE(fd);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -858,17 +855,17 @@ static TRI_datafile_t* OpenDatafile (char const* filename,
|
|||
TRI_CLOSE(fd);
|
||||
|
||||
LOG_ERROR("cannot memory map datafile '%s': %s", filename, TRI_errno_string(res));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// create datafile structure
|
||||
TRI_datafile_t* datafile = static_cast<TRI_datafile_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_datafile_t), false));
|
||||
|
||||
if (datafile == NULL) {
|
||||
if (datafile == nullptr) {
|
||||
TRI_UNMMFile(data, size, fd, &mmHandle);
|
||||
TRI_CLOSE(fd);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InitDatafile(datafile,
|
||||
|
@ -907,25 +904,25 @@ TRI_datafile_t* TRI_CreateDatafile (char const* filename,
|
|||
LOG_ERROR("cannot create datafile, maximal size '%u' is too small", (unsigned int) maximalSize);
|
||||
TRI_set_errno(TRI_ERROR_ARANGO_MAXIMAL_SIZE_TOO_SMALL);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// create either an anonymous or a physical datafile
|
||||
if (filename == NULL) {
|
||||
if (filename == nullptr) {
|
||||
#ifdef TRI_HAVE_ANONYMOUS_MMAP
|
||||
datafile = TRI_CreateAnonymousDatafile(fid, maximalSize);
|
||||
#else
|
||||
// system does not support anonymous mmap
|
||||
return NULL;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
datafile = TRI_CreatePhysicalDatafile(filename, fid, maximalSize);
|
||||
}
|
||||
|
||||
if (datafile == NULL) {
|
||||
if (datafile == nullptr) {
|
||||
// an error occurred during creation
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -942,7 +939,7 @@ TRI_datafile_t* TRI_CreateDatafile (char const* filename,
|
|||
datafile->destroy(datafile);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, datafile);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -981,14 +978,14 @@ TRI_datafile_t* TRI_CreateAnonymousDatafile (TRI_voc_fid_t fid,
|
|||
// TODO: find a good workaround for Windows
|
||||
fd = TRI_OPEN("/dev/zero", O_RDWR);
|
||||
if (fd == -1) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
flags = MAP_PRIVATE;
|
||||
#endif
|
||||
|
||||
// memory map the data
|
||||
res = TRI_MMFile(NULL, maximalSize, PROT_WRITE | PROT_READ, flags, fd, &mmHandle, 0, &data);
|
||||
res = TRI_MMFile(nullptr, maximalSize, PROT_WRITE | PROT_READ, flags, fd, &mmHandle, 0, &data);
|
||||
|
||||
#ifdef MAP_ANONYMOUS
|
||||
// nothing to do
|
||||
|
@ -1002,21 +999,21 @@ TRI_datafile_t* TRI_CreateAnonymousDatafile (TRI_voc_fid_t fid,
|
|||
TRI_set_errno(res);
|
||||
|
||||
LOG_ERROR("cannot memory map anonymous region: %s", TRI_last_error());
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// create datafile structure
|
||||
datafile = (TRI_datafile_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_datafile_t), false);
|
||||
datafile = static_cast<TRI_datafile_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_datafile_t), false));
|
||||
|
||||
if (datafile == NULL) {
|
||||
if (datafile == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
LOG_ERROR("out of memory");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InitDatafile(datafile,
|
||||
NULL,
|
||||
nullptr,
|
||||
fd,
|
||||
mmHandle,
|
||||
maximalSize,
|
||||
|
@ -1037,18 +1034,17 @@ TRI_datafile_t* TRI_CreatePhysicalDatafile (char const* filename,
|
|||
TRI_voc_fid_t fid,
|
||||
TRI_voc_size_t maximalSize) {
|
||||
TRI_datafile_t* datafile;
|
||||
int fd;
|
||||
ssize_t res;
|
||||
void* data;
|
||||
void* mmHandle;
|
||||
|
||||
TRI_ASSERT(filename != NULL);
|
||||
TRI_ASSERT(filename != nullptr);
|
||||
|
||||
fd = CreateSparseFile(filename, maximalSize);
|
||||
int fd = CreateSparseFile(filename, maximalSize);
|
||||
|
||||
if (fd < 0) {
|
||||
// an error occurred
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// memory map the data
|
||||
|
@ -1062,19 +1058,19 @@ TRI_datafile_t* TRI_CreatePhysicalDatafile (char const* filename,
|
|||
TRI_UnlinkFile(filename);
|
||||
|
||||
LOG_ERROR("cannot memory map file '%s': '%s'", filename, TRI_errno_string((int) res));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// create datafile structure
|
||||
datafile = (TRI_datafile_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_datafile_t), false);
|
||||
datafile = static_cast<TRI_datafile_t*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_datafile_t), false));
|
||||
|
||||
if (datafile == NULL) {
|
||||
if (datafile == nullptr) {
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
TRI_CLOSE(fd);
|
||||
|
||||
LOG_ERROR("out of memory");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
InitDatafile(datafile,
|
||||
|
|
|
@ -1932,7 +1932,7 @@ static int FillLookupBitarrayOperator (TRI_index_operator_t* indexOperator, TRI_
|
|||
case TRI_LT_INDEX_OPERATOR: {
|
||||
TRI_relation_index_operator_t* relationOperator = (TRI_relation_index_operator_t*) indexOperator;
|
||||
relationOperator->_numFields = relationOperator->_parameters->_value._objects._length;
|
||||
relationOperator->_fields = NULL; // bitarray indexes need only the json representation of values
|
||||
relationOperator->_fields = nullptr; // bitarray indexes need only the json representation of values
|
||||
|
||||
// even tough we use the json representation of the values sent by the client
|
||||
// for a bitarray index, we still require the shaped_json values for later
|
||||
|
@ -1947,7 +1947,7 @@ static int FillLookupBitarrayOperator (TRI_index_operator_t* indexOperator, TRI_
|
|||
// when you are ready to use the shaped json values -- uncomment the follow
|
||||
/*
|
||||
relationOperator->_fields = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_shaped_json_t) * relationOperator->_numFields, false);
|
||||
if (relationOperator->_fields != NULL) {
|
||||
if (relationOperator->_fields != nullptr) {
|
||||
int j;
|
||||
TRI_json_t* jsonObject;
|
||||
TRI_shaped_json_t* shapedObject;
|
||||
|
@ -2264,9 +2264,9 @@ static TRI_json_t* JsonBitarrayIndex (TRI_index_t const* idx) {
|
|||
TRI_shape_pid_t shape = *((TRI_shape_pid_t*)(TRI_AtVector(&baIndex->_paths,j)));
|
||||
const TRI_shape_path_t* path = document->getShaper()->lookupAttributePathByPid(document->getShaper(), shape); // ONLY IN INDEX, PROTECTED by RUNTIME
|
||||
|
||||
if (path == NULL) {
|
||||
if (path == nullptr) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, (void*) fieldList);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
fieldList[j] = ((const char*) path) + sizeof(TRI_shape_path_t) + path->_aidLength * sizeof(TRI_shape_aid_t);
|
||||
|
@ -2303,11 +2303,11 @@ static TRI_json_t* JsonBitarrayIndex (TRI_index_t const* idx) {
|
|||
|
||||
keyValue = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
|
||||
|
||||
if (keyValue == NULL) {
|
||||
if (keyValue == nullptr) {
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, keyValues);
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, (void*) fieldList);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ........................................................................
|
||||
|
@ -2316,12 +2316,12 @@ static TRI_json_t* JsonBitarrayIndex (TRI_index_t const* idx) {
|
|||
|
||||
key = TRI_CreateStringCopyJson(TRI_CORE_MEM_ZONE, fieldList[j]);
|
||||
|
||||
if (key == NULL) {
|
||||
if (key == nullptr) {
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, keyValues);
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, keyValue);
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, (void*) fieldList);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ........................................................................
|
||||
|
@ -2331,13 +2331,13 @@ static TRI_json_t* JsonBitarrayIndex (TRI_index_t const* idx) {
|
|||
|
||||
value = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
|
||||
|
||||
if (value == NULL) {
|
||||
if (value == nullptr) {
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, keyValues);
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, key);
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, keyValue);
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, (void*) fieldList);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TRI_CopyToJson(TRI_CORE_MEM_ZONE, value, (TRI_json_t*)(TRI_AtVector(&baIndex->_values,j)));
|
||||
|
@ -2395,7 +2395,7 @@ static int RemoveBitarrayIndex (TRI_index_t* idx,
|
|||
// Fill the json field list with values from the document
|
||||
// ..........................................................................
|
||||
|
||||
result = BitarrayIndexHelper(baIndex, &element, doc, NULL);
|
||||
result = BitarrayIndexHelper(baIndex, &element, doc, nullptr);
|
||||
|
||||
// ..........................................................................
|
||||
// Error returned generally implies that the document never was part of the
|
||||
|
@ -2494,22 +2494,24 @@ TRI_index_t* TRI_CreateBitarrayIndex (TRI_document_collection_t* document,
|
|||
// ...........................................................................
|
||||
|
||||
for (k = 0; k < paths->_length; ++k) {
|
||||
TRI_json_t* valueList = (TRI_json_t*)(TRI_AtVectorPointer(values,k));
|
||||
TRI_json_t* valueList = static_cast<TRI_json_t*>(TRI_AtVectorPointer(values,k));
|
||||
|
||||
if (valueList == NULL || valueList->_type != TRI_JSON_LIST) {
|
||||
if (! TRI_IsListJson(valueList)) {
|
||||
*errorNum = TRI_ERROR_BAD_PARAMETER;
|
||||
*errorStr = TRI_DuplicateString("bitarray index creation failed - list of values for index undefined");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (j = 0; j < valueList->_value._objects._length; ++j) {
|
||||
TRI_json_t* leftValue = (TRI_json_t*)(TRI_AtVector(&(valueList->_value._objects), j));
|
||||
TRI_json_t* leftValue = static_cast<TRI_json_t*>(TRI_AtVector(&(valueList->_value._objects), j));
|
||||
|
||||
for (i = j + 1; i < valueList->_value._objects._length; ++i) {
|
||||
TRI_json_t* rightValue = (TRI_json_t*)(TRI_AtVector(&(valueList->_value._objects), i));
|
||||
TRI_json_t* rightValue = static_cast<TRI_json_t*>(TRI_AtVector(&(valueList->_value._objects), i));
|
||||
|
||||
if (TRI_EqualJsonJson(leftValue, rightValue)) {
|
||||
*errorNum = TRI_ERROR_ARANGO_INDEX_BITARRAY_CREATION_FAILURE_DUPLICATE_VALUES;
|
||||
*errorStr = TRI_DuplicateString("bitarray index creation failed - duplicate values in value list for an attribute");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2529,7 +2531,7 @@ TRI_index_t* TRI_CreateBitarrayIndex (TRI_document_collection_t* document,
|
|||
idx->remove = RemoveBitarrayIndex;
|
||||
|
||||
baIndex->_supportUndef = supportUndef;
|
||||
baIndex->_bitarrayIndex = NULL;
|
||||
baIndex->_bitarrayIndex = nullptr;
|
||||
|
||||
// ...........................................................................
|
||||
// Copy the contents of the shape list vector into a new vector and store this
|
||||
|
@ -2565,7 +2567,7 @@ TRI_index_t* TRI_CreateBitarrayIndex (TRI_document_collection_t* document,
|
|||
// Currently there is no creation context -- todo later
|
||||
// ...........................................................................
|
||||
|
||||
createContext = NULL;
|
||||
createContext = nullptr;
|
||||
|
||||
// ...........................................................................
|
||||
// Check that the attributes have not been repeated
|
||||
|
@ -2579,15 +2581,15 @@ TRI_index_t* TRI_CreateBitarrayIndex (TRI_document_collection_t* document,
|
|||
cardinality = 0;
|
||||
|
||||
for (j = 0; j < paths->_length; ++j) {
|
||||
TRI_json_t* value = (TRI_json_t*) TRI_AtVector(&baIndex->_values,j);
|
||||
TRI_json_t* value = static_cast<TRI_json_t*>(TRI_AtVector(&baIndex->_values, j));
|
||||
size_t numValues;
|
||||
|
||||
if (value == NULL) {
|
||||
if (value == nullptr) {
|
||||
TRI_DestroyVector(&baIndex->_paths);
|
||||
TRI_DestroyVector(&baIndex->_values);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, baIndex);
|
||||
LOG_WARNING("bitarray index creation failed -- list of values for index undefined");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
numValues = value->_value._objects._length;
|
||||
|
@ -2610,7 +2612,7 @@ TRI_index_t* TRI_CreateBitarrayIndex (TRI_document_collection_t* document,
|
|||
TRI_DestroyVector(&baIndex->_values);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, baIndex);
|
||||
LOG_WARNING("bitarray index creation failed -- more than 64 possible values");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2619,7 +2621,7 @@ TRI_index_t* TRI_CreateBitarrayIndex (TRI_document_collection_t* document,
|
|||
TRI_DestroyVector(&baIndex->_values);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, baIndex);
|
||||
LOG_WARNING("bitarray index creation failed -- no index values defined");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
|
@ -2635,7 +2637,7 @@ TRI_index_t* TRI_CreateBitarrayIndex (TRI_document_collection_t* document,
|
|||
TRI_DestroyVector(&baIndex->_values);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, baIndex);
|
||||
LOG_WARNING("bitarray index creation failed -- internal error when assigning function calls");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// ...........................................................................
|
||||
|
@ -2647,7 +2649,7 @@ TRI_index_t* TRI_CreateBitarrayIndex (TRI_document_collection_t* document,
|
|||
if (result != TRI_ERROR_NO_ERROR) {
|
||||
TRI_FreeBitarrayIndex(idx);
|
||||
LOG_WARNING("bitarray index creation failed -- your guess as good as mine");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return idx;
|
||||
|
|
|
@ -741,7 +741,7 @@ static int OpenDatabases (TRI_server_t* server,
|
|||
}
|
||||
|
||||
// should never have a duplicate database name
|
||||
TRI_ASSERT(found == NULL);
|
||||
TRI_ASSERT(found == nullptr);
|
||||
|
||||
LOG_INFO("loaded database '%s' from '%s'",
|
||||
vocbase->_name,
|
||||
|
|
|
@ -55,12 +55,10 @@ void TRI_ApplyVocBaseDefaults (TRI_vocbase_t* vocbase,
|
|||
|
||||
TRI_json_t* TRI_JsonVocBaseDefaults (TRI_memory_zone_t* zone,
|
||||
TRI_vocbase_defaults_t const* defaults) {
|
||||
TRI_json_t* json;
|
||||
TRI_json_t* json = TRI_CreateArrayJson(zone);
|
||||
|
||||
json = TRI_CreateArrayJson(zone);
|
||||
|
||||
if (json == NULL) {
|
||||
return NULL;
|
||||
if (json == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TRI_Insert3ArrayJson(zone, json, "waitForSync", TRI_CreateBooleanJson(zone, defaults->defaultWaitForSync));
|
||||
|
|
|
@ -871,20 +871,17 @@ static int ScanPath (TRI_vocbase_t* vocbase,
|
|||
}
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
char* name;
|
||||
char* file;
|
||||
|
||||
name = files._buffer[i];
|
||||
TRI_ASSERT(name != NULL);
|
||||
char* name = files._buffer[i];
|
||||
TRI_ASSERT(name != nullptr);
|
||||
|
||||
if (regexec(&re, name, sizeof(matches) / sizeof(matches[0]), matches, 0) != 0) {
|
||||
// no match, ignore this file
|
||||
continue;
|
||||
}
|
||||
|
||||
file = TRI_Concatenate2File(path, name);
|
||||
char* file = TRI_Concatenate2File(path, name);
|
||||
|
||||
if (file == NULL) {
|
||||
if (file == nullptr) {
|
||||
LOG_FATAL_AND_EXIT("out of memory");
|
||||
}
|
||||
|
||||
|
@ -973,7 +970,7 @@ static int ScanPath (TRI_vocbase_t* vocbase,
|
|||
|
||||
c = AddCollection(vocbase, type, info._name, info._cid, file);
|
||||
|
||||
if (c == NULL) {
|
||||
if (c == nullptr) {
|
||||
LOG_ERROR("failed to add document collection from '%s'", file);
|
||||
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, file);
|
||||
|
@ -990,7 +987,7 @@ static int ScanPath (TRI_vocbase_t* vocbase,
|
|||
if (iterateMarkers) {
|
||||
// iterating markers may be time-consuming. we'll only do it if
|
||||
// we have to
|
||||
TRI_IterateTicksCollection(file, StartupTickIterator, NULL);
|
||||
TRI_IterateTicksCollection(file, StartupTickIterator, nullptr);
|
||||
}
|
||||
|
||||
LOG_DEBUG("added document collection from '%s'", file);
|
||||
|
@ -1168,21 +1165,19 @@ static int LoadCollectionVocBase (TRI_vocbase_t* vocbase,
|
|||
static int FilterCollectionIndex (TRI_vocbase_col_t* collection,
|
||||
char const* filename,
|
||||
void* data) {
|
||||
TRI_json_t* indexJson;
|
||||
TRI_json_t* id;
|
||||
index_json_helper_t* ij = (index_json_helper_t*) data;
|
||||
|
||||
indexJson = TRI_JsonFile(TRI_CORE_MEM_ZONE, filename, NULL);
|
||||
TRI_json_t* indexJson = TRI_JsonFile(TRI_CORE_MEM_ZONE, filename, nullptr);
|
||||
|
||||
if (indexJson == NULL) {
|
||||
if (indexJson == nullptr) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// compare index id with tick value
|
||||
id = TRI_LookupArrayJson(indexJson, "id");
|
||||
TRI_json_t* id = TRI_LookupArrayJson(indexJson, "id");
|
||||
|
||||
// index id is numeric
|
||||
if (id != NULL && id->_type == TRI_JSON_NUMBER) {
|
||||
if (TRI_IsNumberJson(id)) {
|
||||
uint64_t iid = (uint64_t) id->_value._number;
|
||||
|
||||
if (iid > (uint64_t) ij->_maxTick) {
|
||||
|
@ -1333,25 +1328,25 @@ TRI_vocbase_t* TRI_CreateInitialVocBase (TRI_vocbase_type_e type,
|
|||
// init AQL functions
|
||||
vocbase->_functions = TRI_CreateFunctionsAql();
|
||||
|
||||
if (vocbase->_functions == NULL) {
|
||||
if (vocbase->_functions == nullptr) {
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_name);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_path);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
vocbase->_cursors = TRI_CreateStoreGeneralCursor();
|
||||
|
||||
if (vocbase->_cursors == NULL) {
|
||||
if (vocbase->_cursors == nullptr) {
|
||||
TRI_FreeFunctionsAql(vocbase->_functions);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_name);
|
||||
TRI_Free(TRI_CORE_MEM_ZONE, vocbase->_path);
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
|
||||
TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// init usage info
|
||||
|
@ -1368,14 +1363,14 @@ TRI_vocbase_t* TRI_CreateInitialVocBase (TRI_vocbase_type_e type,
|
|||
HashKeyCid,
|
||||
HashElementCid,
|
||||
EqualKeyCid,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
TRI_InitAssociativePointer(&vocbase->_collectionsByName,
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
HashKeyCollectionName,
|
||||
HashElementCollectionName,
|
||||
EqualKeyCollectionName,
|
||||
NULL);
|
||||
nullptr);
|
||||
|
||||
TRI_InitAuthInfo(vocbase);
|
||||
|
||||
|
@ -1438,17 +1433,14 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server,
|
|||
TRI_vocbase_defaults_t const* defaults,
|
||||
bool isUpgrade,
|
||||
bool iterateMarkers) {
|
||||
TRI_vocbase_t* vocbase;
|
||||
int res;
|
||||
TRI_ASSERT(name != nullptr);
|
||||
TRI_ASSERT(path != nullptr);
|
||||
TRI_ASSERT(defaults != nullptr);
|
||||
|
||||
TRI_ASSERT(name != NULL);
|
||||
TRI_ASSERT(path != NULL);
|
||||
TRI_ASSERT(defaults != NULL);
|
||||
TRI_vocbase_t* vocbase = TRI_CreateInitialVocBase(TRI_VOCBASE_TYPE_NORMAL, path, id, name, defaults);
|
||||
|
||||
vocbase = TRI_CreateInitialVocBase(TRI_VOCBASE_TYPE_NORMAL, path, id, name, defaults);
|
||||
|
||||
if (vocbase == NULL) {
|
||||
return NULL;
|
||||
if (vocbase == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TRI_InitCompactorVocBase(vocbase);
|
||||
|
@ -1461,7 +1453,7 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server,
|
|||
// this will create the list of collections and their datafiles, and will also
|
||||
// determine the last tick values used (if iterateMarkers is true)
|
||||
|
||||
res = ScanPath(vocbase, vocbase->_path, isUpgrade, iterateMarkers);
|
||||
int res = ScanPath(vocbase, vocbase->_path, isUpgrade, iterateMarkers);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
TRI_DestroyCompactorVocBase(vocbase);
|
||||
|
@ -1469,7 +1461,7 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server,
|
|||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, vocbase);
|
||||
TRI_set_errno(res);
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ScanTrxCollection(vocbase);
|
||||
|
@ -1486,7 +1478,7 @@ TRI_vocbase_t* TRI_OpenVocBase (TRI_server_t* server,
|
|||
|
||||
// start cleanup thread
|
||||
TRI_InitThread(&vocbase->_cleanup);
|
||||
TRI_StartThread(&vocbase->_cleanup, NULL, "[cleanup]", TRI_CleanupVocBase, vocbase);
|
||||
TRI_StartThread(&vocbase->_cleanup, nullptr, "[cleanup]", TRI_CleanupVocBase, vocbase);
|
||||
|
||||
// we are done
|
||||
return vocbase;
|
||||
|
@ -1577,7 +1569,7 @@ void TRI_StartCompactorVocBase (TRI_vocbase_t* vocbase) {
|
|||
LOG_TRACE("starting compactor for database '%s'", vocbase->_name);
|
||||
// start compactor thread
|
||||
TRI_InitThread(&vocbase->_compactor);
|
||||
TRI_StartThread(&vocbase->_compactor, NULL, "[compactor]", TRI_CompactorVocBase, vocbase);
|
||||
TRI_StartThread(&vocbase->_compactor, nullptr, "[compactor]", TRI_CompactorVocBase, vocbase);
|
||||
vocbase->_hasCompactor = true;
|
||||
}
|
||||
|
||||
|
@ -1614,7 +1606,7 @@ TRI_vector_pointer_t TRI_CollectionsVocBase (TRI_vocbase_t* vocbase) {
|
|||
for (size_t i = 0; i < vocbase->_collectionsById._nrAlloc; ++i) {
|
||||
TRI_vocbase_col_t* found = static_cast<TRI_vocbase_col_t*>(vocbase->_collectionsById._table[i]);
|
||||
|
||||
if (found != NULL) {
|
||||
if (found != nullptr) {
|
||||
TRI_PushBackVectorPointer(&result, found);
|
||||
}
|
||||
}
|
||||
|
@ -1638,10 +1630,10 @@ TRI_vector_string_t TRI_CollectionNamesVocBase (TRI_vocbase_t* vocbase) {
|
|||
for (size_t i = 0; i < vocbase->_collectionsById._nrAlloc; ++i) {
|
||||
TRI_vocbase_col_t* found = static_cast<TRI_vocbase_col_t*>(vocbase->_collectionsById._table[i]);
|
||||
|
||||
if (found != NULL) {
|
||||
if (found != nullptr) {
|
||||
char const* name = found->_name;
|
||||
|
||||
if (name != NULL) {
|
||||
if (name != nullptr) {
|
||||
TRI_PushBackVectorString(&result, TRI_DuplicateStringZ(TRI_UNKNOWN_MEM_ZONE, name));
|
||||
}
|
||||
}
|
||||
|
@ -1706,25 +1698,22 @@ TRI_json_t* TRI_InventoryCollectionsVocBase (TRI_vocbase_t* vocbase,
|
|||
}
|
||||
|
||||
// check if we want this collection
|
||||
if (filter != NULL && ! filter(collection, data)) {
|
||||
if (filter != nullptr && ! filter(collection, data)) {
|
||||
TRI_READ_UNLOCK_STATUS_VOCBASE_COL(collection);
|
||||
continue;
|
||||
}
|
||||
|
||||
TRI_json_t* result = TRI_CreateArray2Json(TRI_CORE_MEM_ZONE, 2);
|
||||
|
||||
if (result != NULL) {
|
||||
TRI_json_t* collectionInfo;
|
||||
TRI_json_t* indexesInfo;
|
||||
if (result != nullptr) {
|
||||
TRI_json_t* collectionInfo = TRI_ReadJsonCollectionInfo(collection);
|
||||
|
||||
collectionInfo = TRI_ReadJsonCollectionInfo(collection);
|
||||
|
||||
if (collectionInfo != NULL) {
|
||||
if (collectionInfo != nullptr) {
|
||||
TRI_Insert3ArrayJson(TRI_CORE_MEM_ZONE, result, "parameters", collectionInfo);
|
||||
|
||||
indexesInfo = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
|
||||
TRI_json_t* indexesInfo = TRI_CreateListJson(TRI_CORE_MEM_ZONE);
|
||||
|
||||
if (indexesInfo != NULL) {
|
||||
if (indexesInfo != nullptr) {
|
||||
index_json_helper_t ij;
|
||||
ij._list = indexesInfo;
|
||||
ij._maxTick = maxTick;
|
||||
|
@ -2153,9 +2142,6 @@ int TRI_RenameCollectionVocBase (TRI_vocbase_t* vocbase,
|
|||
TRI_vocbase_col_t* collection,
|
||||
char const* newName,
|
||||
bool doOverride) {
|
||||
char* oldName;
|
||||
int res;
|
||||
|
||||
if (! collection->_canRename) {
|
||||
return TRI_set_errno(TRI_ERROR_FORBIDDEN);
|
||||
}
|
||||
|
@ -2164,11 +2150,11 @@ int TRI_RenameCollectionVocBase (TRI_vocbase_t* vocbase,
|
|||
TRI_READ_LOCK_STATUS_VOCBASE_COL(collection);
|
||||
|
||||
// old name should be different
|
||||
oldName = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, collection->_name);
|
||||
char* oldName = TRI_DuplicateStringZ(TRI_CORE_MEM_ZONE, collection->_name);
|
||||
|
||||
TRI_READ_UNLOCK_STATUS_VOCBASE_COL(collection);
|
||||
|
||||
if (oldName == NULL) {
|
||||
if (oldName == nullptr) {
|
||||
return TRI_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -2205,7 +2191,7 @@ int TRI_RenameCollectionVocBase (TRI_vocbase_t* vocbase,
|
|||
|
||||
TRI_ReadLockReadWriteLock(&vocbase->_inventoryLock);
|
||||
|
||||
res = RenameCollection(vocbase, collection, oldName, newName);
|
||||
int res = RenameCollection(vocbase, collection, oldName, newName);
|
||||
|
||||
TRI_ReadUnlockReadWriteLock(&vocbase->_inventoryLock);
|
||||
|
||||
|
|
Loading…
Reference in New Issue