示例#1
0
static void
wmem_test_allocator_jumbo(wmem_allocator_type_t type, wmem_verify_func verify)
{
    wmem_allocator_t *allocator;
    char *ptr, *ptr1;

    allocator = wmem_allocator_force_new(type);

    ptr = (char*)wmem_alloc0(allocator, 4*1024*1024);
    wmem_free(allocator, ptr);
    wmem_gc(allocator);
    ptr = (char*)wmem_alloc0(allocator, 4*1024*1024);

    if (verify) (*verify)(allocator);
    wmem_free(allocator, ptr);
    wmem_gc(allocator);
    if (verify) (*verify)(allocator);

    ptr  = (char *)wmem_alloc0(allocator, 10*1024*1024);
    ptr1 = (char *)wmem_alloc0(allocator, 13*1024*1024);
    ptr1 = (char *)wmem_realloc(allocator, ptr1, 10*1024*1024);
    memset(ptr1, 0, 10*1024*1024);
    ptr = (char *)wmem_realloc(allocator, ptr, 13*1024*1024);
    memset(ptr, 0, 13*1024*1024);
    if (verify) (*verify)(allocator);
    wmem_gc(allocator);
    if (verify) (*verify)(allocator);
    wmem_free(allocator, ptr1);
    if (verify) (*verify)(allocator);
    wmem_free_all(allocator);
    wmem_gc(allocator);
    if (verify) (*verify)(allocator);

    wmem_destroy_allocator(allocator);
}
示例#2
0
char *get_hostlist_filter(hostlist_talker_t *host)
{
    char *sport, *src_addr;
    char *str;

    sport = ct_port_to_str(host->ptype, host->port);
    src_addr = address_to_str(NULL, &host->myaddress);
    if (host->myaddress.type == AT_STRINGZ || host->myaddress.type == AT_USB) {
        char *new_addr;

        new_addr = wmem_strdup_printf(NULL, "\"%s\"", src_addr);
        wmem_free(NULL, src_addr);
        src_addr = new_addr;
    }

    str = g_strdup_printf("%s==%s%s%s%s%s",
                          hostlist_get_filter_name(host, CONV_FT_ANY_ADDRESS),
                          src_addr,
                          sport?" && ":"",
                          sport?hostlist_get_filter_name(host, CONV_FT_ANY_PORT):"",
                          sport?"==":"",
                          sport?sport:"");

    g_free(sport);
    wmem_free(NULL, src_addr);
    return str;
}
static void
wmem_block_fast_free_all(void *private_data)
{
    wmem_block_fast_allocator_t *allocator = (wmem_block_fast_allocator_t*) private_data;
    wmem_block_fast_hdr_t       *cur, *nxt;
    wmem_block_fast_jumbo_t     *cur_jum, *nxt_jum;

    /* iterate through the blocks, freeing all but the first and reinitializing
     * that one */
    cur = allocator->block_list;

    if (cur) {
         cur->pos = WMEM_BLOCK_HEADER_SIZE;
         nxt = cur->next;
         cur->next = NULL;
         cur = nxt;
    }

    while (cur) {
        nxt  = cur->next;
        wmem_free(NULL, cur);
        cur = nxt;
    }

    /* now do the jumbo blocks, freeing all of them */
    cur_jum = allocator->jumbo_list;
    while (cur_jum) {
        nxt_jum  = cur_jum->next;
        wmem_free(NULL, cur_jum);
        cur_jum = nxt_jum;
    }
    allocator->jumbo_list = NULL;
}
static void
wmem_strict_block_free(wmem_strict_allocator_block_t *block)
{
    memset(block->real_data, WMEM_POSTFILL, block->data_len);

    wmem_free(NULL, block->leading_canary);
    wmem_free(NULL, block);
}
示例#5
0
static void
rtd_draw(void *arg)
{
	rtd_data_t* rtd_data = (rtd_data_t*)arg;
	rtd_t* rtd = (rtd_t*)rtd_data->user_data;
	gchar* tmp_str;
	guint i, j;

	/* printing results */
	printf("\n");
	printf("=====================================================================================================\n");
	printf("%s Response Time Delay (RTD) Statistics:\n", rtd->type);
	printf("Filter for statistics: %s\n", rtd->filter ? rtd->filter : "");
	if (rtd_data->stat_table.num_rtds == 1)
	{
		printf("Duplicate requests: %u\n", rtd_data->stat_table.time_stats[0].req_dup_num);
		printf("Duplicate responses: %u\n", rtd_data->stat_table.time_stats[0].rsp_dup_num);
		printf("Open requests: %u\n", rtd_data->stat_table.time_stats[0].open_req_num);
		printf("Discarded responses: %u\n", rtd_data->stat_table.time_stats[0].disc_rsp_num);
		printf("Type    | Messages   |    Min RTD    |    Max RTD    |    Avg RTD    | Min in Frame | Max in Frame |\n");
		for (i=0; i<rtd_data->stat_table.time_stats[0].num_timestat; i++) {
			if (rtd_data->stat_table.time_stats[0].rtd[i].num) {
				tmp_str = val_to_str_wmem(NULL, i, rtd->vs_type, "Other (%d)");
				printf("%s | %7u    | %8.2f msec | %8.2f msec | %8.2f msec |  %10u  |  %10u  |\n",
						tmp_str, rtd_data->stat_table.time_stats[0].rtd[i].num,
						nstime_to_msec(&(rtd_data->stat_table.time_stats[0].rtd[i].min)), nstime_to_msec(&(rtd_data->stat_table.time_stats[0].rtd[i].max)),
						get_average(&(rtd_data->stat_table.time_stats[0].rtd[i].tot), rtd_data->stat_table.time_stats[0].rtd[i].num),
						rtd_data->stat_table.time_stats[0].rtd[i].min_num, rtd_data->stat_table.time_stats[0].rtd[i].max_num
				);
				wmem_free(NULL, tmp_str);
			}
		}
	}
	else
	{
		printf("Type    | Messages   |    Min RTD    |    Max RTD    |    Avg RTD    | Min in Frame | Max in Frame | Open Requests | Discarded responses | Duplicate requests | Duplicate responses\n");
		for (i=0; i<rtd_data->stat_table.num_rtds; i++) {
			for (j=0; j<rtd_data->stat_table.time_stats[i].num_timestat; j++) {
				if (rtd_data->stat_table.time_stats[i].rtd[j].num) {
					tmp_str = val_to_str_wmem(NULL, i, rtd->vs_type, "Other (%d)");
					printf("%s | %7u    | %8.2f msec | %8.2f msec | %8.2f msec |  %10u  |  %10u  |  %10u  |  %10u  | %4u (%4.2f%%) | %4u (%4.2f%%)  |\n",
							tmp_str, rtd_data->stat_table.time_stats[i].rtd[j].num,
							nstime_to_msec(&(rtd_data->stat_table.time_stats[i].rtd[j].min)), nstime_to_msec(&(rtd_data->stat_table.time_stats[i].rtd[j].max)),
							get_average(&(rtd_data->stat_table.time_stats[i].rtd[j].tot), rtd_data->stat_table.time_stats[i].rtd[j].num),
							rtd_data->stat_table.time_stats[i].rtd[j].min_num, rtd_data->stat_table.time_stats[i].rtd[j].max_num,
							rtd_data->stat_table.time_stats[i].open_req_num, rtd_data->stat_table.time_stats[i].disc_rsp_num,
							rtd_data->stat_table.time_stats[i].req_dup_num,
							rtd_data->stat_table.time_stats[i].rtd[j].num?((double)rtd_data->stat_table.time_stats[i].req_dup_num*100)/(double)rtd_data->stat_table.time_stats[i].rtd[j].num:0,
							rtd_data->stat_table.time_stats[i].rsp_dup_num,
							rtd_data->stat_table.time_stats[i].rtd[j].num?((double)rtd_data->stat_table.time_stats[i].rsp_dup_num*100)/(double)rtd_data->stat_table.time_stats[i].rtd[j].num:0
					);
					wmem_free(NULL, tmp_str);
				}
			}
		}
	}
	printf("=====================================================================================================\n");
}
示例#6
0
static gboolean
ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, gchar **err_msg)
{
	const char *slash;
	const char *addr_str;
	char *addr_str_to_free = NULL;
	unsigned int nmask_bits;
	fvalue_t *nmask_fvalue;

	/* Look for prefix: Is there a single slash in the string? */
	slash = strchr(s, '/');
	if (slash) {
		/* Make a copy of the string up to but not including the
		 * slash; that's the address portion. */
		addr_str_to_free = wmem_strndup(NULL, s, slash-s);
		addr_str = addr_str_to_free;
	}
	else
		addr_str = s;

	if (!get_host_ipaddr6(addr_str, &(fv->value.ipv6.addr))) {
		if (err_msg != NULL)
			*err_msg = g_strdup_printf("\"%s\" is not a valid hostname or IPv6 address.", s);
		if (addr_str_to_free)
			wmem_free(NULL, addr_str_to_free);
		return FALSE;
	}

	if (addr_str_to_free)
		wmem_free(NULL, addr_str_to_free);

	/* If prefix */
	if (slash) {
		/* XXX - this is inefficient */
		nmask_fvalue = fvalue_from_unparsed(FT_UINT32, slash+1, FALSE, err_msg);
		if (!nmask_fvalue) {
			return FALSE;
		}
		nmask_bits = fvalue_get_uinteger(nmask_fvalue);
		FVALUE_FREE(nmask_fvalue);

		if (nmask_bits > 128) {
			if (err_msg != NULL) {
				*err_msg = g_strdup_printf("Prefix in a IPv6 address should be <= 128, not %u",
						nmask_bits);
			}
			return FALSE;
		}
		fv->value.ipv6.prefix = nmask_bits;
	} else {
		/* Not CIDR; mask covers entire address. */
		fv->value.ipv6.prefix = 128;
	}

	return TRUE;
}
static void
wmem_simple_allocator_cleanup(void *private_data)
{
    wmem_simple_allocator_t *allocator;

    allocator = (wmem_simple_allocator_t*) private_data;

    wmem_free(NULL, allocator->ptrs);
    wmem_free(NULL, allocator);
}
static void
wmem_block_fast_allocator_cleanup(void *private_data)
{
    wmem_block_fast_allocator_t *allocator = (wmem_block_fast_allocator_t*) private_data;

    /* wmem guarantees that free_all() is called directly before this, so
     * simply free the first block */
    wmem_free(NULL, allocator->block_list);

    /* then just free the allocator structs */
    wmem_free(NULL, private_data);
}
示例#9
0
void oid_add_from_string(const char* name, const gchar *oid_str) {
	guint32* subids;
	guint oid_len = oid_string2subid(NULL, oid_str, &subids);

	if (oid_len) {
		gchar* sub = oid_subid2string(NULL, subids,oid_len);
		D(3,("\tOid (from string): %s %s ",name?name:"NULL", sub));
		add_oid(name,OID_KIND_UNKNOWN,NULL,NULL,oid_len,subids);
		wmem_free(NULL, sub);
	} else {
		D(1,("Failed to add Oid: %s %s ",name?name:"NULL", oid_str?oid_str:NULL));
	}
	wmem_free(NULL, subids);
}
示例#10
0
void
wmem_destroy_list(wmem_list_t *list)
{
    wmem_list_frame_t *cur, *next;

    cur = list->head;

    while (cur) {
        next = cur->next;
        wmem_free(list->allocator, cur);
        cur = next;
    }

    wmem_free(list->allocator, list);
}
示例#11
0
static void
wmem_block_free_all(void *private_data)
{
    wmem_block_allocator_t *allocator = (wmem_block_allocator_t*) private_data;
    wmem_block_hdr_t       *cur;
    wmem_block_chunk_t     *chunk;

    /* the existing free lists are entirely irrelevant */
    allocator->master_head   = NULL;
    allocator->recycler_head = NULL;

    /* iterate through the blocks, reinitializing each one */
    cur = allocator->block_list;

    while (cur) {
        chunk = WMEM_BLOCK_TO_CHUNK(cur);
        if (chunk->jumbo) {
            wmem_block_remove_from_block_list(allocator, cur);
            cur = cur->next;
            wmem_free(NULL, WMEM_CHUNK_TO_BLOCK(chunk));
        }
        else {
            wmem_block_init_block(allocator, cur);
            cur = cur->next;
        }
    }
}
示例#12
0
/*
 * Set the address 2 value in a key.  Remove the original from
 * table, update the options and port values, insert the updated key.
 */
