8000 remove memset parameter from TRI_Allocate signature by jsteemann · Pull Request #2993 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

remove memset parameter from TRI_Allocate signature #2993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
remove memset parameter from TRI_Allocate signature
  • Loading branch information
jsteemann committed Aug 8, 2017
commit ed8a7f23d350bac99a22c58de73b0a7032d6cbc8
2 changes: 1 addition & 1 deletion arangod/MMFiles/MMFilesSkiplist.h
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ class MMFilesSkiplist {
// allocate enough memory for skiplist node plus all the next nodes in one
// go
void* ptr = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE,
sizeof(Node) + sizeof(Node*) * height, false);
sizeof(Node) + sizeof(Node*) * height);

if (ptr == nullptr) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
Expand Down
17 changes: 11 additions & 6 deletions arangod/MMFiles/mmfiles-fulltext-handles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static bool AllocateSlot(TRI_fulltext_handles_t* const handles,
}

auto slot = static_cast<TRI_fulltext_handle_slot_t*>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_fulltext_handle_slot_t), false));
TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_fulltext_handle_slot_t)));

if (slot == nullptr) {
return false;
Expand All @@ -55,22 +55,26 @@ static bool AllocateSlot(TRI_fulltext_handles_t* const handles,
// allocate and clear
slot->_documents = static_cast<TRI_voc_rid_t*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE,
sizeof(TRI_voc_rid_t) * handles->_slotSize, true));
sizeof(TRI_voc_rid_t) * handles->_slotSize));

if (slot->_documents == nullptr) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, slot);
return false;
}

memset(slot->_documents, 0, sizeof(TRI_voc_rid_t) * handles->_slotSize);

// allocate and clear deleted flags
slot->_deleted = static_cast<uint8_t*>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE, sizeof(uint8_t) * handles->_slotSize, true));
TRI_UNKNOWN_MEM_ZONE, sizeof(uint8_t) * handles->_slotSize));

if (slot->_deleted == nullptr) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, slot->_documents);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, slot);
return false;
}

memset(slot->_deleted, 0, sizeof(uint8_t) * handles->_slotSize);

// set initial statistics
slot->_min = UINT32_MAX; // yes, this is intentional
Expand Down Expand Up @@ -104,13 +108,14 @@ static bool AllocateSlotList(TRI_fulltext_handles_t* const handles,
TRI_fulltext_handle_slot_t** slots =
static_cast<TRI_fulltext_handle_slot_t**>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE,
sizeof(TRI_fulltext_handle_slot_t*) * targetNumber, true));
sizeof(TRI_fulltext_handle_slot_t*) * targetNumber));

if (slots == nullptr) {
// out of memory
return false;
}

memset(slots, 0, sizeof(TRI_fulltext_handle_slot_t*) * targetNumber);
uint32_t currentNumber = handles->_numSlots;

if (currentNumber > 0) {
Expand All @@ -137,7 +142,7 @@ static bool AllocateSlotList(TRI_fulltext_handles_t* const handles,
TRI_fulltext_handles_t* TRI_CreateHandlesMMFilesFulltextIndex(uint32_t slotSize) {
TRI_fulltext_handles_t* handles =
static_cast<TRI_fulltext_handles_t*>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_fulltext_handles_t), false));
TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_fulltext_handles_t)));

if (handles == nullptr) {
return nullptr;
Expand Down Expand Up @@ -209,7 +214,7 @@ TRI_fulltext_handles_t* TRI_CompactHandleMMFilesFulltextIndex(

TRI_fulltext_handle_t* map = static_cast<TRI_fulltext_handle_t*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE,
sizeof(TRI_fulltext_handle_t) * original->_next, false));
sizeof(TRI_fulltext_handle_t) * original->_next));

