mirror of https://gitee.com/bigwinds/arangodb
fixed memlekas
This commit is contained in:
parent
56b270be18
commit
12c16b0a09
|
@ -1757,11 +1757,11 @@ bool TRI_ContainsImpossibleAql (const TRI_vector_pointer_t* const fieldAccesses)
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clone a vector of ranges
|
||||
/// @brief clone a vector of accesses
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_vector_pointer_t* TRI_CloneRangesAql (TRI_aql_context_t* const context,
|
||||
const TRI_vector_pointer_t* const source) {
|
||||
TRI_vector_pointer_t* TRI_CloneAccessesAql (TRI_aql_context_t* const context,
|
||||
const TRI_vector_pointer_t* const source) {
|
||||
TRI_vector_pointer_t* result;
|
||||
|
||||
if (!source) {
|
||||
|
@ -1987,14 +1987,11 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
|||
}
|
||||
else {
|
||||
// create a new vector
|
||||
accesses = (TRI_vector_pointer_t*) TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_vector_pointer_t), false);
|
||||
accesses = CreateEmptyVector(context);
|
||||
if (accesses == NULL) {
|
||||
// OOM
|
||||
TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TRI_InitVectorPointer(accesses, TRI_UNKNOWN_MEM_ZONE);
|
||||
}
|
||||
|
||||
assert(accesses);
|
||||
|
@ -2019,13 +2016,14 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
|||
|
||||
// free existing field access
|
||||
TRI_FreeAccessAql(existing);
|
||||
// insert candidate instead
|
||||
copy = TRI_CloneAccessAql(context, candidate);
|
||||
if (!copy) {
|
||||
// OOM
|
||||
TRI_SetErrorContextAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL);
|
||||
return accesses;
|
||||
}
|
||||
|
||||
// insert copy of candidate instead
|
||||
accesses->_buffer[i] = (void*) copy;
|
||||
}
|
||||
break;
|
||||
|
@ -2033,7 +2031,7 @@ TRI_vector_pointer_t* TRI_AddAccessAql (TRI_aql_context_t* const context,
|
|||
|
||||
if (!found) {
|
||||
// not found, now add this candidate
|
||||
TRI_PushBackVectorPointer(accesses, candidate);
|
||||
TRI_PushBackVectorPointer(accesses, TRI_CloneAccessAql(context, candidate));
|
||||
}
|
||||
|
||||
return accesses;
|
||||
|
|
|
@ -157,11 +157,11 @@ TRI_aql_field_access_t* TRI_CreateImpossibleAccessAql (TRI_aql_context_t* const)
|
|||
bool TRI_ContainsImpossibleAql (const TRI_vector_pointer_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clone a vector of ranges
|
||||
/// @brief clone a vector of accesses
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_vector_pointer_t* TRI_CloneRangesAql (TRI_aql_context_t* const,
|
||||
const TRI_vector_pointer_t* const);
|
||||
TRI_vector_pointer_t* TRI_CloneAccessesAql (TRI_aql_context_t* const,
|
||||
const TRI_vector_pointer_t* const);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief free access structure with its members and the pointer
|
||||
|
|
|
@ -146,6 +146,7 @@ static void PatchForLoops (TRI_aql_context_t* const context) {
|
|||
|
||||
// merge the field access found into the already existing field accesses for the node
|
||||
PatchForNode(context, scope->_node, fieldAccess);
|
||||
break;
|
||||
}
|
||||
|
||||
TRI_FreeString(TRI_CORE_MEM_ZONE, prefix);
|
||||
|
@ -164,7 +165,7 @@ static void FreeScope (TRI_aql_optimiser_scope_t* const scope) {
|
|||
}
|
||||
|
||||
if (scope->_ranges) {
|
||||
TRI_FreeVectorPointer(TRI_UNKNOWN_MEM_ZONE, scope->_ranges);
|
||||
TRI_FreeAccessesAql(scope->_ranges);
|
||||
}
|
||||
|
||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, scope);
|
||||
|
@ -216,9 +217,10 @@ static void StartScope (TRI_aql_context_t* const context,
|
|||
|
||||
if (context->_optimiser._scopes._length > 0) {
|
||||
// copy ranges of parent scope into current one
|
||||
scope->_ranges = TRI_CloneRangesAql(context, CurrentScope(&context->_optimiser._scopes)->_ranges);
|
||||
scope->_ranges = TRI_CloneAccessesAql(context, CurrentScope(&context->_optimiser._scopes)->_ranges);
|
||||
}
|
||||
|
||||
|
||||
// finally, add the new scope
|
||||
TRI_PushBackVectorPointer(&context->_optimiser._scopes, scope);
|
||||
}
|
||||
|
||||
|
@ -237,7 +239,7 @@ static void EndScope (TRI_aql_context_t* const context, const bool isReturn) {
|
|||
// we are closing at least one scope
|
||||
while (true) {
|
||||
TRI_aql_codegen_scope_e type = scope->_type;
|
||||
|
||||
|
||||
FreeScope(scope);
|
||||
|
||||
TRI_RemoveVectorPointer(&context->_optimiser._scopes, context->_optimiser._scopes._length - 1);
|
||||
|
@ -486,13 +488,18 @@ TRY_LOOP:
|
|||
}
|
||||
|
||||
if (!TRI_IsConstantValueNodeAql(expression)) {
|
||||
TRI_vector_pointer_t* ranges;
|
||||
TRI_vector_pointer_t* oldRanges;
|
||||
TRI_vector_pointer_t* newRanges;
|
||||
bool changed = false;
|
||||
|
||||
ranges = TRI_OptimiseRangesAql(context, expression, &changed, scope->_ranges);
|
||||
oldRanges = scope->_ranges;
|
||||
newRanges = TRI_OptimiseRangesAql(context, expression, &changed, oldRanges);
|
||||
|
||||
if (ranges) {
|
||||
scope->_ranges = ranges;
|
||||
if (newRanges) {
|
||||
if (oldRanges) {
|
||||
TRI_FreeAccessesAql(oldRanges);
|
||||
}
|
||||
scope->_ranges = newRanges;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
|
|
Loading…
Reference in New Issue