prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Need binding to void GENERAL_NAMES_free(GENERAL_NAMES *)
  the function call to d2i methods on the altSubjectName extension returned a dynamicly allocated memory object that must be garbage collected so  binding for GENERAL_NAMES_free should be exposed from hazmat so that higher level code can avoid memory leaks. Not sure which module should expose the binding but I used x509v3.py module in the Proposed solution https://github.com/crc32a/cryptography/commit/24df02646de1e5c1773c9048076b5d67d4c5c0fa
  
  this effects issue https://github.com/pyca/pyopenssl/issues/139 of pyopenssl and an example of its usage to avoid memory leaks is
  https://github.com/rackerlabs/pyopenssl/commit/a479a74820619da13dfab8925cf49c4f766b6536
  
  
  </issue>
  <code>
  [start of cryptography/hazmat/bindings/openssl/x509v3.py]
  1 # Licensed under the Apache License, Version 2.0 (the "License");
  2 # you may not use this file except in compliance with the License.
  3 # You may obtain a copy of the License at
  4 #
  5 #    http://www.apache.org/licenses/LICENSE-2.0
  6 #
  7 # Unless required by applicable law or agreed to in writing, software
  8 # distributed under the License is distributed on an "AS IS" BASIS,
  9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10 # implied.
  11 # See the License for the specific language governing permissions and
  12 # limitations under the License.
  13 
  14 from __future__ import absolute_import, division, print_function
  15 
  16 INCLUDES = """
  17 #include <openssl/x509v3.h>
  18 """
  19 
  20 TYPES = """
  21 typedef struct {
  22     X509 *issuer_cert;
  23     X509 *subject_cert;
  24     ...;
  25 } X509V3_CTX;
  26 
  27 typedef void * (*X509V3_EXT_D2I)(void *, const unsigned char **, long);
  28 
  29 typedef struct {
  30     ASN1_ITEM_EXP *it;
  31     X509V3_EXT_D2I d2i;
  32     ...;
  33 } X509V3_EXT_METHOD;
  34 
  35 static const int GEN_OTHERNAME;
  36 static const int GEN_EMAIL;
  37 static const int GEN_X400;
  38 static const int GEN_DNS;
  39 static const int GEN_URI;
  40 static const int GEN_DIRNAME;
  41 static const int GEN_EDIPARTY;
  42 static const int GEN_IPADD;
  43 static const int GEN_RID;
  44 
  45 typedef struct {
  46     ...;
  47 } OTHERNAME;
  48 
  49 typedef struct {
  50     ...;
  51 } EDIPARTYNAME;
  52 
  53 typedef struct {
  54     int type;
  55     union {
  56         char *ptr;
  57         OTHERNAME *otherName;  /* otherName */
  58         ASN1_IA5STRING *rfc822Name;
  59         ASN1_IA5STRING *dNSName;
  60         ASN1_TYPE *x400Address;
  61         X509_NAME *directoryName;
  62         EDIPARTYNAME *ediPartyName;
  63         ASN1_IA5STRING *uniformResourceIdentifier;
  64         ASN1_OCTET_STRING *iPAddress;
  65         ASN1_OBJECT *registeredID;
  66 
  67         /* Old names */
  68         ASN1_OCTET_STRING *ip; /* iPAddress */
  69         X509_NAME *dirn;       /* dirn */
  70         ASN1_IA5STRING *ia5;   /* rfc822Name, dNSName, */
  71                                /*   uniformResourceIdentifier */
  72         ASN1_OBJECT *rid;      /* registeredID */
  73         ASN1_TYPE *other;      /* x400Address */
  74     } d;
  75     ...;
  76 } GENERAL_NAME;
  77 
  78 typedef struct stack_st_GENERAL_NAME GENERAL_NAMES;
  79 """
  80 
  81 FUNCTIONS = """
  82 void X509V3_set_ctx(X509V3_CTX *, X509 *, X509 *, X509_REQ *, X509_CRL *, int);
  83 X509_EXTENSION *X509V3_EXT_nconf(CONF *, X509V3_CTX *, char *, char *);
  84 int GENERAL_NAME_print(BIO *, GENERAL_NAME *);
  85 """
  86 
  87 MACROS = """
  88 void *X509V3_set_ctx_nodb(X509V3_CTX *);
  89 int sk_GENERAL_NAME_num(struct stack_st_GENERAL_NAME *);
  90 int sk_GENERAL_NAME_push(struct stack_st_GENERAL_NAME *, GENERAL_NAME *);
  91 GENERAL_NAME *sk_GENERAL_NAME_value(struct stack_st_GENERAL_NAME *, int);
  92 
  93 /* These aren't macros these functions are all const X on openssl > 1.0.x */
  94 const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *);
  95 const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int);
  96 """
  97 
  98 CUSTOMIZATIONS = """
  99 """
  100 
  101 CONDITIONAL_NAMES = {}
  102
  [end of cryptography/hazmat/bindings/openssl/x509v3.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/cryptography/hazmat/bindings/openssl/x509v3.py b/cryptography/hazmat/bindings/openssl/x509v3.py
  --- a/cryptography/hazmat/bindings/openssl/x509v3.py
  +++ b/cryptography/hazmat/bindings/openssl/x509v3.py
  @@ -82,6 +82,7 @@
   void X509V3_set_ctx(X509V3_CTX *, X509 *, X509 *, X509_REQ *, X509_CRL *, int);
   X509_EXTENSION *X509V3_EXT_nconf(CONF *, X509V3_CTX *, char *, char *);
   int GENERAL_NAME_print(BIO *, GENERAL_NAME *);
  +void GENERAL_NAMES_free(GENERAL_NAMES *);
   """
   
   MACROS = """
  
verification_info: {"golden_diff": "diff --git a/cryptography/hazmat/bindings/openssl/x509v3.py b/cryptography/hazmat/bindings/openssl/x509v3.py\n--- a/cryptography/hazmat/bindings/openssl/x509v3.py\n+++ b/cryptography/hazmat/bindings/openssl/x509v3.py\n@@ -82,6 +82,7 @@\n void X509V3_set_ctx(X509V3_CTX *, X509 *, X509 *, X509_REQ *, X509_CRL *, int);\n X509_EXTENSION *X509V3_EXT_nconf(CONF *, X509V3_CTX *, char *, char *);\n int GENERAL_NAME_print(BIO *, GENERAL_NAME *);\n+void GENERAL_NAMES_free(GENERAL_NAMES *);\n \"\"\"\n \n MACROS = \"\"\"\n", "issue": "Need binding to void GENERAL_NAMES_free(GENERAL_NAMES *)\nthe function call to d2i methods on the altSubjectName extension returned a dynamicly allocated memory object that must be garbage collected so  binding for GENERAL_NAMES_free should be exposed from hazmat so that higher level code can avoid memory leaks. Not sure which module should expose the binding but I used x509v3.py module in the Proposed solution https://github.com/crc32a/cryptography/commit/24df02646de1e5c1773c9048076b5d67d4c5c0fa\n\nthis effects issue https://github.com/pyca/pyopenssl/issues/139 of pyopenssl and an example of its usage to avoid memory leaks is\nhttps://github.com/rackerlabs/pyopenssl/commit/a479a74820619da13dfab8925cf49c4f766b6536\n\n", "before_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n# implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom __future__ import absolute_import, division, print_function\n\nINCLUDES = \"\"\"\n#include <openssl/x509v3.h>\n\"\"\"\n\nTYPES = \"\"\"\ntypedef struct {\n    X509 *issuer_cert;\n    X509 *subject_cert;\n    ...;\n} X509V3_CTX;\n\ntypedef void * (*X509V3_EXT_D2I)(void *, const unsigned char **, long);\n\ntypedef struct {\n    ASN1_ITEM_EXP *it;\n    X509V3_EXT_D2I d2i;\n    ...;\n} X509V3_EXT_METHOD;\n\nstatic const int GEN_OTHERNAME;\nstatic const int GEN_EMAIL;\nstatic const int GEN_X400;\nstatic const int GEN_DNS;\nstatic const int GEN_URI;\nstatic const int GEN_DIRNAME;\nstatic const int GEN_EDIPARTY;\nstatic const int GEN_IPADD;\nstatic const int GEN_RID;\n\ntypedef struct {\n    ...;\n} OTHERNAME;\n\ntypedef struct {\n    ...;\n} EDIPARTYNAME;\n\ntypedef struct {\n    int type;\n    union {\n        char *ptr;\n        OTHERNAME *otherName;  /* otherName */\n        ASN1_IA5STRING *rfc822Name;\n        ASN1_IA5STRING *dNSName;\n        ASN1_TYPE *x400Address;\n        X509_NAME *directoryName;\n        EDIPARTYNAME *ediPartyName;\n        ASN1_IA5STRING *uniformResourceIdentifier;\n        ASN1_OCTET_STRING *iPAddress;\n        ASN1_OBJECT *registeredID;\n\n        /* Old names */\n        ASN1_OCTET_STRING *ip; /* iPAddress */\n        X509_NAME *dirn;       /* dirn */\n        ASN1_IA5STRING *ia5;   /* rfc822Name, dNSName, */\n                               /*   uniformResourceIdentifier */\n        ASN1_OBJECT *rid;      /* registeredID */\n        ASN1_TYPE *other;      /* x400Address */\n    } d;\n    ...;\n} GENERAL_NAME;\n\ntypedef struct stack_st_GENERAL_NAME GENERAL_NAMES;\n\"\"\"\n\nFUNCTIONS = \"\"\"\nvoid X509V3_set_ctx(X509V3_CTX *, X509 *, X509 *, X509_REQ *, X509_CRL *, int);\nX509_EXTENSION *X509V3_EXT_nconf(CONF *, X509V3_CTX *, char *, char *);\nint GENERAL_NAME_print(BIO *, GENERAL_NAME *);\n\"\"\"\n\nMACROS = \"\"\"\nvoid *X509V3_set_ctx_nodb(X509V3_CTX *);\nint sk_GENERAL_NAME_num(struct stack_st_GENERAL_NAME *);\nint sk_GENERAL_NAME_push(struct stack_st_GENERAL_NAME *, GENERAL_NAME *);\nGENERAL_NAME *sk_GENERAL_NAME_value(struct stack_st_GENERAL_NAME *, int);\n\n/* These aren't macros these functions are all const X on openssl > 1.0.x */\nconst X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *);\nconst X509V3_EXT_METHOD *X509V3_EXT_get_nid(int);\n\"\"\"\n\nCUSTOMIZATIONS = \"\"\"\n\"\"\"\n\nCONDITIONAL_NAMES = {}\n", "path": "cryptography/hazmat/bindings/openssl/x509v3.py"}]}