diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2011-01-09 13:30:34 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2011-01-09 13:30:34 +0000 |
commit | e650f9988b19af974080637dfeff63b4e9b15794 (patch) | |
tree | 0af76a86f916cb2aa4885ce523987a74d5ba8957 | |
parent | 8ed84541154868a8ab0d742a76475659972e8fe6 (diff) |
move some string utilities to buf_str.c to reduce some dependencies (from 0.9.8 branch).
-rw-r--r-- | crypto/buffer/Makefile | 4 | ||||
-rw-r--r-- | crypto/buffer/buffer.c | 58 |
2 files changed, 2 insertions, 60 deletions
diff --git a/crypto/buffer/Makefile b/crypto/buffer/Makefile index 9f3a88d2d6..d0e0d5f896 100644 --- a/crypto/buffer/Makefile +++ b/crypto/buffer/Makefile @@ -17,8 +17,8 @@ TEST= APPS= LIB=$(TOP)/libcrypto.a -LIBSRC= buffer.c buf_err.c -LIBOBJ= buffer.o buf_err.o +LIBSRC= buffer.c buf_str.c buf_err.c +LIBOBJ= buffer.o buf_str.o buf_err.o SRC= $(LIBSRC) diff --git a/crypto/buffer/buffer.c b/crypto/buffer/buffer.c index 620ea8d536..f4b358bbbd 100644 --- a/crypto/buffer/buffer.c +++ b/crypto/buffer/buffer.c @@ -162,64 +162,6 @@ int BUF_MEM_grow_clean(BUF_MEM *str, size_t len) return(len); } -char *BUF_strdup(const char *str) - { - if (str == NULL) return(NULL); - return BUF_strndup(str, strlen(str)); - } - -char *BUF_strndup(const char *str, size_t siz) - { - char *ret; - - if (str == NULL) return(NULL); - - ret=OPENSSL_malloc(siz+1); - if (ret == NULL) - { - BUFerr(BUF_F_BUF_STRNDUP,ERR_R_MALLOC_FAILURE); - return(NULL); - } - BUF_strlcpy(ret,str,siz+1); - return(ret); - } - -void *BUF_memdup(const void *data, size_t siz) - { - void *ret; - - if (data == NULL) return(NULL); - - ret=OPENSSL_malloc(siz); - if (ret == NULL) - { - BUFerr(BUF_F_BUF_MEMDUP,ERR_R_MALLOC_FAILURE); - return(NULL); - } - return memcpy(ret, data, siz); - } - -size_t BUF_strlcpy(char *dst, const char *src, size_t size) - { - size_t l = 0; - for(; size > 1 && *src; size--) - { - *dst++ = *src++; - l++; - } - if (size) - *dst = '\0'; - return l + strlen(src); - } - -size_t BUF_strlcat(char *dst, const char *src, size_t size) - { - size_t l = 0; - for(; size > 0 && *dst; size--, dst++) - l++; - return l + BUF_strlcpy(dst, src, size); - } - void BUF_reverse(unsigned char *out, unsigned char *in, size_t size) { size_t i; |