forked from osmocom/wireshark
Replace some "low hanging fruit" uses of emem.
Most of the remaining ep_ uses are grouped with specific functionality. Change-Id: I8fa64a17acc6bcdcf6891b2d28715ac0c58f1a4a Reviewed-on: https://code.wireshark.org/review/6484 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
fdd6554ccd
commit
f5c4d06dba
|
@ -64,7 +64,7 @@ void asn1_ctx_clean_epdv(asn1_ctx_t *actx) {
|
|||
void asn1_stack_frame_push(asn1_ctx_t *actx, const gchar *name) {
|
||||
asn1_stack_frame_t *frame;
|
||||
|
||||
frame = ep_new0(asn1_stack_frame_t);
|
||||
frame = wmem_new0(wmem_packet_scope(), asn1_stack_frame_t);
|
||||
frame->name = name;
|
||||
frame->next = actx->stack;
|
||||
actx->stack = frame;
|
||||
|
@ -112,7 +112,7 @@ static asn1_par_t *push_new_par(asn1_ctx_t *actx) {
|
|||
|
||||
DISSECTOR_ASSERT(actx->stack);
|
||||
|
||||
par = ep_new0(asn1_par_t);
|
||||
par = wmem_new0(wmem_packet_scope(), asn1_par_t);
|
||||
|
||||
pp = &(actx->stack->par);
|
||||
while (*pp)
|
||||
|
@ -278,8 +278,9 @@ double asn1_get_real(const guint8 *real_ptr, gint len) {
|
|||
case 0x01: val = -HUGE_VAL; break;
|
||||
}
|
||||
} else { /* decimal encoding */
|
||||
buf = ep_strndup(p, len);
|
||||
buf = g_strndup(p, len);
|
||||
val = atof(buf);
|
||||
g_free(buf);
|
||||
}
|
||||
|
||||
return val;
|
||||
|
|
|
@ -620,10 +620,6 @@ col_set_str(column_info *cinfo, const gint el, const gchar* str)
|
|||
|
||||
DISSECTOR_ASSERT(str);
|
||||
|
||||
/* The caller is expected to pass in something that 'will stay around' and
|
||||
* something from the ephemeral pool certainly doesn't fit the bill. */
|
||||
DISSECTOR_ASSERT(!ep_verify_pointer(str));
|
||||
|
||||
if (!CHECK_COL(cinfo, el))
|
||||
return;
|
||||
|
||||
|
|
|
@ -1046,13 +1046,14 @@ AirPDcapRsnaMng(
|
|||
}
|
||||
|
||||
/* allocate a temp buffer for the decryption loop */
|
||||
try_data=(UCHAR *)ep_alloc(try_data_len);
|
||||
try_data=(UCHAR *)g_malloc(try_data_len);
|
||||
|
||||
/* start of loop added by GCS */
|
||||
for(/* sa */; sa != NULL ;sa=sa->next) {
|
||||
|
||||
if (*decrypt_len > try_data_len) {
|
||||
AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapRsnaMng", "Invalid decryption length", AIRPDCAP_DEBUG_LEVEL_3);
|
||||
g_free(try_data);
|
||||
return AIRPDCAP_RET_UNSUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1092,16 +1093,20 @@ AirPDcapRsnaMng(
|
|||
/* end of loop */
|
||||
|
||||
/* none of the keys worked */
|
||||
if(sa == NULL)
|
||||
if(sa == NULL) {
|
||||
g_free(try_data);
|
||||
return ret_value;
|
||||
}
|
||||
|
||||
if (*decrypt_len > try_data_len || *decrypt_len < 8) {
|
||||
AIRPDCAP_DEBUG_PRINT_LINE("AirPDcapRsnaMng", "Invalid decryption length", AIRPDCAP_DEBUG_LEVEL_3);
|
||||
g_free(try_data);
|
||||
return AIRPDCAP_RET_UNSUCCESS;
|
||||
}
|
||||
|
||||
/* copy the decrypted data into the decrypt buffer GCS*/
|
||||
memcpy(decrypt_data, try_data, *decrypt_len);
|
||||
g_free(try_data);
|
||||
|
||||
/* remove protection bit */
|
||||
decrypt_data[1]&=0xBF;
|
||||
|
@ -1142,7 +1147,7 @@ AirPDcapWepMng(
|
|||
UCHAR *try_data;
|
||||
guint try_data_len = *decrypt_len;
|
||||
|
||||
try_data = (UCHAR *)ep_alloc(try_data_len);
|
||||
try_data = (UCHAR *)g_malloc(try_data_len);
|
||||
|
||||
if (sa->key!=NULL)
|
||||
useCache=TRUE;
|
||||
|
@ -1204,6 +1209,7 @@ AirPDcapWepMng(
|
|||
}
|
||||
}
|
||||
|
||||
g_free(try_data);
|
||||
if (ret_value)
|
||||
return ret_value;
|
||||
|
||||
|
|
|
@ -745,7 +745,7 @@ get_full_ipv6_addr(char* ipv6_addr_expanded, char *ipv6_addr)
|
|||
|
||||
if(suffix_len < IPSEC_STRLEN_IPV6)
|
||||
{
|
||||
prefix_addr = ep_strndup(ipv6_addr,strlen(ipv6_addr) - suffix_cpt);
|
||||
prefix_addr = wmem_strndup(wmem_packet_scope(), ipv6_addr,strlen(ipv6_addr) - suffix_cpt);
|
||||
prefix_remaining = get_ipv6_suffix(prefix,prefix_addr);
|
||||
prefix_len = (int) strlen(prefix);
|
||||
memcpy(ipv6_addr_expanded,prefix,prefix_len);
|
||||
|
|
|
@ -359,7 +359,7 @@ static gboolean
|
|||
protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const void* u2 _U_, const char** err)
|
||||
{
|
||||
gchar** protos;
|
||||
gchar* line = ep_strndup(p,len);
|
||||
gchar* line = wmem_strndup(NULL,p,len);
|
||||
guint num_protos, i;
|
||||
|
||||
g_strstrip(line);
|
||||
|
@ -372,6 +372,7 @@ protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const v
|
|||
|
||||
if (!num_protos) {
|
||||
*err = ep_strdup_printf("No protocols given");
|
||||
wmem_free(NULL, line);
|
||||
wmem_free(NULL, protos);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -379,11 +380,13 @@ protos_chk_cb(void* r _U_, const char* p, guint len, const void* u1 _U_, const v
|
|||
for (i = 0; i < num_protos; i++) {
|
||||
if (!find_dissector(protos[i])) {
|
||||
*err = ep_strdup_printf("Could not find dissector for: '%s'",protos[i]);
|
||||
wmem_free(NULL, line);
|
||||
wmem_free(NULL, protos);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
wmem_free(NULL, line);
|
||||
wmem_free(NULL, protos);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -4852,7 +4852,9 @@ ssldecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, co
|
|||
}
|
||||
|
||||
if (!find_dissector(p)) {
|
||||
*err = ep_strdup_printf("Could not find dissector for: '%s'\nValid dissectors are:\n%s", p, ssl_association_info());
|
||||
char* ssl_str = ssl_association_info();
|
||||
*err = ep_strdup_printf("Could not find dissector for: '%s'\nValid dissectors are:\n%s", p, ssl_str);
|
||||
g_free(ssl_str);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ ssl_association_info_(gpointer key_ _U_, gpointer value_, gpointer s_)
|
|||
gchar*
|
||||
ssl_association_info(void)
|
||||
{
|
||||
gchar *s = (gchar *)ep_alloc0(SSL_ASSOC_MAX_LEN);
|
||||
gchar *s = (gchar *)g_malloc0(SSL_ASSOC_MAX_LEN);
|
||||
g_tree_foreach(ssl_associations, ssl_association_info_, s);
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ void *ep_alloc(size_t size) G_GNUC_MALLOC;
|
|||
/** Allocate memory with a packet lifetime scope and fill it with zeros*/
|
||||
WS_DLL_PUBLIC
|
||||
void* ep_alloc0(size_t size) G_GNUC_MALLOC;
|
||||
#define ep_new0(type) ((type*)ep_alloc0(sizeof(type)))
|
||||
|
||||
/** Duplicate a string with a packet lifetime scope */
|
||||
WS_DLL_PUBLIC
|
||||
|
@ -84,9 +83,6 @@ gchar* ep_strdup_printf(const gchar* fmt, ...)
|
|||
WS_DLL_PUBLIC
|
||||
gchar *ep_strconcat(const gchar *string, ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
|
||||
|
||||
/** allocates with a packet lifetime scope an array of type made of num elements */
|
||||
#define ep_alloc_array(type,num) (type*)ep_alloc(sizeof(type)*(num))
|
||||
|
||||
/** release all memory allocated in the previous packet dissection */
|
||||
void ep_free_all(void);
|
||||
|
||||
|
|
|
@ -512,13 +512,13 @@ expert_set_info_vformat(packet_info *pinfo, proto_item *pi, int group, int sever
|
|||
if (!tap)
|
||||
return;
|
||||
|
||||
ei = ep_new(expert_info_t);
|
||||
ei = wmem_new(wmem_packet_scope(), expert_info_t);
|
||||
|
||||
ei->packet_num = PINFO_FD_NUM(pinfo);
|
||||
ei->group = group;
|
||||
ei->severity = severity;
|
||||
ei->protocol = pinfo->current_proto;
|
||||
ei->summary = ep_strdup(formatted);
|
||||
ei->summary = wmem_strdup(wmem_packet_scope(), formatted);
|
||||
|
||||
/* if we have a proto_item (not a faked item), set expert attributes to it */
|
||||
if (pi != NULL && PITEM_FINFO(pi) != NULL) {
|
||||
|
|
|
@ -636,7 +636,8 @@ eui64_repr_len(fvalue_t *fv _U_, ftrepr_t rtype _U_, int field_display _U_)
|
|||
static void
|
||||
eui64_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf)
|
||||
{
|
||||
guint8 *p_eui64 = (guint8 *)ep_alloc(8);
|
||||
guint8 eui64[8];
|
||||
guint8 *p_eui64 = eui64;
|
||||
|
||||
/* Copy and convert the address to network byte order. */
|
||||
*(guint64 *)(void *)(p_eui64) = pntoh64(&(fv->value.integer64));
|
||||
|
|
|
@ -3134,7 +3134,7 @@ proto_item_append_string(proto_item *pi, const char *str)
|
|||
DISSECTOR_ASSERT_FIELD_TYPE_IS_STRING(hfinfo);
|
||||
old_str = (guint8 *)fvalue_get(&fi->value);
|
||||
if (old_str && old_str[0])
|
||||
new_str = ep_strconcat(old_str, str, NULL);
|
||||
new_str = wmem_strconcat(wmem_packet_scope(), old_str, str, NULL);
|
||||
else
|
||||
new_str = str;
|
||||
fvalue_set_string(&fi->value, new_str);
|
||||
|
@ -8337,7 +8337,7 @@ proto_tree_add_bits_format_value(proto_tree *tree, const int hfindex,
|
|||
|
||||
#define CREATE_VALUE_STRING(dst,format,ap) \
|
||||
va_start(ap, format); \
|
||||
dst = ep_strdup_vprintf(format, ap); \
|
||||
dst = wmem_strdup_vprintf(wmem_packet_scope(), format, ap); \
|
||||
va_end(ap);
|
||||
|
||||
proto_item *
|
||||
|
|
|
@ -107,13 +107,14 @@ diam_tree_to_csv(proto_node *node, gpointer data)
|
|||
val_tmp = fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, hfi->display, NULL);
|
||||
if (val_tmp)
|
||||
{
|
||||
val_str = ep_strdup(val_tmp);
|
||||
val_str = g_strdup(val_tmp);
|
||||
g_free(val_tmp);
|
||||
} else
|
||||
val_str = ep_strdup_printf("unsupported type: %s", ftype_name(ftype));
|
||||
val_str = g_strdup_printf("unsupported type: %s", ftype_name(ftype));
|
||||
|
||||
/*printf("traverse: name='%s', abbrev='%s',desc='%s', val='%s'\n", hfi->name, hfi->abbrev, ftype_name(hfi->type), val_str);*/
|
||||
printf("%s='%s' ", hfi->name, val_str);
|
||||
g_free(val_str);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -4936,7 +4936,7 @@ menu_prefs_edit_dlg (GtkWidget *w, gpointer data)
|
|||
{
|
||||
pref_t *pref = (pref_t *)data;
|
||||
module_t *module = (module_t *)g_object_get_data (G_OBJECT(w), "module");
|
||||
gchar *value = NULL;
|
||||
gchar *value = NULL, *label_str;
|
||||
|
||||
GtkWidget *win, *main_grid, *main_vb, *bbox, *cancel_bt, *ok_bt;
|
||||
GtkWidget *entry, *label;
|
||||
|
@ -4982,7 +4982,9 @@ menu_prefs_edit_dlg (GtkWidget *w, gpointer data)
|
|||
gtk_box_pack_start(GTK_BOX(main_vb), main_grid, FALSE, FALSE, 0);
|
||||
ws_gtk_grid_set_column_spacing(GTK_GRID(main_grid), 10);
|
||||
|
||||
label = gtk_label_new(ep_strdup_printf("%s:", pref->title));
|
||||
label_str = g_strdup_printf("%s:", pref->title);
|
||||
label = gtk_label_new(label_str);
|
||||
g_free(label_str);
|
||||
ws_gtk_grid_attach_defaults(GTK_GRID(main_grid), label, 0, 1, 1, 1);
|
||||
gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
|
||||
if (pref->description)
|
||||
|
|
Loading…
Reference in New Issue