From 445470d831c125a9fb8af52eeffd9d760fc0862c Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 16 Feb 2017 10:32:17 +0100 Subject: [PATCH] Rename a gldns function --- src/context.c | 4 ++-- src/convert.c | 8 ++++---- src/dict.c | 8 ++++---- src/gldns/gbuffer.c | 2 +- src/gldns/gbuffer.h | 10 ++++++---- src/request-internal.c | 2 +- src/util-internal.c | 4 ++-- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/context.c b/src/context.c index 88eb0e4d..14c78a09 100644 --- a/src/context.c +++ b/src/context.c @@ -1354,7 +1354,7 @@ getdns_context_create_with_extended_memory_functions( result->suffixes = no_suffixes; result->suffixes_len = sizeof(no_suffixes); - gldns_buffer_init_frm_data_v(&gbuf, result->trust_anchors_spc + gldns_buffer_init_vfixed_frm_data(&gbuf, result->trust_anchors_spc , sizeof(result->trust_anchors_spc)); if (!_getdns_parse_ta_file(NULL, &gbuf)) { @@ -2333,7 +2333,7 @@ getdns_context_set_suffix(getdns_context *context, getdns_list *value) context->suffixes_len = sizeof(no_suffixes); return GETDNS_RETURN_GOOD; } - gldns_buffer_init_frm_data_v(&gbuf, buf_spc, sizeof(buf_spc)); + gldns_buffer_init_vfixed_frm_data(&gbuf, buf_spc, sizeof(buf_spc)); for (;;) { for ( i = 0 ; !(r = getdns_list_get_bindata(value, i, &bindata)) diff --git a/src/convert.c b/src/convert.c index df2ff0e5..11919107 100644 --- a/src/convert.c +++ b/src/convert.c @@ -297,7 +297,7 @@ getdns_rr_dict2wire_scan( return GETDNS_RETURN_INVALID_PARAMETER; - gldns_buffer_init_frm_data_v(&gbuf, *wire, *wire_sz); + gldns_buffer_init_vfixed_frm_data(&gbuf, *wire, *wire_sz); if ((r = _getdns_rr_dict2wire(rr_dict, &gbuf))) return r; @@ -447,7 +447,7 @@ getdns_rr_dict2str_scan( if (!rr_dict || !str || !*str || !str_len) return GETDNS_RETURN_INVALID_PARAMETER; - gldns_buffer_init_frm_data_v(&gbuf, buf, sizeof(buf_spc)); + gldns_buffer_init_vfixed_frm_data(&gbuf, buf, sizeof(buf_spc)); r = _getdns_rr_dict2wire(rr_dict, &gbuf); if (gldns_buffer_position(&gbuf) > sizeof(buf_spc)) { if (!(buf = GETDNS_XMALLOC( @@ -960,7 +960,7 @@ getdns_msg_dict2wire_scan( if (!msg_dict || !wire || !wire_sz || (!*wire && *wire_sz)) return GETDNS_RETURN_INVALID_PARAMETER; - gldns_buffer_init_frm_data_v(&gbuf, *wire, *wire_sz); + gldns_buffer_init_vfixed_frm_data(&gbuf, *wire, *wire_sz); if ((r = _getdns_msg_dict2wire_buf(msg_dict, &gbuf))) return r; @@ -1036,7 +1036,7 @@ getdns_msg_dict2str_scan( if (!msg_dict || !str || !*str || !str_len) return GETDNS_RETURN_INVALID_PARAMETER; - gldns_buffer_init_frm_data_v(&gbuf, buf, sizeof(buf_spc)); + gldns_buffer_init_vfixed_frm_data(&gbuf, buf, sizeof(buf_spc)); r = _getdns_msg_dict2wire_buf(msg_dict, &gbuf); if (gldns_buffer_position(&gbuf) > sizeof(buf_spc)) { if (!(buf = GETDNS_XMALLOC( diff --git a/src/dict.c b/src/dict.c index 70fa3836..23b42531 100644 --- a/src/dict.c +++ b/src/dict.c @@ -1186,7 +1186,7 @@ getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict) if (!dict) return -1; - gldns_buffer_init_frm_data_v(&buf, str, size); + gldns_buffer_init_vfixed_frm_data(&buf, str, size); return getdns_pp_dict(&buf, 0, dict, 0) < 0 ? -1 : (int)gldns_buffer_position(&buf); } @@ -1220,7 +1220,7 @@ getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list) if (!list) return -1; - gldns_buffer_init_frm_data_v(&buf, str, size); + gldns_buffer_init_vfixed_frm_data(&buf, str, size); return getdns_pp_list(&buf, 0, list, 0, 0) < 0 ? -1 : (int)gldns_buffer_position(&buf); } @@ -1255,7 +1255,7 @@ getdns_snprint_json_dict( if (!dict) return -1; - gldns_buffer_init_frm_data_v(&buf, str, size); + gldns_buffer_init_vfixed_frm_data(&buf, str, size); return getdns_pp_dict(&buf, 0, dict, pretty ? 1 : 2) < 0 ? -1 : (int)gldns_buffer_position(&buf); } @@ -1290,7 +1290,7 @@ getdns_snprint_json_list( if (!list) return -1; - gldns_buffer_init_frm_data_v(&buf, str, size); + gldns_buffer_init_vfixed_frm_data(&buf, str, size); return getdns_pp_list(&buf, 0, list, 0, pretty ? 1 : 2) < 0 ? -1 : (int)gldns_buffer_position(&buf); } diff --git a/src/gldns/gbuffer.c b/src/gldns/gbuffer.c index 77398905..04c257fb 100644 --- a/src/gldns/gbuffer.c +++ b/src/gldns/gbuffer.c @@ -72,7 +72,7 @@ gldns_buffer_init_frm_data(gldns_buffer *buffer, void *data, size_t size) } void -gldns_buffer_init_frm_data_v(gldns_buffer *buffer, void *data, size_t size) +gldns_buffer_init_vfixed_frm_data(gldns_buffer *buffer, void *data, size_t size) { memset(buffer, 0, sizeof(*buffer)); buffer->_data = data; diff --git a/src/gldns/gbuffer.h b/src/gldns/gbuffer.h index 15dca675..1b1eb498 100644 --- a/src/gldns/gbuffer.h +++ b/src/gldns/gbuffer.h @@ -194,14 +194,16 @@ void gldns_buffer_init_frm_data(gldns_buffer *buffer, void *data, size_t size); /** * Setup a buffer with the data pointed to. No data copied, no memory allocs. - * The buffer is fixed. Writes beyond size (the capacity) will update the - * position (and not write data). This allows to determine how big the buffer - * should have been to contain all the written data. + * The buffer is "virtually" fixed. Writes beyond size (the capacity) will + * only update position, but no data will be written beyond capacity. This + * allows to determine how big the buffer should have been to contain all the + * written data, by looking at the position with gldns_buffer_position(), + * similarly to the return value of POSIX's snprintf. * \param[in] buffer pointer to the buffer to put the data in * \param[in] data the data to encapsulate in the buffer * \param[in] size the size of the data */ -void gldns_buffer_init_frm_data_v(gldns_buffer *buffer, void *data, size_t size); +void gldns_buffer_init_vfixed_frm_data(gldns_buffer *buffer, void *data, size_t size); /** * clears the buffer and make it ready for writing. The buffer's limit diff --git a/src/request-internal.c b/src/request-internal.c index 7b8af65a..8193acb7 100644 --- a/src/request-internal.c +++ b/src/request-internal.c @@ -383,7 +383,7 @@ _getdns_network_req_add_tsig(getdns_network_req *req) #endif tsig_info = _getdns_get_tsig_info(upstream->tsig_alg); - gldns_buffer_init_frm_data_v(&gbuf, req->response, MAXIMUM_TSIG_SPACE); + gldns_buffer_init_vfixed_frm_data(&gbuf, req->response, MAXIMUM_TSIG_SPACE); gldns_buffer_write(&gbuf, upstream->tsig_dname, upstream->tsig_dname_len); /* Name */ gldns_buffer_write_u16(&gbuf, GETDNS_RRCLASS_ANY); /* Class */ diff --git a/src/util-internal.c b/src/util-internal.c index 2bbad80d..fe05cd83 100644 --- a/src/util-internal.c +++ b/src/util-internal.c @@ -1510,7 +1510,7 @@ uint8_t *_getdns_list2wire( gldns_buffer gbuf; size_t sz; - gldns_buffer_init_frm_data_v(&gbuf, buf, *buf_len); + gldns_buffer_init_vfixed_frm_data(&gbuf, buf, *buf_len); _getdns_list2wire_buf(&gbuf, l); if ((sz = gldns_buffer_position(&gbuf)) <= *buf_len) { @@ -1531,7 +1531,7 @@ uint8_t *_getdns_reply2wire( gldns_buffer gbuf; size_t sz; - gldns_buffer_init_frm_data_v(&gbuf, buf, *buf_len); + gldns_buffer_init_vfixed_frm_data(&gbuf, buf, *buf_len); _getdns_reply2wire_buf(&gbuf, r); if ((sz = gldns_buffer_position(&gbuf)) <= *buf_len) {