yiguolei commented on code in PR #9521:
URL: https://github.com/apache/incubator-doris/pull/9521#discussion_r876813350
##########
be/src/olap/lru_cache.cpp:
##########
@@ -148,29 +143,22 @@ void HandleTable::_resize() {
LRUHandle** new_list = new (std::nothrow) LRUHandle*[new_length];
memset(new_list, 0, sizeof(new_list[0]) * new_length);
- for (uint32_t i = 0; i < new_length; i++) {
- // The first node in the linked-list is a dummy node used for
- // inserting new node mainly.
- new_list[i] = new LRUHandle();
- }
uint32_t count = 0;
for (uint32_t i = 0; i < _length; i++) {
- LRUHandle* h = _list[i]->next_hash;
+ LRUHandle* h = _list[i];
while (h != nullptr) {
LRUHandle* next = h->next_hash;
uint32_t hash = h->hash;
- LRUHandle* head = new_list[hash & (new_length - 1)];
- _head_insert(head, h);
+ LRUHandle** ptr = &new_list[hash & (new_length - 1)];
+ h->next_hash = *ptr;
+ *ptr = h;
h = next;
count++;
}
}
DCHECK_EQ(_elems, count);
- for (uint32_t i = 0; i < _length; i++) {
- delete _list[i];
- }
Review Comment:
not memory leak ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]