]> granicus.if.org Git - python/commitdiff
Make Py_ssize_t-clean.
authorThomas Wouters <thomas@python.org>
Wed, 1 Mar 2006 21:50:07 +0000 (21:50 +0000)
committerThomas Wouters <thomas@python.org>
Wed, 1 Mar 2006 21:50:07 +0000 (21:50 +0000)
Modules/_hashopenssl.c

index 117cc4d4f351723235993f9c9fbc6c94fd497548..8f460e2774a3e4f518acb76f23e27d09b5aa8954 100644 (file)
@@ -11,6 +11,8 @@
  *
  */
 
+#define PY_SSIZE_T_CLEAN
+
 #include "Python.h"
 #include "structmember.h"
 
@@ -166,12 +168,13 @@ static PyObject *
 EVP_update(EVPobject *self, PyObject *args)
 {
     unsigned char *cp;
-    int len;
+    Py_ssize_t len;
 
     if (!PyArg_ParseTuple(args, "s#:update", &cp, &len))
         return NULL;
 
-    EVP_DigestUpdate(&self->ctx, cp, len);
+    EVP_DigestUpdate(&self->ctx, cp, Py_SAFE_DOWNCAST(len, Py_ssize_t,
+                                                      unsigned int));
 
     Py_INCREF(Py_None);
     return Py_None;
@@ -238,7 +241,7 @@ EVP_tp_init(EVPobject *self, PyObject *args, PyObject *kwds)
     PyObject *name_obj = NULL;
     char *nameStr;
     unsigned char *cp = NULL;
-    unsigned int len;
+    Py_ssize_t len;
     const EVP_MD *digest;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|s#:HASH", kwlist,
@@ -262,7 +265,8 @@ EVP_tp_init(EVPobject *self, PyObject *args, PyObject *kwds)
     Py_INCREF(self->name);
 
     if (cp && len)
-        EVP_DigestUpdate(&self->ctx, cp, len);
+        EVP_DigestUpdate(&self->ctx, cp, Py_SAFE_DOWNCAST(len, Py_ssize_t,
+                                                          unsigned int));
 
     return 0;
 }
@@ -375,7 +379,7 @@ EVP_new(PyObject *self, PyObject *args, PyObject *kwdict)
     char *name;
     const EVP_MD *digest;
     unsigned char *cp = NULL;
-    unsigned int len;
+    Py_ssize_t len;
 
     if (!PyArg_ParseTupleAndKeywords(args, kwdict, "O|s#:new", kwlist,
                                      &name_obj, &cp, &len)) {
@@ -389,7 +393,8 @@ EVP_new(PyObject *self, PyObject *args, PyObject *kwdict)
 
     digest = EVP_get_digestbyname(name);
 
-    return EVPnew(name_obj, digest, NULL, cp, len);
+    return EVPnew(name_obj, digest, NULL, cp, Py_SAFE_DOWNCAST(len, Py_ssize_t,
+                                                               unsigned int));
 }
 
 /*
@@ -404,7 +409,7 @@ EVP_new(PyObject *self, PyObject *args, PyObject *kwdict)
     EVP_new_ ## NAME (PyObject *self, PyObject *args) \
     { \
         unsigned char *cp = NULL; \
-        unsigned int len; \
+        Py_ssize_t len; \
      \
         if (!PyArg_ParseTuple(args, "|s#:" #NAME , &cp, &len)) { \
             return NULL; \
@@ -414,7 +419,7 @@ EVP_new(PyObject *self, PyObject *args, PyObject *kwdict)
                 CONST_ ## NAME ## _name_obj, \
                 NULL, \
                 CONST_new_ ## NAME ## _ctx_p, \
-                cp, len); \
+                cp, Py_SAFE_DOWNCAST(len, Py_ssize_t, unsigned int)); \
     }
 
 /* a PyMethodDef structure for the constructor */