C-Plus-Plus icon indicating copy to clipboard operation
C-Plus-Plus copied to clipboard

fix: memory issues in `counting_sort.cpp`

Open vil02 opened this issue 2 years ago • 2 comments

Description of Change

There are several problems with the current implementation of counting_sort.cpp:

  • memory allocated by creating *Count is uninitialized and not deleted, https://github.com/TheAlgorithms/C-Plus-Plus/blob/23b133ae1eac4ad7e94e74da140d462180738413/sorting/counting_sort.cpp#L29
  • memory allocated by creating *Sorted_Arr is not deleted. https://github.com/TheAlgorithms/C-Plus-Plus/blob/23b133ae1eac4ad7e94e74da140d462180738413/sorting/counting_sort.cpp#L27

This PR fixes that.

Checklist

  • [x] Added description of change
  • [x] PR title follows semantic commit guidelines
  • [x] Search previous suggestions before making a new one, as yours may be a duplicate.
  • [x] I acknowledge that all my contributions will be made under the project's license.

Notes: This PR fixes memory issues in counting_sort.cpp.

vil02 avatar Sep 11 '23 17:09 vil02

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 25 '23 00:12 github-actions[bot]

@Panquesito7, @realstealthninja: please dont-close.

vil02 avatar Dec 25 '23 04:12 vil02