Remove ep_strndup

Change-Id: Id336dc16f97a0973754993094aa637813c0ca31c
Reviewed-on: https://code.wireshark.org/review/6604
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2015-01-17 20:59:20 -05:00
parent 403be722ce
commit ef7e8aa065
6 changed files with 24 additions and 39 deletions

View File

@ -442,7 +442,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
ep_alloc@Base 1.9.1
ep_strdup@Base 1.9.1
ep_strdup_printf@Base 1.9.1
ep_strndup@Base 1.9.1
epan_cleanup@Base 1.9.1
epan_dissect_cleanup@Base 1.9.1
epan_dissect_fake_protocols@Base 1.9.1

View File

@ -965,27 +965,6 @@ ep_strdup(const gchar *src)
return emem_strdup(src, ep_alloc);
}
static gchar *
emem_strndup(const gchar *src, size_t len, void *allocator(size_t))
{
gchar *dst = (gchar *)allocator(len+1);
guint i;
for (i = 0; (i < len) && src[i]; i++)
dst[i] = src[i];
dst[i] = '\0';
return dst;
}
gchar *
ep_strndup(const gchar *src, size_t len)
{
return emem_strndup(src, len, ep_alloc);
}
static gchar *
emem_strdup_vprintf(const gchar *fmt, va_list ap, void *allocator(size_t))

View File

@ -63,10 +63,6 @@ void* ep_alloc0(size_t size) G_GNUC_MALLOC;
WS_DLL_PUBLIC
gchar* ep_strdup(const gchar* src) G_GNUC_MALLOC;
/** Duplicate at most n characters of a string with a packet lifetime scope */
WS_DLL_PUBLIC
gchar* ep_strndup(const gchar* src, size_t len) G_GNUC_MALLOC;
/** Create a formatted string with a packet lifetime scope */
WS_DLL_PUBLIC
gchar* ep_strdup_printf(const gchar* fmt, ...)

View File

@ -25,7 +25,6 @@
#include <ftypes-int.h>
#include <epan/ipv4.h>
#include <epan/addr_resolv.h>
#include <epan/emem.h>
static void
@ -47,27 +46,32 @@ val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_,
guint32 addr;
unsigned int nmask_bits;
const char *has_slash;
const char *net_str, *addr_str;
const char *has_slash, *net_str;
char *addr_str;
fvalue_t *nmask_fvalue;
gboolean free_addr_str = FALSE;
/* Look for CIDR: Is there a single slash in the string? */
has_slash = strchr(s, '/');
if (has_slash) {
/* Make a copy of the string up to but not including the
* slash; that's the address portion. */
addr_str = ep_strndup(s, has_slash - s);
addr_str = wmem_strndup(NULL, s, has_slash - s);
free_addr_str = TRUE;
}
else {
addr_str = s;
addr_str = (char*)s;
}
if (!get_host_ipaddr(addr_str, &addr)) {
logfunc("\"%s\" is not a valid hostname or IPv4 address.",
addr_str);
logfunc("\"%s\" is not a valid hostname or IPv4 address.", addr_str);
if (free_addr_str)
wmem_free(NULL, addr_str);
return FALSE;
}
if (free_addr_str)
wmem_free(NULL, addr_str);
ipv4_addr_set_net_order_addr(&(fv->value.ipv4), addr);
/* If CIDR, get netmask bits. */

View File

@ -25,7 +25,6 @@
#include <ftypes-int.h>
#include <epan/ipv6-utils.h>
#include <epan/addr_resolv.h>
#include <epan/emem.h>
static void
ipv6_fvalue_set(fvalue_t *fv, const guint8 *value)
@ -37,21 +36,30 @@ ipv6_fvalue_set(fvalue_t *fv, const guint8 *value)
static gboolean
ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, LogFunc logfunc)
{
const char *has_slash, *addr_str;
const char *has_slash;
char *addr_str;
unsigned int nmask_bits;
fvalue_t *nmask_fvalue;
gboolean free_addr_str = FALSE;
/* Look for prefix: Is there a single slash in the string? */
if ((has_slash = strchr(s, '/')))
addr_str = ep_strndup(s, has_slash-s);
if ((has_slash = strchr(s, '/'))) {
addr_str = wmem_strndup(NULL, s, has_slash-s);
free_addr_str = TRUE;
}
else
addr_str = s;
addr_str = (char*)s;
if (!get_host_ipaddr6(addr_str, &(fv->value.ipv6.addr))) {
logfunc("\"%s\" is not a valid hostname or IPv6 address.", s);
if (free_addr_str)
wmem_free(NULL, addr_str);
return FALSE;
}
if (free_addr_str)
wmem_free(NULL, addr_str);
/* If prefix */
if (has_slash) {
/* XXX - this is inefficient */

View File

@ -155,7 +155,6 @@ my %APIs = (
'ep_alloc',
'ep_alloc0',
'ep_strdup',
'ep_strndup',
'ep_strdup_printf',
'ep_alloc_array',
'ep_alloc_array0',