- DA_ENSURE(&global_pymethods, n);
- memcpy(DA(&global_pymethods) + DA_LEN(&global_pymethods),
- m, n * sizeof(*m));
- DA_EXTEND(&global_pymethods, n);
+ want = nmethods + n + 1;
+ if (want > methodsz) {
+ newsz = methodsz ? 2*methodsz : 16;
+ while (want > newsz) newsz *= 2;
+ if (!global_methods)
+ global_methods = PyObject_Malloc(newsz*sizeof(PyMethodDef));
+ else
+ global_methods = PyObject_Realloc(global_methods,
+ newsz*sizeof(PyMethodDef));
+ assert(global_methods);
+ methodsz = newsz;
+ }
+ memcpy(global_methods + nmethods, m, n*sizeof(PyMethodDef));
+ nmethods += n;
+ global_methods[nmethods].ml_name = 0;