aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl.h
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-08-24 02:08:43 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-08-26 19:32:40 +0900
commitef3b30ddb6cff80c1ead60cb63940e80d0fb9ec5 (patch)
tree51ce13db65e6761108bd8c1d6bcac036b484350c /ext/openssl/ossl.h
parent9e331f2b33b562bb760f5db301d7ab76eb4922a0 (diff)
downloadruby-openssl-ef3b30ddb6cff80c1ead60cb63940e80d0fb9ec5.tar.gz
Avoid unnecessary memory allocation in string2hex()
Remove string2hex() and replace with newly added ossl_bin2hex(). Since the output hex string is always returned to users as a String, we can avoid the memory allocation by writing directly to the String buffer. This also reduces some lines of code.
Diffstat (limited to 'ext/openssl/ossl.h')
-rw-r--r--ext/openssl/ossl.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
index 0ba64e65..864d0683 100644
--- a/ext/openssl/ossl.h
+++ b/ext/openssl/ossl.h
@@ -97,11 +97,6 @@ extern VALUE eOSSLError;
} while (0)
/*
- * String to HEXString conversion
- */
-int string2hex(const unsigned char *, int, char **, int *);
-
-/*
* Data Conversion
*/
STACK_OF(X509) *ossl_x509_ary2sk0(VALUE);
@@ -118,6 +113,11 @@ do{\
assert(newlen <= len);\
rb_str_set_len((str), newlen);\
}while(0)
+/*
+ * Convert binary string to hex string. The caller is responsible for
+ * ensuring out has (2 * len) bytes of capacity.
+ */
+void ossl_bin2hex(unsigned char *in, char *out, size_t len);
/*
* Our default PEM callback