if (map == nullptr) {
return nullptr;
Expand Down
7 changes: 3 additions & 4 deletions arangod/MMFiles/mmfiles-fulltext-index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static inline void* AllocateMemory(index__t* const idx, size_t const size) {
TRI_ASSERT(size > 0);
#endif

data = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, size, false);
data = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, size);
if (data != nullptr) {
idx->_memoryAllocated += size;
}
Expand Down Expand Up @@ -1221,8 +1221,8 @@ void TRI_DeleteDocumentMMFilesFulltextIndex(TRI_fts_index_t* const ftx,
/// - save redundant lookups of prefix nodes for adjacent words with shared
/// prefixes
bool TRI_InsertWordsMMFilesFulltextIndex(TRI_fts_index_t* const ftx,
const TRI_voc_rid_t document,
std::set<std::string>& wordlist) {
TRI_voc_rid_t document,
std::set<std::string> const& wordlist) {
index__t* idx;
TRI_fulltext_handle_t handle;
node_t* paths[MAX_WORD_BYTES + 4];
Expand All @@ -1241,7 +1241,6 @@ bool TRI_InsertWordsMMFilesFulltextIndex(TRI_fts_index_t* const ftx,
// for words with common prefixes (which will be adjacent in the sorted list
// of words)
// The default comparator (<) is exactly what we need here
//std::sort(wordlist.begin(), wordlist.end());

idx = static_cast<index__t*>(ftx);

Expand Down
6 changes: 3 additions & 3 deletions arangod/MMFiles/mmfiles-fulltext-index.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ void TRI_TruncateMMFilesFulltextIndex(TRI_fts_index_t*);

/// @brief delete a document from the index
void TRI_DeleteDocumentMMFilesFulltextIndex(TRI_fts_index_t* const,
const TRI_voc_rid_t);
TRI_voc_rid_t);

/// @brief insert a list of words to the index
bool TRI_InsertWordsMMFilesFulltextIndex(TRI_fts_index_t* const,
const TRI_voc_rid_t,
std::set<std::string>&);
TRI_voc_rid_t,
std::set<std::string> const&);

/// @brief find all documents that contain a word (exact match)
#if 0
Expand Down
2 changes: 1 addition & 1 deletion arangod/MMFiles/mmfiles-fulltext-list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ TRI_fulltext_list_t* TRI_CloneListMMFilesFulltextIndex(
/// @brief create a new list
TRI_fulltext_list_t* TRI_CreateListMMFilesFulltextIndex(uint32_t size) {
TRI_fulltext_list_t* list =
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, MemoryList(size), false);
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, MemoryList(size));

if (list == nullptr) {
// out of memory
Expand Down
12 changes: 7 additions & 5 deletions arangod/MMFiles/mmfiles-fulltext-query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static char* NormalizeWord(char const* word, size_t wordLength) {
ptrdiff_t prefixLength = prefixEnd - copy2;

char* copy3 = static_cast<char*>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE, sizeof(char) * ((size_t)prefixLength + 1), false));
TRI_UNKNOWN_MEM_ZONE, sizeof(char) * ((size_t)prefixLength + 1)));

if (copy3 == nullptr) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, copy2);
Expand All @@ -82,24 +82,26 @@ static char* NormalizeWord(char const* word, size_t wordLength) {
TRI_fulltext_query_t* TRI_CreateQueryMMFilesFulltextIndex(size_t numWords,
size_t maxResults) {
TRI_fulltext_query_t* query = static_cast<TRI_fulltext_query_t*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_fulltext_query_t), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_fulltext_query_t)));

if (query == nullptr) {
return nullptr;
}

// fill word vector with NULLs
query->_words = static_cast<char**>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(char*) * numWords, true));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(char*) * numWords));

if (query->_words == nullptr) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, query);
return nullptr;
}

memset(query->_words, 0, sizeof(char*) * numWords);

query->_matches = static_cast<TRI_fulltext_query_match_e*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE,
sizeof(TRI_fulltext_query_match_e) * numWords, false));
sizeof(TRI_fulltext_query_match_e) * numWords));

if (query->_matches == nullptr) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, query->_words);
Expand All @@ -109,7 +111,7 @@ TRI_fulltext_query_t* TRI_CreateQueryMMFilesFulltextIndex(size_t numWords,

query->_operations = static_cast<TRI_fulltext_query_operation_e*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE,
sizeof(TRI_fulltext_query_operation_e) * numWords, false));
sizeof(TRI_fulltext_query_operation_e) * numWords));

if (query->_operations == nullptr) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, query->_matches);
Expand Down
4 changes: 2 additions & 2 deletions arangod/MMFiles/mmfiles-fulltext-result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/// @brief create a result
TRI_fulltext_result_t* TRI_CreateResultMMFilesFulltextIndex(const uint32_t size) {
TRI_fulltext_result_t* result = static_cast<TRI_fulltext_result_t*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_fulltext_result_t), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_fulltext_result_t)));

if (result == nullptr) {
return nullptr;
Expand All @@ -38,7 +38,7 @@ TRI_fulltext_result_t* TRI_CreateResultMMFilesFulltextIndex(const uint32_t size)

if (size > 0) {
result->_documents = static_cast<arangodb::DocumentIdentifierToken*>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE, sizeof(arangodb::DocumentIdentifierToken) * size, false));
TRI_UNKNOWN_MEM_ZONE, sizeof(arangodb::DocumentIdentifierToken) * size));

if (result->_documents == nullptr) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, result);
Expand Down
16 changes: 8 additions & 8 deletions arangod/MMFiles/mmfiles-geo-index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,17 @@ GeoIdx* GeoIndex_new(void) {
int i, j;

gix = static_cast<GeoIx*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoIx), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoIx)));

