This pull request addresses a potential memory leak in the load_model function by ensuring that the dynamically allocated memory for 'model' is properly deallocated before returning NULL in case of a model loading failure. Additionally, it includes changes to the convert-hf-to-ggml.py script to improve its readability and consistency.
Changes Made:
Added memory deallocation for 'model' before returning NULL in case of a model loading failure.
Utilized the delete operator to release the dynamically allocated memory.
Removed a few unnecessary semicolons from the convert-hf-to-ggml.py script to enhance code readability and consistency.
Explanation:
The load_model function previously allocated memory for 'model' using the new operator but didn't release it in case the model loading failed, potentially causing a memory leak. To address this issue, I added a delete model; statement before returning NULL when the loading fails.
In the convert-hf-to-ggml.py script, I removed a few semicolons that were not required for proper code execution. This change enhances the code's readability and maintains consistency with Python's coding style.
Pull Request Summary:
This pull request addresses a potential memory leak in the
load_model
function by ensuring that the dynamically allocated memory for 'model' is properly deallocated before returningNULL
in case of a model loading failure. Additionally, it includes changes to theconvert-hf-to-ggml.py
script to improve its readability and consistency.Changes Made:
NULL
in case of a model loading failure.delete
operator to release the dynamically allocated memory.convert-hf-to-ggml.py
script to enhance code readability and consistency.Explanation:
The
load_model
function previously allocated memory for 'model' using thenew
operator but didn't release it in case the model loading failed, potentially causing a memory leak. To address this issue, I added adelete model;
statement before returningNULL
when the loading fails.In the
convert-hf-to-ggml.py
script, I removed a few semicolons that were not required for proper code execution. This change enhances the code's readability and maintains consistency with Python's coding style.