本文整理汇总了C++中wmem_free函数的典型用法代码示例。如果您正苦于以下问题:C++ wmem_free函数的具体用法?C++ wmem_free怎么用?C++ wmem_free使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wmem_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wmem_test_allocator_jumbo
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: ct_port_to_str
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;
}
示例3: wmem_block_fast_free_all
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;
}
示例4: wmem_strict_block_free
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: rtd_draw
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: ipv6_from_unparsed
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;
}
示例7: wmem_simple_allocator_cleanup
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);
}
示例8: wmem_block_fast_allocator_cleanup
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: oid_add_from_string
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: wmem_destroy_list
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: wmem_block_free_all
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: conversation_set_addr2
/*
* 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: oid_add_from_encoded
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: NSTime__tostring
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: tacplus_print_key_entry
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);
}