if (gix == nullptr) {
return (GeoIdx*)gix;
}

/* try to allocate all the things we need */
gix->pots = static_cast<GeoPot*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, GEOPOTSTART * sizeof(GeoPot), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, GEOPOTSTART * sizeof(GeoPot)));
gix->gc = static_cast<GeoCoordinate*>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE, GEOSLOTSTART * sizeof(GeoCoordinate), false));
TRI_UNKNOWN_MEM_ZONE, GEOSLOTSTART * sizeof(GeoCoordinate)));

/* if any of them fail, free the ones that succeeded */
/* and then return the nullptr for our user */
Expand Down Expand Up @@ -782,11 +782,11 @@ GeoResults* GeoResultsCons(int alloc) {
}

gres = static_cast<GeoResults*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoResults), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoResults)));
sa = static_cast<int*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, alloc * sizeof(int), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, alloc * sizeof(int)));
dd = static_cast<double*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, alloc * sizeof(double), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, alloc * sizeof(double)));
if ((gres == NULL) || (sa == NULL) || (dd == NULL)) {
if (gres != NULL) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, gres);
Expand Down Expand Up @@ -944,9 +944,9 @@ GeoCoordinates* GeoAnswers(GeoIx* gix, GeoResults* gr, bool returnDistances) {
}

ans = static_cast<GeoCoordinates*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoCoordinates), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoCoordinates)));
gc = static_cast<GeoCoordinate*>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE, gr->pointsct * sizeof(GeoCoordinate), false));
TRI_UNKNOWN_MEM_ZONE, gr->pointsct * sizeof(GeoCoordinate)));

if ((ans == NULL) || (gc == NULL)) {
if (ans != NULL) {
Expand Down
12 changes: 6 additions & 6 deletions arangod/RocksDBEngine/RocksDBGeoIndexImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ GeoIdx* GeoIndex_new(uint64_t objectId, int numPots, int numSlots) {
int i;

gix = static_cast<GeoIx*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoIx), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoIx)));

if (gix == nullptr) {
return (GeoIdx*)gix;
Expand Down Expand Up @@ -887,11 +887,11 @@ GeoResults* GeoResultsCons(int alloc) {
}

gres = static_cast<GeoResults*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoResults), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoResults)));
sa = static_cast<int*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, alloc * sizeof(int), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, alloc * sizeof(int)));
dd = static_cast<double*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, alloc * sizeof(double), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, alloc * sizeof(double)));
if ((gres == nullptr) || (sa == nullptr) || (dd == nullptr)) {
if (gres != nullptr) {
TRI_Free(TRI_UNKNOWN_MEM_ZONE, gres);
Expand Down Expand Up @@ -1050,9 +1050,9 @@ GeoCoordinates* GeoAnswers(GeoIx* gix, GeoResults* gr, bool returnDistances) {
}

ans = static_cast<GeoCoordinates*>(
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoCoordinates), false));
TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(GeoCoordinates)));
gc = static_cast<GeoCoordinate*>(TRI_Allocate(
TRI_UNKNOWN_MEM_ZONE, gr->pointsct * sizeof(GeoCoordinate), false));
TRI_UNKNOWN_MEM_ZONE, gr->pointsct * sizeof(GeoCoordinate)));

if ((ans == nullptr) || (gc == nullptr)) {
if (ans != nullptr) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Basics/StringBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static int AppendString(TRI_string_buffer_t* self, char const* str,
/// @brief create a new string buffer and initialize it
TRI_string_buffer_t* TRI_CreateStringBuffer(TRI_memory_zone_t* zone) {
auto self = static_cast<TRI_string_buffer_t*>(TRI_Allocate(
zone, sizeof(TRI_string_buffer_t), false));
zone, sizeof(TRI_string_buffer_t)));

if (self == nullptr) {
return nullptr;
Expand All @@ -98,7 +98,7 @@ TRI_string_buffer_t* TRI_CreateStringBuffer(TRI_memory_zone_t* zone) {
TRI_string_buffer_t* TRI_CreateSizedStringBuffer(TRI_memory_zone_t* zone,
size_t size) {
auto self = static_cast<TRI_string_buffer_t*>(TRI_Allocate(
zone, sizeof(TRI_string_buffer_t), false));
zone, sizeof(TRI_string_buffer_t)));

if (self == nullptr) {
return nullptr;
Expand Down Expand Up @@ -187,7 +187,7 @@ int TRI_DeflateStringBuffer(TRI_string_buffer_t* self, size_t bufferSize) {
return TRI_ERROR_OUT_OF_MEMORY;
}

buffer = (char*)TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, bufferSize, false);
buffer = static_cast<char*>(TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, bufferSize));

if (buffer == nullptr) {
(void)deflateEnd(&strm);
Expand Down
Loading
0