MCPcopy Create free account
hub / github.com/numpy/numpy / PyArrayIdentityHash_New

Function PyArrayIdentityHash_New

numpy/core/src/common/npy_hashtable.c:89–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88
89NPY_NO_EXPORT PyArrayIdentityHash *
90PyArrayIdentityHash_New(int key_len)
91{
92 PyArrayIdentityHash *res = PyMem_Malloc(sizeof(PyArrayIdentityHash));
93 if (res == NULL) {
94 PyErr_NoMemory();
95 return NULL;
96 }
97
98 assert(key_len > 0);
99 res->key_len = key_len;
100 res->size = 4; /* Start with a size of 4 */
101 res->nelem = 0;
102
103 res->buckets = PyMem_Calloc(4 * (key_len + 1), sizeof(PyObject *));
104 if (res->buckets == NULL) {
105 PyErr_NoMemory();
106 PyMem_Free(res);
107 return NULL;
108 }
109 return res;
110}
111
112
113NPY_NO_EXPORT void

Calls

no outgoing calls

Tested by

no test coverage detected