-
Notifications
You must be signed in to change notification settings - Fork 103
Enhance param parse for 3L and LRB #204
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| #include <assert.h> | ||
|
|
||
| #include <map> | ||
|
|
@@ -92,10 +92,9 @@ | |
| ThreeLCache_params_t *params = my_malloc(ThreeLCache_params_t); | ||
| cache->eviction_params = params; | ||
|
|
||
| ThreeLCache_parse_params(cache, DEFAULT_PARAMS); | ||
| if (cache_specific_params != NULL) { | ||
| ThreeLCache_parse_params(cache, cache_specific_params); | ||
| } else { | ||
| ThreeLCache_parse_params(cache, DEFAULT_PARAMS); | ||
| } | ||
|
|
||
| auto *ThreeLCache = new ThreeLCache::ThreeLCacheCache(); | ||
|
|
@@ -131,6 +130,9 @@ | |
| static_cast<ThreeLCache::ThreeLCacheCache *>(params->ThreeLCache_cache); | ||
| delete ThreeLCache; | ||
| free(cache->to_evict_candidate); | ||
| if (params->objective != NULL) { | ||
| free(params->objective); | ||
| } | ||
| my_free(sizeof(ThreeLCache_params_t), params); | ||
| cache_struct_free(cache); | ||
| } | ||
|
|
@@ -340,6 +342,9 @@ | |
| } | ||
|
|
||
| if (strcasecmp(key, "objective") == 0) { | ||
| if (params->objective != NULL) { | ||
|
||
| free(params->objective); | ||
| } | ||
| params->objective = strdup(value); | ||
| if (params->objective == NULL) { | ||
| ERROR("out of memory %s\n", strerror(errno)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,3 @@ | ||||||||
|
|
||||||||
|
|
||||||||
| #include <assert.h> | ||||||||
|
|
@@ -95,10 +95,9 @@ | |||||||
| LRB_params_t *params = my_malloc(LRB_params_t); | ||||||||
| cache->eviction_params = params; | ||||||||
|
|
||||||||
| LRB_parse_params(cache, DEFAULT_PARAMS); | ||||||||
| if (cache_specific_params != NULL) { | ||||||||
| LRB_parse_params(cache, cache_specific_params); | ||||||||
| } else { | ||||||||
| LRB_parse_params(cache, DEFAULT_PARAMS); | ||||||||
| } | ||||||||
|
|
||||||||
| auto *lrb = new lrb::LRBCache(); | ||||||||
|
|
@@ -133,6 +132,9 @@ | |||||||
| auto *LRB = static_cast<lrb::LRBCache *>(params->LRB_cache); | ||||||||
| delete LRB; | ||||||||
| free(cache->to_evict_candidate); | ||||||||
|
||||||||
| free(cache->to_evict_candidate); | |
| free(cache->to_evict_candidate); | |
| // Ensure that 'objective' is freed to prevent memory leaks. |
Copilot
AI
Jun 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Freeing the existing 'objective' before reassigning it avoids memory leaks; this practice is consistent with robust memory management.
| free(params->objective); | |
| free(params->objective); | |
| params->objective = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a check and free for 'objective' in the free function reinforces memory safety; ensure this pattern is uniformly applied across all similar modules.