void
conversation_set_addr2(conversation_t *conv, const address *addr)
{
	char* addr_str;
	DISSECTOR_ASSERT_HINT(!(conv->options & CONVERSATION_TEMPLATE),
			"Use the conversation_create_from_template function when the CONVERSATION_TEMPLATE bit is set in the options mask");

	addr_str = address_to_str(NULL, addr);
	DPRINT(("called for addr=%s", addr_str));
	wmem_free(NULL, addr_str);

	/*
	 * If the address 2 value is not wildcarded, don't set it.
	 */
	if (!(conv->options & NO_ADDR2))
		return;

	DINDENT();
	if (conv->options & NO_PORT2) {
		conversation_remove_from_hashtable(conversation_hashtable_no_addr2_or_port2, conv);
	} else {
		conversation_remove_from_hashtable(conversation_hashtable_no_port2, conv);
	}
	conv->options &= ~NO_ADDR2;
	copy_address_wmem(wmem_file_scope(), &conv->key_ptr->addr2, addr);
	if (conv->options & NO_PORT2) {
		conversation_insert_into_hashtable(conversation_hashtable_no_port2, conv);
	} else {
		conversation_insert_into_hashtable(conversation_hashtable_exact, conv);
	}
	DENDENT();
}
示例#13
0
extern void oid_add_from_encoded(const char* name, const guint8 *oid, gint oid_len) {
	guint32* subids = NULL;
	guint subids_len = oid_encoded2subid(NULL, oid, oid_len, &subids);

	if (subids_len) {
		gchar* sub = oid_subid2string(NULL, subids,subids_len);
		D(3,("\tOid (from encoded): %s %s ",name, sub));
		add_oid(name,OID_KIND_UNKNOWN,NULL,NULL,subids_len,subids);
		wmem_free(NULL, sub);
	} else {
		gchar* bytestr = bytestring_to_str(NULL, oid, oid_len, ':');
		D(1,("Failed to add Oid: %s [%d]%s ",name?name:"NULL", oid_len, bytestr));
		wmem_free(NULL, bytestr);
	}
	wmem_free(NULL, subids);
}
示例#14
0
WSLUA_METAMETHOD NSTime__tostring(lua_State* L) {
    NSTime nstime = checkNSTime(L,1);
    gchar *str;
    long secs = (long)nstime->secs;
    gint nsecs = nstime->nsecs;
    gboolean negative_zero = FALSE;

    /* Time is defined as sec + nsec/10^9, both parts can be negative.
     * Translate this into the more familiar sec.nsec notation instead. */
    if (secs > 0 && nsecs < 0) {
        /* sign mismatch: (2, -3ns) -> 1.7 */
        nsecs += NS_PER_S;
        secs--;
    } else if (secs < 0 && nsecs > 0) {
        /* sign mismatch: (-2, 3ns) -> -1.7 */
        nsecs = NS_PER_S - nsecs;
        secs--;
    } else if (nsecs < 0) {
        /* Drop sign, the integer part already has it: (-2, -3ns) -> -2.3 */
        nsecs = -nsecs;
        /* In case the integer part is zero, it does not has a sign, so remember
         * that it must be explicitly added. */
        negative_zero = secs == 0;
    }

    if (negative_zero) {
        str = wmem_strdup_printf(NULL, "-0.%09d", nsecs);
    } else {
        str = wmem_strdup_printf(NULL, "%ld.%09d", secs, nsecs);
    }
    lua_pushstring(L, str);
    wmem_free(NULL, str);

    WSLUA_RETURN(1); /* The string representing the nstime. */
}
示例#15
0
static void
tacplus_print_key_entry( gpointer data, gpointer user_data )
{
	tacplus_key_entry *tacplus_data=(tacplus_key_entry *)data;
	gchar *s_str, *c_str;

	s_str = address_to_str( NULL, tacplus_data->s );
	c_str = address_to_str( NULL, tacplus_data->c );
	if( user_data ) {
		printf("%s:%s=%s\n", s_str, c_str, tacplus_data->k );
	} else {
		printf("%s:%s\n", s_str, c_str );
	}
	wmem_free(NULL, s_str);
	wmem_free(NULL, c_str);
}
void LBMStreamDialog::fillTree(void)
{
    gchar * error_string;

    if (m_capture_file == NULL)
    {
        return;
    }
    m_dialog_info->setDialog(this);

    error_string = register_tap_listener("lbm_stream",
        (void *)m_dialog_info,
        m_ui->displayFilterLineEdit->text().toUtf8().constData(),
        TL_REQUIRES_COLUMNS,
        resetTap,
        tapPacket,
        drawTreeItems);
    if (error_string)
    {
        QMessageBox::critical(this, tr("LBM Stream failed to attach to tap"),
            error_string);
        wmem_free(NULL, error_string);
        reject();
    }

    cf_retap_packets(m_capture_file);
    drawTreeItems(&m_dialog_info);
    remove_tap_listener((void *)m_dialog_info);
}
示例#17
0
/* WSLUA_ATTRIBUTE FieldInfo_label RO The string representing this field. */
WSLUA_METAMETHOD FieldInfo__tostring(lua_State* L) {
    /* The string representation of the field. */
    FieldInfo fi = checkFieldInfo(L,1);

    if (fi->ws_fi->value.ftype->val_to_string_repr) {
        gchar* repr = NULL;

        if (fi->ws_fi->hfinfo->type == FT_PROTOCOL || fi->ws_fi->hfinfo->type == FT_PCRE) {
            repr = fvalue_to_string_repr(NULL, &fi->ws_fi->value,FTREPR_DFILTER,BASE_NONE);
        }
        else {
            repr = fvalue_to_string_repr(NULL, &fi->ws_fi->value,FTREPR_DISPLAY,fi->ws_fi->hfinfo->display);
        }

        if (repr) {
            lua_pushstring(L,repr);
            /* fvalue_to_string_repr() wmem_alloc's the string's buffer */
            wmem_free(NULL, repr);
        }
        else {
            lua_pushstring(L,"(unknown)");
        }
    }
    else if (fi->ws_fi->hfinfo->type == FT_NONE) {
        lua_pushstring(L, "(none)");
    }
    else {
        lua_pushstring(L,"(n/a)");
    }

    return 1;
}
示例#18
0
void packet_range_convert_str(packet_range_t *range, const gchar *es)
{
    range_t *new_range;
    convert_ret_t ret;

    if (range->user_range != NULL)
        wmem_free(NULL, range->user_range);

    g_assert(range->cf != NULL);

    ret = range_convert_str(NULL, &new_range, es, range->cf->count);
    if (ret != CVT_NO_ERROR) {
        /* range isn't valid */
        range->user_range                       = NULL;
        range->user_range_status                = ret;
        range->user_range_cnt                   = 0;
        range->ignored_user_range_cnt           = 0;
        range->displayed_user_range_cnt         = 0;
        range->displayed_ignored_user_range_cnt = 0;
        return;
    }
    range->user_range = new_range;

    /* calculate new user specified packet range counts */
    packet_range_calc_user(range);
} /* packet_range_convert_str */
示例#19
0
gchar *
wmem_strdup_vprintf(wmem_allocator_t *allocator, const gchar *fmt, va_list ap)
{
    va_list ap2;
    gchar *dst;
    int needed_len;

    G_VA_COPY(ap2, ap);

    /* needed_len = g_printf_string_upper_bound(fmt, ap2); */

    dst = (gchar *)wmem_alloc(allocator, WMEM_STRDUP_VPRINTF_DEFAULT_BUFFER);

    /* Returns: the number of characters which would be produced if the buffer was large enough
     * (not including the null, for which we add +1 ourselves). */
    needed_len = g_vsnprintf(dst, (gulong) WMEM_STRDUP_VPRINTF_DEFAULT_BUFFER, fmt, ap2) + 1;
    va_end(ap2);

    if (needed_len > WMEM_STRDUP_VPRINTF_DEFAULT_BUFFER) {
        wmem_free(allocator, dst);
        dst = (gchar *)wmem_alloc(allocator, needed_len);
        G_VA_COPY(ap2, ap);
        g_vsnprintf(dst, (gulong) needed_len, fmt, ap2);
        va_end(ap2);
    }

    return dst;
}
示例#20
0
void
wmem_call_callbacks(wmem_allocator_t *allocator, wmem_cb_event_t event)
{
    wmem_user_cb_container_t **prev, *cur;
    gboolean again;

    prev = &(allocator->callbacks);
    cur  = allocator->callbacks;

    while (cur) {

        /* call it */
        again = cur->cb(allocator, event, cur->user_data);

        /* if the callback requested deregistration, or this is being triggered
         * by the final destruction of the allocator, remove the callback */
        if (! again || event == WMEM_CB_DESTROY_EVENT) {
            *prev = cur->next;
            wmem_free(NULL, cur);
            cur = *prev;
        }
        else {
            prev = &(cur->next);
            cur  = cur->next;
        }
    }
}
示例#21
0
static void
remove_old_requests(ipmi_packet_data_t * data, const nstime_t * curr_time)
{
	wmem_list_frame_t * iter = wmem_list_head(data->request_list);

	while (iter) {
		ipmi_request_t * rq = (ipmi_request_t *) wmem_list_frame_data(iter);
		ipmi_frame_data_t * frame = get_frame_data(data, rq->frame_num);
		nstime_t delta;

		/* calculate time delta */
		nstime_delta(&delta, curr_time, &frame->ts);

		if (nstime_to_msec(&delta) > response_after_req) {
			wmem_list_frame_t * del = iter;

			/* proceed to next request */
			iter = wmem_list_frame_next(iter);

			/* free request data */
			wmem_free(wmem_file_scope(), rq);

			/* remove list item */
			wmem_list_remove_frame(data->request_list, del);
		} else {
			break;
		}
	}
}
示例#22
0
static void
wmem_test_allocator_det(wmem_allocator_t *allocator, wmem_verify_func verify,
        guint len)
{
    int i;
    char *ptrs[MAX_SIMULTANEOUS_ALLOCS];

    /* we use wmem_alloc0 in part because it tests slightly more code, but
     * primarily so that if the allocator doesn't give us enough memory or
     * gives us memory that includes its own metadata, we write to it and
     * things go wrong, causing the tests to fail */
    for (i=0; i<MAX_SIMULTANEOUS_ALLOCS; i++) {
        ptrs[i] = (char *)wmem_alloc0(allocator, len);
    }
    for (i=MAX_SIMULTANEOUS_ALLOCS-1; i>=0; i--) {
        /* no wmem_realloc0 so just use memset manually */
        ptrs[i] = (char *)wmem_realloc(allocator, ptrs[i], 4*len);
        memset(ptrs[i], 0, 4*len);
    }
    for (i=0; i<MAX_SIMULTANEOUS_ALLOCS; i++) {
        wmem_free(allocator, ptrs[i]);
    }

    if (verify) (*verify)(allocator);
    wmem_free_all(allocator);
    wmem_gc(allocator);
    if (verify) (*verify)(allocator);
}
void SequenceDialog::fillDiagram()
{
    if (!sainfo_ || file_closed_) return;

    QCustomPlot *sp = ui->sequencePlot;

    if (sainfo_->type == SEQ_ANALYSIS_VOIP) {
        seq_diagram_->setData(sainfo_);
    } else {
        seq_diagram_->clearData();
        sequence_analysis_list_free(sainfo_);
        sequence_analysis_list_get(cap_file_.capFile(), sainfo_);
        num_items_ = sequence_analysis_get_nodes(sainfo_);
        seq_diagram_->setData(sainfo_);
    }

    QFontMetrics vfm = QFontMetrics(sp->xAxis2->labelFont());
    char* addr_str;
    node_label_w_ = 0;
    for (guint i = 0; i < sainfo_->num_nodes; i++) {
        addr_str = (char*)address_to_display(NULL, &(sainfo_->nodes[i]));
        int label_w = vfm.width(addr_str);
        if (node_label_w_ < label_w) {
            node_label_w_ = label_w;
        }
        wmem_free(NULL, addr_str);
    }
    node_label_w_ = (node_label_w_ * 3 / 4) + one_em_;

    mouseMoved(NULL);
    resetAxes();

    // XXX QCustomPlot doesn't seem to draw any sort of focus indicator.
    sp->setFocus();
}
示例#24
0
static void
relative_val_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_, char *buf)
{
	gchar *rep;
	rep = rel_time_to_secs_str(NULL, &fv->value.time);
	strcpy(buf, rep);
	wmem_free(NULL, rep);
}
示例#25
0
const QString val_ext_to_qstring(const guint32 val, value_string_ext *vse, const char *fmt)
{
    QString val_qstr = QString();
    gchar* gchar_p = val_to_str_ext_wmem(NULL, val, vse, fmt);
    val_qstr = gchar_p;
    wmem_free(NULL, gchar_p);

    return val_qstr;
}
示例#26
0
文件: oids.c 项目: pvons/wireshark
static oid_info_t* add_oid(const char* name, oid_kind_t kind, const oid_value_type_t* type, oid_key_t* key, guint oid_len, guint32 *subids) {
	guint i = 0;
	oid_info_t* c = &oid_root;

	prepopulate_oids();
	oid_len--;

	do {
		oid_info_t* n = (oid_info_t *)wmem_tree_lookup32(c->children,subids[i]);

		if(n) {
			if (i == oid_len) {
				if (n->name) {
					if (!g_str_equal(n->name,name)) {
						D(2,("Renaming Oid from: %s -> %s, this means the same oid is registered more than once",n->name,name));
					}
					wmem_free(wmem_epan_scope(), n->name);
				}

				n->name = wmem_strdup(wmem_epan_scope(), name);

				if (! n->value_type) {
					n->value_type = type;
				}

				return n;
			}
		} else {
			n = wmem_new(wmem_epan_scope(), oid_info_t);
			n->subid = subids[i];
			n->kind = kind;
			n->children = wmem_tree_new(wmem_epan_scope());
			n->value_hfid = -2;
			n->key = key;
			n->parent = c;
			n->bits = NULL;

			wmem_tree_insert32(c->children,n->subid,n);

			if (i == oid_len) {
				n->name = wmem_strdup(wmem_epan_scope(), name);
				n->value_type = type;
				n->kind = kind;
				return n;
			} else {
				n->name = NULL;
				n->value_type = NULL;
				n->kind = OID_KIND_UNKNOWN;
			}
		}
		c = n;
	} while(++i);

	g_assert_not_reached();
	return NULL;
}
示例#27
0
const QString address_to_display_qstring(const _address *address)
{
    QString address_qstr = QString();
    if (address) {
        gchar *address_gchar_p = address_to_display(NULL, address);
        address_qstr = address_gchar_p;
        wmem_free(NULL, address_gchar_p);
    }
    return address_qstr;
}
示例#28
0
const QString range_to_qstring(const epan_range *range)
{
    QString range_qstr = QString();
    if (range) {
        gchar *range_gchar_p = range_convert_range(NULL, range);
        range_qstr = range_gchar_p;
        wmem_free(NULL, range_gchar_p);
    }
    return range_qstr;
}
static void
wmem_strict_allocator_cleanup(void *private_data)
{
    wmem_strict_allocator_t *allocator;

    allocator = (wmem_strict_allocator_t*) private_data;

    g_hash_table_destroy(allocator->block_table);
    wmem_free(NULL, allocator);
}
示例#30
0
WSLUA_METAMETHOD NSTime__tostring(lua_State* L) {
    NSTime nstime = checkNSTime(L,1);
    gchar *str;

    str = wmem_strdup_printf(NULL, "%ld.%09d", (long)nstime->secs, nstime->nsecs);
    lua_pushstring(L, str);
    wmem_free(NULL, str);

    WSLUA_RETURN(1); /* The string representing the nstime. */
}