Skip to content
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

Simplify dynamic memory allocation/deallocation #16

Merged
merged 2 commits into from
Nov 24, 2018

Conversation

jakirkham
Copy link
Owner

Does a little tidying around memory allocation/deallocation. Namely imports PyMem_Malloc and PyMem_Free into cybuffer.pyx to shorten things a bit. Also inlines use of sizeof into PyMem_Malloc calls. Finally drops unused intermediate variables.

Use a `cimport` to include `PyMem_Malloc` and `PyMem_Free` directly.
Helps shorten expressions where they are used.
Simplify usage of `PyMem_Malloc` by dropping the `sizeof` expression
into the argument. Also drop the now unused `len_nd_b`. Should make it
easier for the C compiler to inline the `sizeof` result; thus,
simplifying the allocation expression.
@jakirkham jakirkham merged commit 4a9e46f into master Nov 24, 2018
@jakirkham jakirkham deleted the simp_dyn_mem_alloc_free branch November 24, 2018 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant