chiark / gitweb /
Merge remote-tracking branch 'origin/HEAD'
[catacomb-python] / bytestring.c
index 6dc70f759fca205df6355cc58067c00e6fd6d076..2b74648d91d9ca2793f206ba4091e941123465f1 100644 (file)
@@ -73,6 +73,17 @@ end:
   return (0);
 }
 
+static PyObject *meth__ByteString_zero(PyObject *me, PyObject *arg)
+{
+  size_t sz;
+  PyObject *rc = 0;
+  if (!PyArg_ParseTuple(arg, "OO&:zero", &me, convszt, &sz)) goto end;
+  rc = bytestring_pywrap(0, sz);
+  memset(PyString_AS_STRING(rc), 0, sz);
+end:
+  return (rc);
+}
+
 static PyObject *bytestring_pyrichcompare(PyObject *me,
                                          PyObject *you, int op)
 {
@@ -228,6 +239,7 @@ static PyTypeObject bytestring_pytype_skel = {
 static PyMethodDef methods[] = {
 #define METHNAME(func) meth_##func
   METH  (ctstreq,              "ctstreq(S, T) -> BOOL")
+  METH (_ByteString_zero,      "zero(N) -> 0000...00")
 #undef METHNAME
   { 0 }
 };