Skip to content

Commit

Permalink
Merge pull request #53 from jrenaud90/ver0.9.0
Browse files Browse the repository at this point in the history
Added free_mem function to utils
  • Loading branch information
jrenaud90 authored May 23, 2024
2 parents 02c0c57 + 9a612bb commit 1960d51
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CyRK/utils/utils.pxd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cdef void* allocate_mem(size_t size, char* var_name) noexcept nogil

cdef void* reallocate_mem(void* old_pointer, size_t new_size, char* var_name) noexcept nogil

cdef void free_mem(void* pointer) noexcept nogil
5 changes: 4 additions & 1 deletion CyRK/utils/utils.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# distutils: language = c
# cython: boundscheck=False, wraparound=False, nonecheck=False, cdivision=True, initializedcheck=False
from libc.stdlib cimport malloc, realloc, exit
from libc.stdlib cimport malloc, realloc, free, exit
from libc.stdio cimport printf


Expand All @@ -18,3 +18,6 @@ cdef inline void* reallocate_mem(void* old_pointer, size_t new_size, char* var_n
printf('Failed to *re*allocate memory for %s \n\tRequested size = %d.', var_name, new_size)
exit(-1)
return new_memory

cdef inline void free_mem(void* pointer) noexcept nogil:
free(pointer)

0 comments on commit 1960d51

Please sign in to comment.