10000 WIP, MAINT: simplify generic type memory handling by tylerjereddy · Pull Request #11836 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

WIP, MAINT: simplify generic type memory handling #11836

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

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions numpy/core/src/multiarray/scalartypes.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,7 @@ NPY_NO_EXPORT PyTypeObject Py@NAME@ArrType_Type = {
static PyObject *
gentype_alloc(PyTypeObject *type, Py_ssize_t nitems)
{
PyObject *obj;
const size_t size = _PyObject_VAR_SIZE(type, nitems + 1);

obj = (PyObject *)PyObject_Malloc(size);
/*
* Fixme. Need to check for no memory.
* If we don't need to zero memory, we could use
* PyObject_{New, NewVar} for this whole function.
*/
memset(obj, 0, size);
if (type->tp_itemsize == 0) {
PyObject_Init(obj, type);
}
else {
(void) PyObject_InitVar((PyVarObject *)obj, type, nitems);
}
return obj;
return (PyTypeObject *) PyObject_NewVar(PyTypeObject *, type, nitems);
}

static void
Expand Down
0