aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/charsets.c30
-rw-r--r--epan/dfilter/dfunctions.c2
-rw-r--r--epan/dissectors/asn1/rrc/rrc.cnf12
-rw-r--r--epan/dissectors/asn1/x509if/x509if.cnf2
-rw-r--r--epan/dissectors/packet-9p.c12
-rw-r--r--epan/dissectors/packet-afs.c2
-rw-r--r--epan/dissectors/packet-awdl.c4
-rw-r--r--epan/dissectors/packet-cimd.c2
-rw-r--r--epan/dissectors/packet-coap.c4
-rw-r--r--epan/dissectors/packet-erldp.c2
-rw-r--r--epan/dissectors/packet-frame.c2
-rw-r--r--epan/dissectors/packet-gsm_a_rr.c2
-rw-r--r--epan/dissectors/packet-isup.c10
-rw-r--r--epan/dissectors/packet-json.c2
-rw-r--r--epan/dissectors/packet-nwp.c7
-rw-r--r--epan/dissectors/packet-opa-mad.c4
-rw-r--r--epan/dissectors/packet-protobuf.c2
-rw-r--r--epan/dissectors/packet-radius.c2
-rw-r--r--epan/dissectors/packet-rrc.c12
-rw-r--r--epan/dissectors/packet-sita.c2
-rw-r--r--epan/dissectors/packet-skinny.c2
-rw-r--r--epan/dissectors/packet-tds.c2
-rw-r--r--epan/dissectors/packet-tr.c3
-rw-r--r--epan/dissectors/packet-waveagent.c2
-rw-r--r--epan/dissectors/packet-x11.c2
-rw-r--r--epan/dissectors/packet-x509if.c2
-rw-r--r--epan/dissectors/packet-xip.c3
-rw-r--r--epan/proto.c2
-rw-r--r--epan/to_str.c8
-rw-r--r--epan/tvbuff.c2
-rw-r--r--wsutil/str_util.c6
-rw-r--r--wsutil/wmem/wmem_strbuf.c50
-rw-r--r--wsutil/wmem/wmem_strbuf.h4
-rw-r--r--wsutil/wmem/wmem_test.c30
34 files changed, 90 insertions, 145 deletions
diff --git a/epan/charsets.c b/epan/charsets.c
index 0d84dbd147..aaeb0e4585 100644
--- a/epan/charsets.c
+++ b/epan/charsets.c
@@ -73,7 +73,7 @@ get_ascii_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
{
wmem_strbuf_t *str;
- str = wmem_strbuf_sized_new(scope, length+1, 0);
+ str = wmem_strbuf_new_sized(scope, length+1);
while (length > 0) {
guint8 ch = *ptr;
@@ -111,7 +111,7 @@ get_utf_8_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
guint8 ch;
const guint8 *prev;
- str = wmem_strbuf_sized_new(scope, length+1, 0);
+ str = wmem_strbuf_new_sized(scope, length+1);
/* See the Unicode Standard conformance chapter at
* https://www.unicode.org/versions/Unicode13.0.0/ch03.pdf especially
@@ -253,7 +253,7 @@ get_iso_646_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, cons
{
wmem_strbuf_t *str;
- str = wmem_strbuf_sized_new(scope, length+1, 0);
+ str = wmem_strbuf_new_sized(scope, length+1);
while (length > 0) {
guint8 ch = *ptr;
@@ -279,7 +279,7 @@ get_8859_1_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
{
wmem_strbuf_t *str;
- str = wmem_strbuf_sized_new(scope, length+1, 0);
+ str = wmem_strbuf_new_sized(scope, length+1);
while (length > 0) {
guint8 ch = *ptr;
@@ -779,7 +779,7 @@ get_unichar2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, con
{
wmem_strbuf_t *str;
- str = wmem_strbuf_sized_new(scope, length+1, 0);
+ str = wmem_strbuf_new_sized(scope, length+1);
while (length > 0) {
guint8 ch = *ptr;
@@ -813,7 +813,7 @@ get_ucs_2_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const
gint i; /* Byte counter for string */
wmem_strbuf_t *strbuf;
- strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
+ strbuf = wmem_strbuf_new_sized(scope, length+1);
for(i = 0; i + 1 < length; i += 2) {
if (encoding == ENC_BIG_ENDIAN){
@@ -853,7 +853,7 @@ get_utf_16_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const
gunichar uchar;
gint i; /* Byte counter for string */
- strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
+ strbuf = wmem_strbuf_new_sized(scope, length+1);
for(i = 0; i + 1 < length; i += 2) {
if (encoding == ENC_BIG_ENDIAN)
@@ -940,7 +940,7 @@ get_ucs_4_string(wmem_allocator_t *scope, const guint8 *ptr, gint length, const
gint i; /* Byte counter for string */
wmem_strbuf_t *strbuf;
- strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
+ strbuf = wmem_strbuf_new_sized(scope, length+1);
for(i = 0; i + 3 < length; i += 4) {
if (encoding == ENC_BIG_ENDIAN)
@@ -1073,7 +1073,7 @@ get_ts_23_038_7bits_string_packed(wmem_allocator_t *scope, const guint8 *ptr,
gboolean saw_escape = FALSE;
int bits;
- strbuf = wmem_strbuf_sized_new(scope, no_of_chars+1, 0);
+ strbuf = wmem_strbuf_new_sized(scope, no_of_chars+1);
bits = bit_offset & 0x07;
if (!bits) {
@@ -1142,7 +1142,7 @@ get_ts_23_038_7bits_string_unpacked(wmem_allocator_t *scope, const guint8 *ptr,
gint i; /* Byte counter for string */
gboolean saw_escape = FALSE;
- strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
+ strbuf = wmem_strbuf_new_sized(scope, length+1);
for (i = 0; i < length; i++)
saw_escape = handle_ts_23_038_char(strbuf, *ptr++, saw_escape);
@@ -1218,7 +1218,7 @@ get_etsi_ts_102_221_annex_a_string(wmem_allocator_t *scope, const guint8 *ptr,
ptr++;
length--;
- strbuf = wmem_strbuf_sized_new(scope, 2*string_len+1, 0);
+ strbuf = wmem_strbuf_new_sized(scope, 2*string_len+1);
/*
* Get the UCS-2 base.
@@ -1295,7 +1295,7 @@ get_ascii_7bits_string(wmem_allocator_t *scope, const guint8 *ptr,
bits = 7;
}
- strbuf = wmem_strbuf_sized_new(scope, no_of_chars+1, 0);
+ strbuf = wmem_strbuf_new_sized(scope, no_of_chars+1);
for(char_count = 0; char_count < no_of_chars; ptr++) {
/* Get the next byte from the string. */
in_byte = *ptr;
@@ -1428,7 +1428,7 @@ get_nonascii_unichar2_string(wmem_allocator_t *scope, const guint8 *ptr, gint le
{
wmem_strbuf_t *str;
- str = wmem_strbuf_sized_new(scope, length+1, 0);
+ str = wmem_strbuf_new_sized(scope, length+1);
while (length > 0) {
guint8 ch = *ptr;
@@ -1471,7 +1471,7 @@ get_string_enc_iconv(wmem_allocator_t *scope, const guint8 *ptr, gint length, co
}
inbytes = length;
- str = wmem_strbuf_sized_new(scope, length+1, 0);
+ str = wmem_strbuf_new_sized(scope, length+1);
/* XXX: If speed becomes an issue, the faster way to do this would
* involve passing the wmem_strbuf_t's string buffer directly into
* g_iconv to avoid a memcpy later, but that requires changes to the
@@ -1846,7 +1846,7 @@ get_t61_string(wmem_allocator_t *scope, const guint8 *ptr, gint length)
const guint8 *c;
wmem_strbuf_t *strbuf;
- strbuf = wmem_strbuf_sized_new(scope, length+1, 0);
+ strbuf = wmem_strbuf_new_sized(scope, length+1);
for (i = 0, c = ptr; i < length; c++, i++) {
if (!t61_tab[*c]) {
diff --git a/epan/dfilter/dfunctions.c b/epan/dfilter/dfunctions.c
index 1ceaa25df4..aa129c600b 100644
--- a/epan/dfilter/dfunctions.c
+++ b/epan/dfilter/dfunctions.c
@@ -44,7 +44,7 @@ string_walk(GSList *args, guint32 arg_count, GSList **retval, gchar(*conv_func)(
/* XXX - it would be nice to handle FT_TVBUFF, too */
if (IS_FT_STRING(fvalue_type_ftenum(arg_fvalue))) {
src = fvalue_get_strbuf(arg_fvalue);
- dst = wmem_strbuf_sized_new(NULL, src->len, 0);
+ dst = wmem_strbuf_new_sized(NULL, src->len);
for (size_t i = 0; i < src->len; i++) {
wmem_strbuf_append_c(dst, conv_func(src->str[i]));
}
diff --git a/epan/dissectors/asn1/rrc/rrc.cnf b/epan/dissectors/asn1/rrc/rrc.cnf
index 7a8c233a57..381c274cfd 100644
--- a/epan/dissectors/asn1/rrc/rrc.cnf
+++ b/epan/dissectors/asn1/rrc/rrc.cnf
@@ -828,7 +828,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
/* Reset the digits string in the private data struct */
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
- mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
+ mcc_mnc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
/* Reset parsing failure flag*/
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
@@ -846,7 +846,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
if(string_len >= 3)
{
/* 3 MCC digits were found, keep for later in case MCC is missing in other PLMN ids*/
- mcc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,4,4);
+ mcc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,4);
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[0]);
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[1]);
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[2]);
@@ -871,7 +871,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
/* Reset the digits string in the private data struct */
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
- mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
+ mcc_mnc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
/* Reset parsing failure flag*/
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
@@ -888,7 +888,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
if (string_len > 3) {
/* 3 MCC digits and at least 1 MNC digit were found, keep MCC for later
in case it's missing in other PLMN ids*/
- temp_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,4,4);
+ temp_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,4);
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[0]);
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[1]);
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[2]);
@@ -902,7 +902,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
if(last_mcc_strbuf)
{
/* Concat MCC and MNC in temp buffer */
- temp_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
+ temp_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
wmem_strbuf_append_printf(temp_strbuf,"%%s",wmem_strbuf_get_str(last_mcc_strbuf));
wmem_strbuf_append_printf(temp_strbuf,"%%s",mcc_mnc_string);
/* Update length of recovered MCC-MNC pair */
@@ -929,7 +929,7 @@ HandoverFromUTRANCommand-GSM-r6-IEs/gsm-message/single-GSM-Message single-GSM-Me
tvbuff_t* imsi_tvb;
/* Reset the digits string in the private data struct */
- imsi_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,16,16);
+ imsi_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,16);
private_data_set_digits_strbuf(actx, imsi_strbuf);
/* Reset parsing failure flag*/
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
diff --git a/epan/dissectors/asn1/x509if/x509if.cnf b/epan/dissectors/asn1/x509if/x509if.cnf
index 3003c455fb..6a9f654e2f 100644
--- a/epan/dissectors/asn1/x509if/x509if.cnf
+++ b/epan/dissectors/asn1/x509if/x509if.cnf
@@ -341,7 +341,7 @@ DistinguishedName B "2.16.840.1.101.2.2.1.188" "id-at-primaryMember"
/* now append this to the DN */
if (last_dn_buf) {
if(wmem_strbuf_get_len(last_dn_buf) > 0) {
- wmem_strbuf_t *temp_dn_buf = wmem_strbuf_sized_new(actx->pinfo->pool, wmem_strbuf_get_len(last_rdn_buf) + wmem_strbuf_get_len(last_dn_buf) + 1, 0);
+ wmem_strbuf_t *temp_dn_buf = wmem_strbuf_new_sized(actx->pinfo->pool, wmem_strbuf_get_len(last_rdn_buf) + wmem_strbuf_get_len(last_dn_buf) + 1);
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_rdn_buf));
wmem_strbuf_append_c(temp_dn_buf, ',');
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_dn_buf));
diff --git a/epan/dissectors/packet-9p.c b/epan/dissectors/packet-9p.c
index 285e888774..146828d578 100644
--- a/epan/dissectors/packet-9p.c
+++ b/epan/dissectors/packet-9p.c
@@ -304,10 +304,6 @@ enum _9p_qid_t {
#define _9P_NONUNAME (guint32)(~0)
#define _9P_MAXWELEM 16
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
-#endif
-
/**
* @brief Length prefixed string type
@@ -1337,7 +1333,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
fid_path = conv_get_fid(pinfo, fid);
proto_item_append_text(ti, " (%s)", fid_path);
if (!pinfo->fd->visited) {
- tmppath = wmem_strbuf_sized_new(pinfo->pool, 0, MAXPATHLEN);
+ tmppath = wmem_strbuf_create(pinfo->pool);
wmem_strbuf_append(tmppath, fid_path);
}
offset += 4;
@@ -1430,7 +1426,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
if (!pinfo->fd->visited) {
_9p_len = tvb_get_letohs(tvb, offset);
- tmppath = wmem_strbuf_sized_new(pinfo->pool, 0, MAXPATHLEN);
+ tmppath = wmem_strbuf_create(pinfo->pool);
wmem_strbuf_append(tmppath, fid_path);
wmem_strbuf_append_c(tmppath, '/');
tvb_s = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset+2, _9p_len, ENC_UTF_8|ENC_NA);
@@ -1463,7 +1459,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
if (!pinfo->fd->visited) {
_9p_len = tvb_get_letohs(tvb, offset);
- tmppath = wmem_strbuf_sized_new(pinfo->pool, 0, MAXPATHLEN);
+ tmppath = wmem_strbuf_create(pinfo->pool);
wmem_strbuf_append(tmppath, fid_path);
wmem_strbuf_append_c(tmppath, '/');
tvb_s = (char*)tvb_get_string_enc(pinfo->pool, tvb, offset+2, _9p_len, ENC_UTF_8|ENC_NA);
@@ -1808,7 +1804,7 @@ static int dissect_9P_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
if (!pinfo->fd->visited) {
_9p_len = tvb_get_letohs(tvb, offset);
- tmppath = wmem_strbuf_sized_new(pinfo->pool, 0, MAXPATHLEN);
+ tmppath = wmem_strbuf_create(pinfo->pool);
wmem_strbuf_append(tmppath, conv_get_fid(pinfo, dfid));
wmem_strbuf_append_c(tmppath, '/');
diff --git a/epan/dissectors/packet-afs.c b/epan/dissectors/packet-afs.c
index 9e85420c0c..470da703b0 100644
--- a/epan/dissectors/packet-afs.c
+++ b/epan/dissectors/packet-afs.c
@@ -545,7 +545,7 @@ static void OUT_RXString(ptvcursor_t *cursor, int field)
static void OUT_RXStringV(ptvcursor_t *cursor, int field, guint32 length)
{
tvbuff_t* tvb = ptvcursor_tvbuff(cursor);
- wmem_strbuf_t *strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), length+1, 0);
+ wmem_strbuf_t *strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), length+1);
int offset = ptvcursor_current_offset(cursor),
start_offset = offset;
guint32 idx;
diff --git a/epan/dissectors/packet-awdl.c b/epan/dissectors/packet-awdl.c
index 8d6b82b953..2466315acf 100644
--- a/epan/dissectors/packet-awdl.c
+++ b/epan/dissectors/packet-awdl.c
@@ -730,7 +730,7 @@ awdl_tag_channel_sequence(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tre
offset += 2;
/* make sufficient space for channel decodings: 5 chars/channel (3-digit number + ', ') */
- strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), 5 * channels, 5 * channels);
+ strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), 5 * channels);
switch (seq_enc) {
case AWDL_CHANSEQ_ENC_CHANNELNUMBER:
@@ -1139,7 +1139,7 @@ add_awdl_dns_name(proto_tree *tree, int hfindex_regular, int hfindex_compressed,
const guchar *component;
wmem_strbuf_t *strbuf;
- strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), MAX_DNAME_LEN, MAX_DNAME_LEN);
+ strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), MAX_DNAME_LEN);
while (offset < (len + start_offset)) {
component_len = tvb_get_guint8(tvb, offset);
diff --git a/epan/dissectors/packet-cimd.c b/epan/dissectors/packet-cimd.c
index b5b275418e..295bad0dde 100644
--- a/epan/dissectors/packet-cimd.c
+++ b/epan/dissectors/packet-cimd.c
@@ -564,7 +564,7 @@ static void dissect_cimd_ud(tvbuff_t *tvb, proto_tree *tree, gint pindex, gint s
g_size = endOffset - g_offset;
payloadText = tvb_get_ptr(tvb, g_offset, g_size);
- tmpBuffer = wmem_strbuf_sized_new(wmem_packet_scope(), g_size+1, 0);
+ tmpBuffer = wmem_strbuf_new_sized(wmem_packet_scope(), g_size+1);
for (loop = 0; loop < g_size; loop++)
{
if (payloadText[loop] == '_')
diff --git a/epan/dissectors/packet-coap.c b/epan/dissectors/packet-coap.c
index ea49e6d079..364ba37a51 100644
--- a/epan/dissectors/packet-coap.c
+++ b/epan/dissectors/packet-coap.c
@@ -1323,8 +1323,8 @@ dissect_coap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
coinfo->block_option = 0;
coinfo->block_number = DEFAULT_COAP_BLOCK_NUMBER;
coinfo->block_mflag = 0;
- coinfo->uri_str_strbuf = wmem_strbuf_sized_new(pinfo->pool, 0, 1024);
- coinfo->uri_query_strbuf = wmem_strbuf_sized_new(pinfo->pool, 0, 1024);
+ coinfo->uri_str_strbuf = wmem_strbuf_create(pinfo->pool);
+ coinfo->uri_query_strbuf = wmem_strbuf_create(pinfo->pool);
/* Allocate pointers and static elements of oscore_info_t, arrays are allocated only if object security option is found during option parsing */
coinfo->oscore_info = wmem_new0(pinfo->pool, oscore_info_t);
coinfo->object_security = FALSE;
diff --git a/epan/dissectors/packet-erldp.c b/epan/dissectors/packet-erldp.c
index 897218a725..495306e8a5 100644
--- a/epan/dissectors/packet-erldp.c
+++ b/epan/dissectors/packet-erldp.c
@@ -397,7 +397,7 @@ static gint dissect_etf_big_ext(tvbuff_t *tvb, gint offset, guint32 len, proto_t
*value_str = wmem_strdup_printf(wmem_packet_scope(), "%s%" PRIu64,
sign ? "-" : "", big_val);
} if (len < 64) {
- wmem_strbuf_t *strbuf = wmem_strbuf_sized_new(wmem_packet_scope(), len*1+3+1, len*1+3+1);
+ wmem_strbuf_t *strbuf = wmem_strbuf_new_sized(wmem_packet_scope(), len*1+3+1);
wmem_strbuf_append(strbuf, "0x");
for (i = len - 1; i >= 0; i--) {
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index bef9c9da30..0457f19936 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -1159,7 +1159,7 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
ENDTRY;
if (proto_field_is_referenced(tree, hf_frame_protocols)) {
- wmem_strbuf_t *val = wmem_strbuf_sized_new(pinfo->pool, 128, 0);
+ wmem_strbuf_t *val = wmem_strbuf_new_sized(pinfo->pool, 128);
wmem_list_frame_t *frame;
/* skip the first entry, it's always the "frame" protocol */
frame = wmem_list_frame_next(wmem_list_head(pinfo->layers));
diff --git a/epan/dissectors/packet-gsm_a_rr.c b/epan/dissectors/packet-gsm_a_rr.c
index 7859ae4fc6..823f95d1f4 100644
--- a/epan/dissectors/packet-gsm_a_rr.c
+++ b/epan/dissectors/packet-gsm_a_rr.c
@@ -11704,7 +11704,7 @@ dtap_rr_ec_paging_imsi(tvbuff_t *tvb, proto_tree *tree, guint32 curr_bit_offset)
proto_tree_add_bits_ret_val(tree, hf_gsm_a_rr_ec_imsi_digits, tvb, curr_bit_offset, 4, &imsi_digits, ENC_BIG_ENDIAN);
curr_bit_offset += 4;
sav_bit_offset = curr_bit_offset;
- imsi_str = wmem_strbuf_sized_new(wmem_packet_scope(), (gsize)imsi_digits+2, 0);
+ imsi_str = wmem_strbuf_new_sized(wmem_packet_scope(), (gsize)imsi_digits+2);
for (i = 0; i <= (guint8)imsi_digits; i++) {
wmem_strbuf_append_c(imsi_str, digits[tvb_get_bits8(tvb, curr_bit_offset, 4)]);
curr_bit_offset += 4;
diff --git a/epan/dissectors/packet-isup.c b/epan/dissectors/packet-isup.c
index 10dadd9102..023357d204 100644
--- a/epan/dissectors/packet-isup.c
+++ b/epan/dissectors/packet-isup.c
@@ -3440,7 +3440,7 @@ dissect_isup_digits_common(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto
return NULL;
}
- strbuf_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
+ strbuf_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
/* Make the digit string, looping on captured length (in case a snaplen was set) */
captured_length = tvb_captured_length_remaining(tvb, offset);
@@ -7151,7 +7151,7 @@ dissect_japan_isup_network_poi_cad(tvbuff_t *parameter_tvb, packet_info *pinfo,
guint8 carrier_info_length;
gint num_octets_with_digits = 0;
gint digit_index = 0;
- wmem_strbuf_t *ca_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
+ wmem_strbuf_t *ca_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
/* POI Hierarchy information
@@ -7518,7 +7518,7 @@ dissect_japan_isup_carrier_information(tvbuff_t *parameter_tvb, packet_info *pin
/* Lets now load up the digits.*/
/* If the odd indicator is set... drop the Filler from the last octet.*/
/* This loop also loads up ca_number with the digits for display*/
- ca_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
+ ca_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
digit_index = 0;
while (num_octets_with_digits > 0) {
offset += 1;
@@ -7588,7 +7588,7 @@ dissect_japan_isup_carrier_information(tvbuff_t *parameter_tvb, packet_info *pin
/* Lets now load up the digits.*/
/* If the odd indicator is set... drop the Filler from the last octet.*/
/* This loop also loads up cid_number with the digits for display*/
- cid_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
+ cid_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
digit_index = 0;
while (num_octets_with_digits > 0) {
offset += 1;
@@ -7718,7 +7718,7 @@ dissect_japan_isup_charge_area_info(tvbuff_t *parameter_tvb, packet_info *pinfo,
gint odd_even;
gint digit_index = 0;
- wmem_strbuf_t *ca_number = wmem_strbuf_sized_new(pinfo->pool, MAXDIGITS+1, 0);
+ wmem_strbuf_t *ca_number = wmem_strbuf_new_sized(pinfo->pool, MAXDIGITS+1);
/*Octet 1 : Indicator*/
octet = tvb_get_guint8(parameter_tvb, 0);
diff --git a/epan/dissectors/packet-json.c b/epan/dissectors/packet-json.c
index fb4f18257e..aa57ded3d0 100644
--- a/epan/dissectors/packet-json.c
+++ b/epan/dissectors/packet-json.c
@@ -143,7 +143,7 @@ json_string_unescape(wmem_allocator_t *scope, const char *string, size_t *length
size_t read_index = 0;
size_t string_length = strlen(string);
- wmem_strbuf_t* output_string_buffer = wmem_strbuf_sized_new(scope, string_length, 0);
+ wmem_strbuf_t* output_string_buffer = wmem_strbuf_new_sized(scope, string_length);
while (true)
{
diff --git a/epan/dissectors/packet-nwp.c b/epan/dissectors/packet-nwp.c
index cab69535e8..789d8d1f83 100644
--- a/epan/dissectors/packet-nwp.c
+++ b/epan/dissectors/packet-nwp.c
@@ -118,8 +118,7 @@ dissect_nwp_ann(tvbuff_t *tvb, proto_tree *nwp_tree, guint8 hid_count,
NWPH_HWAD + ha_len, hid_count * NWP_XID_LEN, ENC_NA);
hid_tree = proto_item_add_subtree(ti, ett_nwp_ann_hid_tree);
- buf = wmem_strbuf_sized_new(wmem_packet_scope(),
- NWP_HID_STR_LEN, NWP_HID_STR_LEN);
+ buf = wmem_strbuf_new_sized(wmem_packet_scope(), NWP_HID_STR_LEN);
/* Add HIDs. */
offset = NWPH_HWAD + ha_len;
@@ -157,8 +156,8 @@ dissect_nwp_nl(tvbuff_t *tvb, proto_tree *nwp_tree, guint8 hid_count,
guint i;
guint8 offset = NWPH_NLST;
- wmem_strbuf_t *hid_buf = wmem_strbuf_sized_new(wmem_packet_scope(),
- NWP_HID_STR_LEN, NWP_HID_STR_LEN);
+ wmem_strbuf_t *hid_buf = wmem_strbuf_new_sized(wmem_packet_scope(),
+ NWP_HID_STR_LEN);
/* Set up tree for neighbor list. */
pi = proto_tree_add_item(nwp_tree, hf_nwp_neigh_list,
diff --git a/epan/dissectors/packet-opa-mad.c b/epan/dissectors/packet-opa-mad.c
index 2796f175cc..f50275a0f0 100644
--- a/epan/dissectors/packet-opa-mad.c
+++ b/epan/dissectors/packet-opa-mad.c
@@ -2525,7 +2525,7 @@ static const fragment_items opa_rmpp_frag_items = {
* @param[out] num_ports optional: pointer to a number of ports in set in port
* select mask and portlist if provided.
* @return gchar* pointer to range string allocated using
- * wmem_strbuf_sized_new(wmem_packet_scope(),...)
+ * wmem_strbuf_new_sized(wmem_packet_scope(),...)
*/
static gchar *opa_format_port_select_mask(tvbuff_t *tvb, gint offset, guint8 **port_list, guint8 *num_ports)
{
@@ -2542,7 +2542,7 @@ static gchar *opa_format_port_select_mask(tvbuff_t *tvb, gint offset, guint8 **p
psm[2] = tvb_get_ntoh64(tvb, offset + 16);
psm[3] = tvb_get_ntoh64(tvb, offset + 24);
- buf = wmem_strbuf_sized_new(wmem_packet_scope(), 0, ITEM_LABEL_LENGTH);
+ buf = wmem_strbuf_create(wmem_packet_scope());
if (port_list) {
/* Allocate list of ports; max = 256 = 64 * 4 */
diff --git a/epan/dissectors/packet-protobuf.c b/epan/dissectors/packet-protobuf.c
index a1cfce2050..9a8ca22115 100644
--- a/epan/dissectors/packet-protobuf.c
+++ b/epan/dissectors/packet-protobuf.c
@@ -1700,7 +1700,7 @@ buffer_error(const gchar *fmt, ...)
va_start(ap, fmt);
if (err_msg_buf == NULL)
- err_msg_buf = wmem_strbuf_sized_new(wmem_epan_scope(), MIN_ERR_STR_BUF_SIZE, MAX_ERR_STR_BUF_SIZE);
+ err_msg_buf = wmem_strbuf_new_sized(wmem_epan_scope(), MIN_ERR_STR_BUF_SIZE);
wmem_strbuf_append_vprintf(err_msg_buf, fmt, ap);
diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c
index ddda9c2490..bc291c4604 100644
--- a/epan/dissectors/packet-radius.c
+++ b/epan/dissectors/packet-radius.c
@@ -680,7 +680,7 @@ dissect_ascend_data_filter(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _
return wmem_strdup_printf(wmem_packet_scope(), "Wrong attribute length %d", len);
}
- filterstr = wmem_strbuf_sized_new(wmem_packet_scope(), 128, 128);
+ filterstr = wmem_strbuf_new_sized(wmem_packet_scope(), 128);
ti = proto_tree_add_item(tree, hf_radius_ascend_data_filter, tvb, 0, -1, ENC_NA);
ascend_tree = proto_item_add_subtree(ti, ett_radius_ascend);
diff --git a/epan/dissectors/packet-rrc.c b/epan/dissectors/packet-rrc.c
index b52e8b1f66..d78b620515 100644
--- a/epan/dissectors/packet-rrc.c
+++ b/epan/dissectors/packet-rrc.c
@@ -19010,7 +19010,7 @@ dissect_rrc_PLMN_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U
/* Reset the digits string in the private data struct */
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
- mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
+ mcc_mnc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
/* Reset parsing failure flag*/
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
@@ -19030,7 +19030,7 @@ dissect_rrc_PLMN_Identity(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U
if(string_len >= 3)
{
/* 3 MCC digits were found, keep for later in case MCC is missing in other PLMN ids*/
- mcc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,4,4);
+ mcc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,4);
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[0]);
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[1]);
wmem_strbuf_append_c(mcc_strbuf,mcc_mnc_string[2]);
@@ -116016,7 +116016,7 @@ dissect_rrc_IMSI_GSM_MAP(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_
tvbuff_t* imsi_tvb;
/* Reset the digits string in the private data struct */
- imsi_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,16,16);
+ imsi_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,16);
private_data_set_digits_strbuf(actx, imsi_strbuf);
/* Reset parsing failure flag*/
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
@@ -135772,7 +135772,7 @@ dissect_rrc_PLMN_IdentityWithOptionalMCC_r6(tvbuff_t *tvb _U_, int offset _U_, a
/* Reset the digits string in the private data struct */
/* Maximal length: 7 = 3 digits MCC + 3 digits MNC + trailing '\0' */
- mcc_mnc_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
+ mcc_mnc_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
private_data_set_digits_strbuf(actx, mcc_mnc_strbuf);
/* Reset parsing failure flag*/
private_data_set_digits_strbuf_parsing_failed_flag(actx, FALSE);
@@ -135791,7 +135791,7 @@ dissect_rrc_PLMN_IdentityWithOptionalMCC_r6(tvbuff_t *tvb _U_, int offset _U_, a
if (string_len > 3) {
/* 3 MCC digits and at least 1 MNC digit were found, keep MCC for later
in case it's missing in other PLMN ids*/
- temp_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,4,4);
+ temp_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,4);
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[0]);
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[1]);
wmem_strbuf_append_c(temp_strbuf,mcc_mnc_string[2]);
@@ -135805,7 +135805,7 @@ dissect_rrc_PLMN_IdentityWithOptionalMCC_r6(tvbuff_t *tvb _U_, int offset _U_, a
if(last_mcc_strbuf)
{
/* Concat MCC and MNC in temp buffer */
- temp_strbuf = wmem_strbuf_sized_new(actx->pinfo->pool,7,7);
+ temp_strbuf = wmem_strbuf_new_sized(actx->pinfo->pool,7);
wmem_strbuf_append_printf(temp_strbuf,"%s",wmem_strbuf_get_str(last_mcc_strbuf));
wmem_strbuf_append_printf(temp_strbuf,"%s",mcc_mnc_string);
/* Update length of recovered MCC-MNC pair */
diff --git a/epan/dissectors/packet-sita.c b/epan/dissectors/packet-sita.c
index ebedb4e252..a7e91a6816 100644
--- a/epan/dissectors/packet-sita.c
+++ b/epan/dissectors/packet-sita.c
@@ -69,7 +69,7 @@ format_flags_string(guchar value, const gchar *array[])
wmem_strbuf_t *buf;
const char *sep = "";
- buf = wmem_strbuf_sized_new(wmem_packet_scope(), MAX_FLAGS_LEN, MAX_FLAGS_LEN);
+ buf = wmem_strbuf_new_sized(wmem_packet_scope(), MAX_FLAGS_LEN);
for (i = 0; i < 8; i++) {
bpos = 1 << i;
if (value & bpos) {
diff --git a/epan/dissectors/packet-skinny.c b/epan/dissectors/packet-skinny.c
index 3b618ea8ea..c25ac1ed3c 100644
--- a/epan/dissectors/packet-skinny.c
+++ b/epan/dissectors/packet-skinny.c
@@ -2339,7 +2339,7 @@ dissect_skinny_displayLabel(ptvcursor_t *cursor, packet_info *pinfo, int hfindex
item = proto_tree_add_item(tree, hfindex, tvb, offset, length, ENC_ASCII);
- wmem_new = wmem_strbuf_sized_new(pinfo->pool, length + 1, 0);
+ wmem_new = wmem_strbuf_new_sized(pinfo->pool, length + 1);
disp_string = (gchar*) wmem_alloc(pinfo->pool, length + 1);
disp_string[length] = '\0';
tvb_memcpy(tvb, (void*)disp_string, offset, length);
diff --git a/epan/dissectors/packet-tds.c b/epan/dissectors/packet-tds.c
index 13e3ea7390..08e569d400 100644
--- a/epan/dissectors/packet-tds.c
+++ b/epan/dissectors/packet-tds.c
@@ -4539,7 +4539,7 @@ dissect_tds7_login(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tds_conv
wmem_strbuf_t *val2;
len *= 2;
val = tvb_memdup(wmem_packet_scope(), tvb, offset2, len);
- val2 = wmem_strbuf_sized_new(wmem_packet_scope(), len/2+1, 0);
+ val2 = wmem_strbuf_new_sized(wmem_packet_scope(), len/2+1);
for(j = 0, k = 0; j < len; j += 2, k++) {
val[j] ^= 0xA5;
diff --git a/epan/dissectors/packet-tr.c b/epan/dissectors/packet-tr.c
index 5e3390c8e1..39d17b2a80 100644
--- a/epan/dissectors/packet-tr.c
+++ b/epan/dissectors/packet-tr.c
@@ -641,8 +641,7 @@ add_ring_bridge_pairs(int rcf_len, tvbuff_t *tvb, proto_tree *tree)
wmem_strbuf_t *buf;
#define MAX_BUF_LEN 3 + (RIF_BYTES_TO_PROCESS / 2) * 6 + 1
- buf = wmem_strbuf_sized_new(wmem_packet_scope(),
- MAX_BUF_LEN, MAX_BUF_LEN);
+ buf = wmem_strbuf_new_sized(wmem_packet_scope(), MAX_BUF_LEN);
/* Only process so many bytes of RIF, as per TR spec, and not overflow
* static buffer above */
unprocessed_rif = rcf_len - RIF_BYTES_TO_PROCESS;
diff --git a/epan/dissectors/packet-waveagent.c b/epan/dissectors/packet-waveagent.c
index b2422db5fb..b55a65c845 100644
--- a/epan/dissectors/packet-waveagent.c
+++ b/epan/dissectors/packet-waveagent.c
@@ -492,7 +492,7 @@ static void dissect_wa_payload(guint32 starting_offset, proto_item *parent_tree,
offset = starting_offset + 16;
delta = 148;
- sb = wmem_strbuf_sized_new(wmem_packet_scope(), 8, SHORT_STR);
+ sb = wmem_strbuf_new_sized(wmem_packet_scope(), 8);
for (iLoop = 0; iLoop < num_bss_entries; iLoop++)
{
diff --git a/epan/dissectors/packet-x11.c b/epan/dissectors/packet-x11.c
index f2e3a6c1c8..c4dcf9b43a 100644
--- a/epan/dissectors/packet-x11.c
+++ b/epan/dissectors/packet-x11.c
@@ -2231,7 +2231,7 @@ static char *tvb_get_ascii_string16(tvbuff_t *tvb, int offset, guint length)
wmem_strbuf_t *str;
guint8 ch;
- str = wmem_strbuf_sized_new(wmem_packet_scope(), length + 1, 0);
+ str = wmem_strbuf_new_sized(wmem_packet_scope(), length + 1);
while(length--) {
offset++;
diff --git a/epan/dissectors/packet-x509if.c b/epan/dissectors/packet-x509if.c
index 832d753809..d891112248 100644
--- a/epan/dissectors/packet-x509if.c
+++ b/epan/dissectors/packet-x509if.c
@@ -862,7 +862,7 @@ dissect_x509if_RelativeDistinguishedName(gboolean implicit_tag _U_, tvbuff_t *tv
/* now append this to the DN */
if (last_dn_buf) {
if(wmem_strbuf_get_len(last_dn_buf) > 0) {
- wmem_strbuf_t *temp_dn_buf = wmem_strbuf_sized_new(actx->pinfo->pool, wmem_strbuf_get_len(last_rdn_buf) + wmem_strbuf_get_len(last_dn_buf) + 1, 0);
+ wmem_strbuf_t *temp_dn_buf = wmem_strbuf_new_sized(actx->pinfo->pool, wmem_strbuf_get_len(last_rdn_buf) + wmem_strbuf_get_len(last_dn_buf) + 1);
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_rdn_buf));
wmem_strbuf_append_c(temp_dn_buf, ',');
wmem_strbuf_append(temp_dn_buf, wmem_strbuf_get_str(last_dn_buf));
diff --git a/epan/dissectors/packet-xip.c b/epan/dissectors/packet-xip.c
index b9f01ed54e..a9689b0867 100644
--- a/epan/dissectors/packet-xip.c
+++ b/epan/dissectors/packet-xip.c
@@ -412,8 +412,7 @@ construct_dag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *xip_tree,
ti = proto_tree_add_item(xip_tree, hf, tvb, offset,
num_nodes * XIA_NODE_SIZE, ENC_BIG_ENDIAN);
- buf = wmem_strbuf_sized_new(pinfo->pool,
- XIA_MAX_STRADDR_SIZE, XIA_MAX_STRADDR_SIZE);
+ buf = wmem_strbuf_new_sized(pinfo->pool, XIA_MAX_STRADDR_SIZE);
dag_tree = proto_item_add_subtree(ti, ett);
diff --git a/epan/proto.c b/epan/proto.c
index c665daf839..aa43342ba9 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -8044,7 +8044,7 @@ proto_list_layers(const packet_info *pinfo)
wmem_strbuf_t *buf;
wmem_list_frame_t *layers = wmem_list_head(pinfo->layers);
- buf = wmem_strbuf_sized_new(pinfo->pool, 128, 0);
+ buf = wmem_strbuf_new_sized(pinfo->pool, 128);
/* Walk the list of layers in the packet and
return a string of all entries. */
diff --git a/epan/to_str.c b/epan/to_str.c
index 990d92d7ed..19731e951d 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -423,7 +423,7 @@ unsigned_time_secs_to_str(wmem_allocator_t *scope, const guint32 time_val)
return wmem_strdup(scope, "0 seconds");
}
- buf = wmem_strbuf_sized_new(scope, TIME_SECS_LEN+1, TIME_SECS_LEN+1);
+ buf = wmem_strbuf_new_sized(scope, TIME_SECS_LEN+1);
unsigned_time_secs_to_str_buf(time_val, 0, FALSE, buf);
@@ -478,7 +478,7 @@ signed_time_secs_to_str(wmem_allocator_t *scope, const gint32 time_val)
return wmem_strdup(scope, "0 seconds");
}
- buf = wmem_strbuf_sized_new(scope, TIME_SECS_LEN+1, TIME_SECS_LEN+1);
+ buf = wmem_strbuf_new_sized(scope, TIME_SECS_LEN+1);
signed_time_secs_to_str_buf(time_val, 0, FALSE, buf);
@@ -499,7 +499,7 @@ signed_time_msecs_to_str(wmem_allocator_t *scope, gint32 time_val)
return wmem_strdup(scope, "0 seconds");
}
- buf = wmem_strbuf_sized_new(scope, TIME_SECS_LEN+1+3+1, TIME_SECS_LEN+1+3+1);
+ buf = wmem_strbuf_new_sized(scope, TIME_SECS_LEN+1+3+1);
if (time_val<0) {
/* oops we got passed a negative time */
@@ -537,7 +537,7 @@ rel_time_to_str(wmem_allocator_t *scope, const nstime_t *rel_time)
return wmem_strdup(scope, "0.000000000 seconds");
}
- buf = wmem_strbuf_sized_new(scope, 1+TIME_SECS_LEN+1+6+1, 1+TIME_SECS_LEN+1+6+1);
+ buf = wmem_strbuf_new_sized(scope, 1+TIME_SECS_LEN+1+6+1);
if (nsec < 0) {
nsec = -nsec;
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 99d37ed68b..4f0bfdab82 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -3033,7 +3033,7 @@ tvb_get_apn_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset,
* the upper 2 bits of the length don't indicate that it's a
* pointer or an extended label (RFC 2673).
*/
- str = wmem_strbuf_sized_new(scope, length + 1, 0);
+ str = wmem_strbuf_new_sized(scope, length + 1);
if (length > 0) {
const guint8 *ptr;
diff --git a/wsutil/str_util.c b/wsutil/str_util.c
index 2b87c970fa..9b40ece067 100644
--- a/wsutil/str_util.c
+++ b/wsutil/str_util.c
@@ -492,7 +492,7 @@ escape_string_len(wmem_allocator_t *alloc, const char *string, ssize_t len,
if (add_quotes)
alloc_size += 2;
- buf = wmem_strbuf_sized_new(alloc, alloc_size, 0);
+ buf = wmem_strbuf_new_sized(alloc, alloc_size);
if (add_quotes)
wmem_strbuf_append_c(buf, '"');
@@ -552,7 +552,7 @@ ws_strdup_underline(wmem_allocator_t *allocator, long offset, size_t len)
if (offset < 0)
return NULL;
- wmem_strbuf_t *buf = wmem_strbuf_sized_new(allocator, offset + len, 0);
+ wmem_strbuf_t *buf = wmem_strbuf_new_sized(allocator, offset + len);
for (int i = 0; i < offset; i++) {
wmem_strbuf_append_c(buf, ' ');
@@ -1013,7 +1013,7 @@ format_text_chr(wmem_allocator_t *allocator, const char *string, size_t len, cha
{
wmem_strbuf_t *buf;
- buf = wmem_strbuf_sized_new(allocator, len + 1, 0);
+ buf = wmem_strbuf_new_sized(allocator, len + 1);
for (const char *p = string; p < string + len; p++) {
if (g_ascii_isprint(*p)) {
wmem_strbuf_append_c(buf, *p);
diff --git a/wsutil/wmem/wmem_strbuf.c b/wsutil/wmem/wmem_strbuf.c
index a4696f0924..6f4666dba6 100644
--- a/wsutil/wmem/wmem_strbuf.c
+++ b/wsutil/wmem/wmem_strbuf.c
@@ -26,19 +26,16 @@
#define WMEM_STRBUF_RAW_ROOM(S) ((S)->alloc_size - (S)->len)
wmem_strbuf_t *
-wmem_strbuf_sized_new(wmem_allocator_t *allocator,
- size_t alloc_size, size_t max_size)
+wmem_strbuf_new_sized(wmem_allocator_t *allocator,
+ size_t alloc_size)
{
wmem_strbuf_t *strbuf;
- ASSERT((max_size == 0) || (alloc_size <= max_size));
-
strbuf = wmem_new(allocator, wmem_strbuf_t);
strbuf->allocator = allocator;
strbuf->len = 0;
strbuf->alloc_size = alloc_size ? alloc_size : DEFAULT_MINIMUM_SIZE;
- strbuf->max_size = max_size;
strbuf->str = (gchar *)wmem_alloc(strbuf->allocator, strbuf->alloc_size);
strbuf->str[0] = '\0';
@@ -59,7 +56,7 @@ wmem_strbuf_new_len(wmem_allocator_t *allocator, const gchar *str, size_t len)
alloc_size *= 2;
}
- strbuf = wmem_strbuf_sized_new(allocator, alloc_size, 0);
+ strbuf = wmem_strbuf_new_sized(allocator, alloc_size);
if (str && len > 0) {
ASSERT(strbuf->alloc_size >= len + 1);
@@ -82,7 +79,7 @@ wmem_strbuf_dup(wmem_allocator_t *allocator, const wmem_strbuf_t *src)
{
wmem_strbuf_t *new;
- new = wmem_strbuf_sized_new(allocator, src->alloc_size, src->max_size);
+ new = wmem_strbuf_new_sized(allocator, src->alloc_size);
new->len = src->len;
memcpy(new->str, src->str, new->len);
new->str[new->len] = '\0';
@@ -112,11 +109,6 @@ wmem_strbuf_grow(wmem_strbuf_t *strbuf, const size_t to_add)
new_alloc_len *= 2;
}
- /* max length only enforced if not 0 */
- if (strbuf->max_size && new_alloc_len > strbuf->max_size) {
- new_alloc_len = strbuf->max_size;
- }
-
if (new_alloc_len == strbuf->alloc_size) {
return;
}
@@ -154,17 +146,13 @@ wmem_strbuf_append_len(wmem_strbuf_t *strbuf, const gchar *str, size_t append_le
wmem_strbuf_grow(strbuf, append_len);
- if (strbuf->max_size) {
- append_len = MIN(append_len, WMEM_STRBUF_ROOM(strbuf));
- }
-
memcpy(&strbuf->str[strbuf->len], str, append_len);
strbuf->len += append_len;
strbuf->str[strbuf->len] = '\0';
}
static inline
-int _strbuf_vsnprintf(wmem_strbuf_t *strbuf, const char *format, va_list ap, gboolean reset)
+int _strbuf_vsnprintf(wmem_strbuf_t *strbuf, const char *format, va_list ap)
{
int want_len;
char *buffer = &strbuf->str[strbuf->len];
@@ -182,14 +170,8 @@ int _strbuf_vsnprintf(wmem_strbuf_t *strbuf, const char *format, va_list ap, gbo
return 0;
}
- /* No space in buffer, output was truncated. */
- if (reset) {
- strbuf->str[strbuf->len] = '\0'; /* Reset. */
- }
- else {
- strbuf->len += buffer_size - 1; /* Append. */
- ASSERT(strbuf->len == strbuf->alloc_size - 1);
- }
+ /* Not enough space in buffer, output was truncated. */
+ strbuf->str[strbuf->len] = '\0'; /* Reset. */
return want_len; /* Length (not including terminating null) that would be written
if there was enough space in buffer. */
@@ -203,14 +185,16 @@ wmem_strbuf_append_vprintf(wmem_strbuf_t *strbuf, const gchar *fmt, va_list ap)
va_copy(ap2, ap);
/* Try to write buffer, check if output fits. */
- want_len = _strbuf_vsnprintf(strbuf, fmt, ap2, TRUE); /* Remove output if truncated. */
+ want_len = _strbuf_vsnprintf(strbuf, fmt, ap2);
va_end(ap2);
if (want_len <= 0)
return;
- /* Resize buffer and try again. This could hit the 'max_size' ceiling. */
+ /* Resize buffer and try again. */
wmem_strbuf_grow(strbuf, want_len);
- _strbuf_vsnprintf(strbuf, fmt, ap, FALSE); /* Keep output if truncated. */
+ want_len = _strbuf_vsnprintf(strbuf, fmt, ap);
+ /* Second time must succeed or error out. */
+ ASSERT(want_len <= 0);
}
void
@@ -228,7 +212,7 @@ wmem_strbuf_append_c(wmem_strbuf_t *strbuf, const gchar c)
{
wmem_strbuf_grow(strbuf, 1);
- if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= 1) {
+ if (WMEM_STRBUF_ROOM(strbuf) >= 1) {
strbuf->str[strbuf->len] = c;
strbuf->len++;
strbuf->str[strbuf->len] = '\0';
@@ -245,7 +229,7 @@ wmem_strbuf_append_unichar(wmem_strbuf_t *strbuf, const gunichar c)
wmem_strbuf_grow(strbuf, charlen);
- if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= charlen) {
+ if (WMEM_STRBUF_ROOM(strbuf) >= charlen) {
memcpy(&strbuf->str[strbuf->len], buf, charlen);
strbuf->len += charlen;
strbuf->str[strbuf->len] = '\0';
@@ -272,7 +256,7 @@ wmem_strbuf_append_hex(wmem_strbuf_t *strbuf, uint8_t ch)
{
wmem_strbuf_grow(strbuf, HEX_CODELEN * 1);
- if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= HEX_CODELEN * 1) {
+ if (WMEM_STRBUF_ROOM(strbuf) >= HEX_CODELEN * 1) {
strbuf->str[strbuf->len++] = '\\';
strbuf->str[strbuf->len++] = 'x';
strbuf->str[strbuf->len++] = hex[(ch >> 4) & 0xF];
@@ -288,7 +272,7 @@ void append_hex_bmp(wmem_strbuf_t *strbuf, gunichar ch)
{
wmem_strbuf_grow(strbuf, BMP_CODELEN * 1);
- if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= BMP_CODELEN * 1) {
+ if (WMEM_STRBUF_ROOM(strbuf) >= BMP_CODELEN * 1) {
strbuf->str[strbuf->len++] = '\\';
strbuf->str[strbuf->len++] = 'u';
strbuf->str[strbuf->len++] = hex[(ch >> 12) & 0xF];
@@ -306,7 +290,7 @@ void append_hex_any(wmem_strbuf_t *strbuf, gunichar ch)
{
wmem_strbuf_grow(strbuf, ANY_CODELEN * 1);
- if (!strbuf->max_size || WMEM_STRBUF_ROOM(strbuf) >= ANY_CODELEN * 1) {
+ if (WMEM_STRBUF_ROOM(strbuf) >= ANY_CODELEN * 1) {
strbuf->str[strbuf->len++] = '\\';
strbuf->str[strbuf->len++] = 'U';
strbuf->str[strbuf->len++] = hex[(ch >> 28) & 0xF];
diff --git a/wsutil/wmem/wmem_strbuf.h b/wsutil/wmem/wmem_strbuf.h
index f063b4b341..68c6cefe4c 100644
--- a/wsutil/wmem/wmem_strbuf.h
+++ b/wsutil/wmem/wmem_strbuf.h
@@ -47,15 +47,13 @@ struct _wmem_strbuf_t {
/* private fields */
size_t alloc_size;
- size_t max_size;
};
typedef struct _wmem_strbuf_t wmem_strbuf_t;
WS_DLL_PUBLIC
wmem_strbuf_t *
-wmem_strbuf_sized_new(wmem_allocator_t *allocator,
- size_t alloc_size, size_t max_size)
+wmem_strbuf_new_sized(wmem_allocator_t *allocator, size_t alloc_size)
G_GNUC_MALLOC;
WS_DLL_PUBLIC
diff --git a/wsutil/wmem/wmem_test.c b/wsutil/wmem/wmem_test.c
index a70fe9293d..dfa6895260 100644
--- a/wsutil/wmem/wmem_test.c
+++ b/wsutil/wmem/wmem_test.c
@@ -1088,7 +1088,6 @@ wmem_test_strbuf(void)
wmem_allocator_t *allocator;
wmem_strbuf_t *strbuf;
int i;
- char *str;
allocator = wmem_allocator_new(WMEM_ALLOCATOR_STRICT);
@@ -1128,35 +1127,6 @@ wmem_test_strbuf(void)
g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "TESTFUZZ");
g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 8);
- strbuf = wmem_strbuf_sized_new(allocator, 10, 10);
- g_assert_true(strbuf);
- g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "");
- g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 0);
-
- wmem_strbuf_append(strbuf, "FUZZ");
- g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ");
- g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 4);
-
- wmem_strbuf_append_printf(strbuf, "%d%s", 3, "abcdefghijklmnop");
- g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ3abcd");
- g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 9);
-
- wmem_strbuf_append(strbuf, "abcdefghijklmnopqrstuvwxyz");
- g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ3abcd");
- g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 9);
-
- wmem_strbuf_append_c(strbuf, 'q');
- g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ3abcd");
- g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 9);
-
- wmem_strbuf_append_unichar(strbuf, g_utf8_get_char("\xC2\xA9"));
- g_assert_cmpstr(wmem_strbuf_get_str(strbuf), ==, "FUZZ3abcd");
- g_assert_cmpuint(wmem_strbuf_get_len(strbuf), ==, 9);
-
- str = wmem_strbuf_finalize(strbuf);
- g_assert_cmpstr(str, ==, "FUZZ3abcd");
- g_assert_cmpuint(strlen(str), ==, 9);
-
wmem_free_all(allocator);
strbuf = wmem_strbuf_new(allocator, "TEST");