some const fixes and cleanup
[openssl.git] / crypto / evp / names.c
index 250356c844e6ce30658a1b8ae5dca68d81cd2e97..88c1e780dd7694c325730ef76720868beff338c1 100644 (file)
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include "evp.h"
-#include "objects.h"
-#include "x509.h"
+#include <openssl/evp.h>
+#include <openssl/objects.h>
+#include <openssl/x509.h>
 
-int EVP_add_cipher(EVP_CIPHER *c)
+int EVP_add_cipher(const EVP_CIPHER *c)
        {
        int r;
 
-       r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(char *)c);
+       r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c);
        if (r == 0) return(0);
-       r=OBJ_NAME_add(OBJ_nid2ln(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(char *)c);
+       r=OBJ_NAME_add(OBJ_nid2ln(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(const char *)c);
        return(r);
        }
 
-int EVP_add_digest(EVP_MD *md)
+int EVP_add_digest(const EVP_MD *md)
        {
        int r;
        const char *name;
 
        name=OBJ_nid2sn(md->type);
-       r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(char *)md);
+       r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(const char *)md);
        if (r == 0) return(0);
-       r=OBJ_NAME_add(OBJ_nid2ln(md->type),OBJ_NAME_TYPE_MD_METH,(char *)md);
+       r=OBJ_NAME_add(OBJ_nid2ln(md->type),OBJ_NAME_TYPE_MD_METH,(const char *)md);
        if (r == 0) return(0);
 
        if (md->type != md->pkey_type)
@@ -114,5 +114,10 @@ void EVP_cleanup(void)
        {
        OBJ_NAME_cleanup(OBJ_NAME_TYPE_CIPHER_METH);
        OBJ_NAME_cleanup(OBJ_NAME_TYPE_MD_METH);
+       /* The above calls will only clean out the contents of the name
+          hash table, but not the hash table itself.  The following line
+          does that part.  -- Richard Levitte */
+       OBJ_NAME_cleanup(-1);
+
        EVP_PBE_cleanup();
        }