本文整理汇总了C++中GNUNET_free_non_null函数的典型用法代码示例。如果您正苦于以下问题:C++ GNUNET_free_non_null函数的具体用法?C++ GNUNET_free_non_null怎么用?C++ GNUNET_free_non_null使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GNUNET_free_non_null函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cleanup
/**
* Assuming all peers have been destroyed cleanup run handle
*
* @param rc the run context
*/
static void
cleanup (struct GNUNET_TESTBED_RunHandle *rc)
{
unsigned int hid;
GNUNET_assert (NULL == rc->register_hosts_task);
GNUNET_assert (NULL == rc->reg_handle);
GNUNET_assert (NULL == rc->peers);
GNUNET_assert (NULL == rc->hclist);
GNUNET_assert (RC_PEERS_SHUTDOWN == rc->state);
GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap32_size (rc->rcop_map));
GNUNET_CONTAINER_multihashmap32_destroy (rc->rcop_map);
if (NULL != rc->c)
GNUNET_TESTBED_controller_disconnect (rc->c);
if (NULL != rc->cproc)
GNUNET_TESTBED_controller_stop (rc->cproc);
if (NULL != rc->h)
GNUNET_TESTBED_host_destroy (rc->h);
for (hid = 0; hid < rc->num_hosts; hid++)
GNUNET_TESTBED_host_destroy (rc->hosts[hid]);
GNUNET_free_non_null (rc->hosts);
if (NULL != rc->cfg)
GNUNET_CONFIGURATION_destroy (rc->cfg);
GNUNET_free_non_null (rc->topo_file);
GNUNET_free_non_null (rc->trusted_ip);
GNUNET_free (rc);
}
示例2: terminate_task
static void
terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_CORE_Handle *ch;
err_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_STATISTICS_destroy (p1.stats, GNUNET_NO);
GNUNET_STATISTICS_destroy (p2.stats, GNUNET_NO);
GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
if (p1.nth != NULL)
{
GNUNET_CORE_notify_transmit_ready_cancel (p1.nth);
p1.nth = NULL;
}
if (connect_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (connect_task);
connect_task = GNUNET_SCHEDULER_NO_TASK;
}
ch = p1.ch;
p1.ch = NULL;
GNUNET_CORE_disconnect (ch);
ch = p2.ch;
p2.ch = NULL;
GNUNET_CORE_disconnect (ch);
GNUNET_TRANSPORT_disconnect (p1.th);
p1.th = NULL;
GNUNET_TRANSPORT_disconnect (p2.th);
p2.th = NULL;
GNUNET_free_non_null (p1.hello);
GNUNET_free_non_null (p2.hello);
}
示例3: do_shutdown
void
do_shutdown (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
unsigned int ca;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
if (NULL != mlp)
{
GAS_mlp_done (mlp);
mlp = NULL;
}
if (NULL != a)
{
for (ca=0; ca < (peers * addresses); ca++)
{
GNUNET_free (a[ca].plugin);
GNUNET_free (a[ca].ats);
}
}
if (NULL != amap)
GNUNET_CONTAINER_multihashmap_destroy(amap);
GNUNET_free_non_null (a);
GNUNET_free_non_null (p);
}
示例4: end
static void
end ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
if (die_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (die_task);
die_task = GNUNET_SCHEDULER_NO_TASK;
}
if (NULL != atsh)
GNUNET_ATS_scheduling_done (atsh);
if (phal != NULL)
GNUNET_ATS_performance_list_addresses_cancel (phal);
phal = NULL;
if (ph != NULL)
GNUNET_ATS_performance_done (ph);
ph = NULL;
GNUNET_free_non_null (p0_addresses[0].addr);
GNUNET_free_non_null (p0_addresses[1].addr);
GNUNET_free_non_null (p1_addresses[0].addr);
GNUNET_free_non_null (p1_addresses[1].addr);
ret = 0;
}
示例5: GNUNET_DNSPARSER_free_record
/**
* Free the given DNS record.
*
* @param r record to free
*/
void
GNUNET_DNSPARSER_free_record (struct GNUNET_DNSPARSER_Record *r)
{
GNUNET_free_non_null (r->name);
switch (r->type)
{
case GNUNET_DNSPARSER_TYPE_MX:
GNUNET_DNSPARSER_free_mx (r->data.mx);
break;
case GNUNET_DNSPARSER_TYPE_SOA:
GNUNET_DNSPARSER_free_soa (r->data.soa);
break;
case GNUNET_DNSPARSER_TYPE_SRV:
GNUNET_DNSPARSER_free_srv (r->data.srv);
break;
case GNUNET_DNSPARSER_TYPE_CERT:
GNUNET_DNSPARSER_free_cert (r->data.cert);
break;
case GNUNET_DNSPARSER_TYPE_NS:
case GNUNET_DNSPARSER_TYPE_CNAME:
case GNUNET_DNSPARSER_TYPE_PTR:
GNUNET_free_non_null (r->data.hostname);
break;
default:
GNUNET_free_non_null (r->data.raw.data);
break;
}
}
示例6: test_service_configuration
/**
* Try connecting to the server using UNIX domain sockets.
*
* @param service_name name of service to connect to
* @param cfg configuration to use
* @return GNUNET_OK if the configuration is valid, GNUNET_SYSERR if not
*/
static int
test_service_configuration (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
int ret = GNUNET_SYSERR;
char *hostname = NULL;
unsigned long long port;
#if AF_UNIX
char *unixpath = NULL;
if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "UNIXPATH", &unixpath)) &&
(0 < strlen (unixpath)))
ret = GNUNET_OK;
GNUNET_free_non_null (unixpath);
#endif
if ( (GNUNET_YES ==
GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT")) &&
(GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_number (cfg, service_name, "PORT", &port)) &&
(port <= 65535) && (0 != port) &&
(GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (cfg, service_name, "HOSTNAME",
&hostname)) &&
(0 != strlen (hostname)) )
ret = GNUNET_OK;
GNUNET_free_non_null (hostname);
return ret;
}
示例7: oprelease_get_stats
/**
* Function called when get_statistics operation is cancelled or marked as done
*
* @param cls the GetStatsContext
*/
static void
oprelease_get_stats (void *cls)
{
struct GetStatsContext *sc = cls;
unsigned int peer;
LOG_DEBUG ("Cleaning up get_statistics operation\n");
if (NULL != sc->call_completion_task_id)
GNUNET_SCHEDULER_cancel (sc->call_completion_task_id);
if (NULL != sc->ops)
{
for (peer = 0; peer < sc->num_peers; peer++)
{
if (NULL != sc->ops[peer])
{
GNUNET_TESTBED_operation_done (sc->ops[peer]);
sc->ops[peer] = NULL;
}
}
GNUNET_free (sc->ops);
}
GNUNET_free_non_null (sc->subsystem);
GNUNET_free_non_null (sc->name);
GNUNET_free (sc);
if (GNUNET_YES ==
GNUNET_TESTBED_operation_queue_destroy_empty_ (no_wait_queue))
no_wait_queue = NULL;
}
示例8: add_host_to_known_hosts
/**
* Add a host to the list and notify clients about this event
*
* @param identity the identity of the host
* @return the HostEntry
*/
static struct HostEntry *
add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
{
struct HostEntry *entry;
struct ReadHostFileContext r;
char *fn;
entry = GNUNET_CONTAINER_multipeermap_get (hostmap, identity);
if (NULL == entry)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding new peer `%s'\n", GNUNET_i2s (identity));
GNUNET_STATISTICS_update (stats, gettext_noop ("# peers known"), 1,
GNUNET_NO);
entry = GNUNET_new (struct HostEntry);
entry->identity = *identity;
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multipeermap_put (hostmap, &entry->identity, entry,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
notify_all (entry);
fn = get_host_filename (identity);
if (NULL != fn)
{
read_host_file (fn, GNUNET_YES, &r);
if (NULL != r.hello)
update_hello (identity, r.hello);
if (NULL != r.friend_only_hello)
update_hello (identity, r.friend_only_hello);
GNUNET_free_non_null (r.hello);
GNUNET_free_non_null (r.friend_only_hello);
GNUNET_free (fn);
}
}
示例9: send_shorten_response
/**
* Send shorten response back to client
*
* @param cls the closure containing a client shorten handle
* @param name the shortened name result or NULL if cannot be shortened
*/
static void
send_shorten_response(void* cls, const char* name)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n",
"SHORTEN_RESULT", name);
struct GNUNET_GNS_ClientShortenResultMessage *rmsg;
struct ClientShortenHandle *csh = (struct ClientShortenHandle *)cls;
if (name == NULL)
{
name = "";
}
rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientShortenResultMessage)
+ strlen(name) + 1);
rmsg->id = csh->unique_id;
rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT);
rmsg->header.size =
htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) +
strlen(name) + 1);
strcpy((char*)&rmsg[1], name);
GNUNET_SERVER_notification_context_unicast (nc, csh->client,
(const struct GNUNET_MessageHeader *) rmsg,
GNUNET_NO);
GNUNET_SERVER_receive_done (csh->client, GNUNET_OK);
GNUNET_free(rmsg);
GNUNET_free_non_null(csh->name);
GNUNET_free_non_null(csh->zone_key);
GNUNET_free(csh);
}
示例10: shutdown_task
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct SysmonProperty *sp;
struct SysmonProperty *next;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "sysdaemon stopping ... \n");
end_task = GNUNET_SCHEDULER_NO_TASK;
if (NULL != stats)
{
GNUNET_STATISTICS_destroy (stats, GNUNET_YES);
stats = NULL;
}
next = sp_head;
while (NULL != (sp = next))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping `%s' \n", sp->desc);
GNUNET_CONTAINER_DLL_remove (sp_head, sp_tail, sp);
next = sp->next;
if (GNUNET_SCHEDULER_NO_TASK != sp->task_id)
{
GNUNET_SCHEDULER_cancel (sp->task_id);
sp->task_id = GNUNET_SCHEDULER_NO_TASK;
}
GNUNET_free_non_null (sp->cmd);
GNUNET_free_non_null (sp->cmd_args);
GNUNET_free (sp->desc);
GNUNET_free (sp);
}
}
示例11: main
/**
* The main function.
*
* @param argc number of arguments from the command line
* @param argv command line arguments
* @return 0 ok, 1 on error
*/
int
main (int argc, char *const *argv)
{
int res;
resolve_addresses_numeric = GNUNET_NO;
op_monitor = GNUNET_NO;
op_list_all = GNUNET_NO;
op_list_used = GNUNET_NO;
op_set_pref = GNUNET_NO;
pending = 0;
receive_done = GNUNET_NO;
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'u', "used", NULL,
gettext_noop ("get list of active addresses currently used"),
0, &GNUNET_GETOPT_set_one, &op_list_used},
{'a', "all", NULL,
gettext_noop ("get list of all active addresses"),
0, &GNUNET_GETOPT_set_one, &op_list_all},
{'n', "numeric", NULL,
gettext_noop ("do not resolve IP addresses to hostnames"),
0, &GNUNET_GETOPT_set_one, &resolve_addresses_numeric},
{'m', "monitor", NULL,
gettext_noop ("monitor mode"),
0, &GNUNET_GETOPT_set_one, &op_monitor},
{'p', "preference", NULL,
gettext_noop ("set preference for the given peer"),
0, &GNUNET_GETOPT_set_one, &op_set_pref},
{'i', "id", "TYPE",
gettext_noop ("peer id"),
1, &GNUNET_GETOPT_set_string, &pid_str},
{'t', "type", "TYPE",
gettext_noop ("preference type to set: latency | bandwidth"),
1, &GNUNET_GETOPT_set_string, &type_str},
{'k', "value", "VALUE",
gettext_noop ("preference value"),
1, &GNUNET_GETOPT_set_uint, &value},
{'V', "verbose", NULL,
gettext_noop ("verbose output (include ATS address properties)"),
0, &GNUNET_GETOPT_set_one, &verbose},
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
res = GNUNET_PROGRAM_run (argc, argv, "gnunet-ats",
gettext_noop ("Print information about ATS state"), options, &run,
NULL);
GNUNET_free_non_null (pid_str);
GNUNET_free_non_null (type_str);
GNUNET_free ((void *) argv);
if (GNUNET_OK == res)
return ret;
else
return 1;
}
示例12: GNUNET_FS_file_information_destroy
/**
* Destroy publish-structure. Clients should never destroy publish
* structures that were passed to #GNUNET_FS_publish_start already.
*
* @param fi structure to destroy
* @param cleaner function to call on each entry in the structure
* (useful to clean up client_info); can be NULL; return
* values are ignored
* @param cleaner_cls closure for @a cleaner
*/
void
GNUNET_FS_file_information_destroy (struct GNUNET_FS_FileInformation *fi,
GNUNET_FS_FileInformationProcessor cleaner,
void *cleaner_cls)
{
struct GNUNET_FS_FileInformation *pos;
int no;
no = GNUNET_NO;
if (GNUNET_YES == fi->is_directory)
{
/* clean up directory */
while (NULL != (pos = fi->data.dir.entries))
{
fi->data.dir.entries = pos->next;
GNUNET_FS_file_information_destroy (pos, cleaner, cleaner_cls);
}
/* clean up client-info */
if (NULL != cleaner)
cleaner (cleaner_cls, fi, fi->data.dir.dir_size, fi->meta, &fi->keywords,
&fi->bo, &no, &fi->client_info);
GNUNET_free_non_null (fi->data.dir.dir_data);
}
else
{
/* call clean-up function of the reader */
if (NULL != fi->data.file.reader)
{
(void) fi->data.file.reader (fi->data.file.reader_cls, 0, 0, NULL, NULL);
fi->data.file.reader = NULL;
}
/* clean up client-info */
if (NULL != cleaner)
cleaner (cleaner_cls, fi, fi->data.file.file_size, fi->meta,
&fi->keywords, &fi->bo, &fi->data.file.do_index,
&fi->client_info);
}
GNUNET_free_non_null (fi->filename);
GNUNET_free_non_null (fi->emsg);
if (NULL != fi->sks_uri)
GNUNET_FS_uri_destroy (fi->sks_uri);
if (NULL != fi->chk_uri)
GNUNET_FS_uri_destroy (fi->chk_uri);
/* clean up serialization */
if ((NULL != fi->serialization) && (0 != UNLINK (fi->serialization)))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
fi->serialization);
if (NULL != fi->keywords)
GNUNET_FS_uri_destroy (fi->keywords);
if (NULL != fi->meta)
GNUNET_CONTAINER_meta_data_destroy (fi->meta);
GNUNET_free_non_null (fi->serialization);
if (NULL != fi->te)
{
GNUNET_FS_tree_encoder_finish (fi->te, NULL);
fi->te = NULL;
}
GNUNET_free (fi);
}
示例13: meta_item_free
/**
* Free meta data item.
*
* @param item item to free
*/
static void
meta_item_free (struct MetaItem *item)
{
GNUNET_free_non_null (item->plugin_name);
GNUNET_free_non_null (item->mime_type);
GNUNET_free_non_null (item->data);
GNUNET_free (item);
}
示例14: GNUNET_FS_unindex_signal_suspend_
/**
* Create SUSPEND event for the given unindex operation
* and then clean up our state (without stop signal).
*
* @param cls the `struct GNUNET_FS_UnindexContext` to signal for
*/
void
GNUNET_FS_unindex_signal_suspend_ (void *cls)
{
struct GNUNET_FS_UnindexContext *uc = cls;
struct GNUNET_FS_ProgressInfo pi;
/* FIXME: lots of duplication with unindex_stop here! */
if (uc->dscan != NULL)
{
GNUNET_FS_directory_scan_abort (uc->dscan);
uc->dscan = NULL;
}
if (NULL != uc->dqe)
{
GNUNET_DATASTORE_cancel (uc->dqe);
uc->dqe = NULL;
}
if (uc->fhc != NULL)
{
GNUNET_CRYPTO_hash_file_cancel (uc->fhc);
uc->fhc = NULL;
}
if (NULL != uc->ksk_uri)
{
GNUNET_FS_uri_destroy (uc->ksk_uri);
uc->ksk_uri = NULL;
}
if (uc->client != NULL)
{
GNUNET_CLIENT_disconnect (uc->client);
uc->client = NULL;
}
if (NULL != uc->dsh)
{
GNUNET_DATASTORE_disconnect (uc->dsh, GNUNET_NO);
uc->dsh = NULL;
}
if (NULL != uc->tc)
{
GNUNET_FS_tree_encoder_finish (uc->tc, NULL);
uc->tc = NULL;
}
if (uc->fh != NULL)
{
GNUNET_DISK_file_close (uc->fh);
uc->fh = NULL;
}
GNUNET_FS_end_top (uc->h, uc->top);
pi.status = GNUNET_FS_STATUS_UNINDEX_SUSPEND;
GNUNET_FS_unindex_make_status_ (&pi, uc,
(uc->state ==
UNINDEX_STATE_COMPLETE) ? uc->file_size : 0);
GNUNET_break (NULL == uc->client_info);
GNUNET_free (uc->filename);
GNUNET_free_non_null (uc->serialization);
GNUNET_free_non_null (uc->emsg);
GNUNET_free (uc);
}
示例15: GNUNET_CONNECTION_destroy
/**
* Close the connection and free associated resources. There must
* not be any pending requests for reading or writing to the
* connection at this time.
*
* @param connection connection to destroy
*/
void
GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection)
{
struct AddressProbe *pos;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connection (%p)\n", connection);
GNUNET_assert (NULL == connection->nth.notify_ready);
GNUNET_assert (NULL == connection->receiver);
if (GNUNET_SCHEDULER_NO_TASK != connection->write_task)
{
GNUNET_SCHEDULER_cancel (connection->write_task);
connection->write_task = GNUNET_SCHEDULER_NO_TASK;
connection->write_buffer_off = 0;
}
if (GNUNET_SCHEDULER_NO_TASK != connection->read_task)
{
GNUNET_SCHEDULER_cancel (connection->read_task);
connection->read_task = GNUNET_SCHEDULER_NO_TASK;
}
if (GNUNET_SCHEDULER_NO_TASK != connection->nth.timeout_task)
{
GNUNET_SCHEDULER_cancel (connection->nth.timeout_task);
connection->nth.timeout_task = GNUNET_SCHEDULER_NO_TASK;
}
connection->nth.notify_ready = NULL;
if (NULL != connection->dns_active)
{
GNUNET_RESOLVER_request_cancel (connection->dns_active);
connection->dns_active = NULL;
}
while (NULL != (pos = connection->ap_head))
{
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
GNUNET_SCHEDULER_cancel (pos->task);
GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, pos);
GNUNET_free (pos);
}
if ( (NULL != connection->sock) &&
(GNUNET_YES != connection->persist) )
{
if ((GNUNET_YES != GNUNET_NETWORK_socket_shutdown (connection->sock, SHUT_RDWR)) &&
(ENOTCONN != errno) &&
(ECONNRESET != errno) )
LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "shutdown");
}
if (NULL != connection->sock)
{
if (GNUNET_YES != connection->persist)
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (connection->sock));
else
GNUNET_free (connection->sock); /* at least no memory leak (we deliberately
* leak the socket in this special case) ... */
}
GNUNET_free_non_null (connection->addr);
GNUNET_free_non_null (connection->hostname);
GNUNET_free (connection->write_buffer);
GNUNET_free (connection);
}