Home | History | Annotate | Download | only in buf

Lines Matching refs:BUF

57 #include <openssl/buf.h>
70 OPENSSL_PUT_ERROR(BUF, BUF_MEM_new, ERR_R_MALLOC_FAILURE);
78 void BUF_MEM_free(BUF_MEM *buf) {
79 if (buf == NULL) {
83 if (buf->data != NULL) {
84 OPENSSL_cleanse(buf->data, buf->max);
85 OPENSSL_free(buf->data);
88 OPENSSL_free(buf);
91 static size_t buf_mem_grow(BUF_MEM *buf, size_t len, char clean) {
95 if (buf->length >= len) {
96 buf->length = len;
99 if (buf->max >= len) {
100 memset(&buf->data[buf->length], 0, len - buf->length);
101 buf->length = len;
108 OPENSSL_PUT_ERROR(BUF, buf_mem_grow, ERR_R_MALLOC_FAILURE);
115 OPENSSL_PUT_ERROR(BUF, buf_mem_grow, ERR_R_MALLOC_FAILURE);
119 if (buf->data == NULL) {
123 new_buf = OPENSSL_realloc_clean(buf->data, buf->max, alloc_size);
125 new_buf = OPENSSL_realloc(buf->data, alloc_size);
130 OPENSSL_PUT_ERROR(BUF, buf_mem_grow, ERR_R_MALLOC_FAILURE);
133 buf->data = new_buf;
134 buf->max = alloc_size;
135 memset(&buf->data[buf->length], 0, len - buf->length);
136 buf->length = len;
142 size_t BUF_MEM_grow(BUF_MEM *buf, size_t len) {
143 return buf_mem_grow(buf, len, 0 /* don't clear old buffer contents. */);
146 size_t BUF_MEM_grow_clean(BUF_MEM *buf, size_t len) {
147 return buf_mem_grow(buf, len, 1 /* clear old buffer contents. */);
150 char *BUF_strdup(const char *buf) {
151 if (buf == NULL) {
155 return BUF_strndup(buf, strlen(buf));
170 char *BUF_strndup(const char *buf, size_t size) {
174 if (buf == NULL) {
178 size = BUF_strnlen(buf, size);
183 OPENSSL_PUT_ERROR(BUF, BUF_strndup, ERR_R_MALLOC_FAILURE);
188 OPENSSL_PUT_ERROR(BUF, BUF_strndup, ERR_R_MALLOC_FAILURE);
192 memcpy(ret, buf, size);
229 OPENSSL_PUT_ERROR(BUF, BUF_memdup, ERR_R_MALLOC_FAILURE);