move some string utilities to buf_str.c to reduce some dependencies (from 0.9.8 branch).
This commit is contained in:
parent
8ed8454115
commit
e650f9988b
2 changed files with 2 additions and 60 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue