From e0ca7357cd0bfedc5c29cb731b56279fef8da059 Mon Sep 17 00:00:00 2001 From: LRN Date: Thu, 19 Dec 2013 06:00:23 +0000 Subject: malloc -> new --- src/arm/arm_api.c | 4 +-- src/arm/arm_monitor_api.c | 2 +- src/arm/test_exponential_backoff.c | 2 +- src/ats-tests/perf_ats_logging.c | 2 +- src/ats/ats_api_performance.c | 6 ++-- src/ats/ats_api_scheduling.c | 4 +-- src/ats/gnunet-service-ats_addresses.c | 6 ++-- src/ats/gnunet-service-ats_normalization.c | 4 +-- src/ats/gnunet-service-ats_performance.c | 2 +- src/ats/perf_ats_solver.c | 2 +- src/ats/plugin_ats_mlp.c | 4 +-- src/ats/plugin_ats_proportional.c | 6 ++-- src/ats/plugin_ats_ril.c | 4 +-- src/ats/test_ats_api_bandwidth_consumption.c | 4 +-- src/block/plugin_block_template.c | 2 +- src/consensus/consensus_api.c | 2 +- src/core/gnunet-service-core_clients.c | 2 +- src/core/gnunet-service-core_sessions.c | 2 +- src/core/gnunet-service-core_typemap.c | 8 ++--- src/datacache/datacache.c | 2 +- src/datacache/plugin_datacache_heap.c | 4 +-- src/datacache/plugin_datacache_postgres.c | 4 +-- src/datacache/plugin_datacache_sqlite.c | 4 +-- src/datacache/plugin_datacache_template.c | 4 +-- src/datastore/gnunet-service-datastore.c | 8 ++--- src/datastore/perf_datastore_api.c | 2 +- src/datastore/perf_plugin_datastore.c | 2 +- src/datastore/plugin_datastore_heap.c | 6 ++-- src/datastore/plugin_datastore_mysql.c | 4 +-- src/datastore/plugin_datastore_postgres.c | 4 +-- src/datastore/plugin_datastore_sqlite.c | 2 +- src/datastore/plugin_datastore_template.c | 4 +-- src/datastore/test_datastore_api.c | 2 +- src/datastore/test_datastore_api_management.c | 2 +- src/datastore/test_plugin_datastore.c | 2 +- src/dht/dht_test_lib.c | 2 +- src/dht/gnunet-service-dht_clients.c | 4 +-- src/dht/gnunet-service-dht_neighbours.c | 2 +- src/dht/gnunet-service-xdht_clients.c | 4 +-- src/dht/gnunet-service-xdht_neighbours.c | 2 +- src/dht/plugin_block_dht.c | 2 +- src/dht/test_dht_monitor.c | 2 +- src/dht/test_dht_topo.c | 2 +- src/dns/dns_api.c | 4 +-- src/dns/dnsstub.c | 2 +- src/dns/gnunet-service-dns.c | 2 +- src/env/env.c | 2 +- .../gnunet-daemon-experimentation_nodes.c | 4 +-- .../gnunet-daemon-experimentation_scheduler.c | 2 +- src/fragmentation/defragmentation.c | 2 +- src/fs/fs_api.c | 10 +++--- src/fs/fs_directory.c | 2 +- src/fs/fs_dirmetascan.c | 2 +- src/fs/fs_download.c | 2 +- src/fs/fs_file_information.c | 4 +-- src/fs/fs_getopt.c | 2 +- src/fs/fs_list_indexed.c | 2 +- src/fs/fs_test_lib.c | 4 +-- src/fs/fs_tree.c | 4 +-- src/fs/fs_unindex.c | 2 +- src/fs/gnunet-auto-share.c | 4 +-- src/fs/gnunet-helper-fs-publish.c | 2 +- src/fs/gnunet-service-fs_pr.c | 4 +-- src/fs/perf_gnunet_service_fs_p2p.c | 2 +- src/fs/perf_gnunet_service_fs_p2p_respect.c | 2 +- src/fs/test_gnunet_service_fs_migration.c | 2 +- src/gns/gnunet-dns2gns.c | 2 +- src/gns/gnunet-gns-helper-service-w32.c | 4 +-- src/gnsrecord/plugin_gnsrecord_dns.c | 4 +-- src/hostlist/hostlist-server.c | 2 +- src/mesh/gnunet-service-mesh_local.c | 4 +-- src/mesh/gnunet-service-mesh_peer.c | 2 +- src/mesh/mesh_api.c | 6 ++-- src/mesh/mesh_path.c | 2 +- src/mesh/mesh_test_lib.c | 4 +-- src/mesh/mesh_tunnel_tree.c | 12 +++---- src/mysql/mysql.c | 4 +-- src/namestore/gnunet-namestore-fcfsd.c | 2 +- src/nat/gnunet-nat-server.c | 2 +- src/nat/nat_mini.c | 4 +-- src/nse/gnunet-nse-profiler.c | 4 +-- src/peerinfo-tool/gnunet-peerinfo.c | 2 +- src/peerinfo-tool/gnunet-peerinfo_plugins.c | 2 +- src/peerinfo/gnunet-service-peerinfo.c | 2 +- src/peerinfo/peerinfo_api.c | 4 +-- src/peerinfo/peerinfo_api_notify.c | 2 +- src/regex/gnunet-regex-simulation-profiler.c | 2 +- src/regex/plugin_block_regex.c | 2 +- src/regex/regex_internal.c | 14 ++++---- src/regex/regex_internal_dht.c | 8 ++--- src/regex/regex_test_lib.c | 8 ++--- src/set/ibf.c | 2 +- src/set/strata_estimator.c | 4 +-- src/statistics/statistics_api.c | 10 +++--- src/testbed/gnunet-helper-testbed.c | 2 +- src/testbed/gnunet-service-testbed-logger.c | 2 +- src/testbed/gnunet-service-testbed.c | 6 ++-- src/testbed/gnunet-service-testbed_barriers.c | 8 ++--- src/testbed/gnunet-service-testbed_cache.c | 2 +- src/testbed/gnunet-service-testbed_links.c | 18 +++++----- src/testbed/gnunet-service-testbed_oc.c | 14 ++++---- src/testbed/testbed_api.c | 28 +++++++-------- src/testbed/testbed_api_barriers.c | 4 +-- src/testbed/testbed_api_hosts.c | 10 +++--- src/testbed/testbed_api_operations.c | 10 +++--- src/testbed/testbed_api_peers.c | 40 +++++++++++----------- src/testbed/testbed_api_sd.c | 4 +-- src/testbed/testbed_api_services.c | 2 +- src/testbed/testbed_api_statistics.c | 4 +-- src/testbed/testbed_api_testbed.c | 10 +++--- src/testbed/testbed_api_topology.c | 4 +-- src/testbed/testbed_logger_api.c | 4 +-- src/testing/test_testing_peerstartup.c | 2 +- src/testing/test_testing_peerstartup2.c | 2 +- src/testing/test_testing_sharedservices.c | 2 +- src/testing/testing.c | 8 ++--- src/topology/gnunet-daemon-topology.c | 2 +- src/transport/gnunet-service-transport_blacklist.c | 6 ++-- src/transport/gnunet-service-transport_clients.c | 2 +- src/transport/gnunet-service-transport_hello.c | 2 +- .../gnunet-service-transport_manipulation.c | 4 +-- .../gnunet-service-transport_validation.c | 2 +- src/transport/plugin_transport_bluetooth.c | 14 ++++---- src/transport/plugin_transport_http_common.c | 4 +-- src/transport/plugin_transport_http_server.c | 6 ++-- src/transport/plugin_transport_smtp.c | 4 +-- src/transport/plugin_transport_tcp.c | 4 +-- src/transport/plugin_transport_udp.c | 6 ++-- src/transport/plugin_transport_udp_broadcasting.c | 4 +-- src/transport/plugin_transport_wlan.c | 14 ++++---- src/transport/transport-testing.c | 6 ++-- src/transport/transport_api_address_lookup.c | 2 +- src/transport/transport_api_address_to_string.c | 2 +- src/transport/transport_api_blacklist.c | 2 +- src/util/common_logging.c | 2 +- src/util/container_bloomfilter.c | 4 +-- src/util/container_heap.c | 4 +-- src/util/container_slist.c | 4 +-- src/util/disk.c | 20 +++++------ src/util/os_priority.c | 4 +-- src/util/peer.c | 2 +- src/util/server_tc.c | 2 +- src/util/signal.c | 2 +- src/util/test_client.c | 2 +- src/util/test_container_slist.c | 2 +- 145 files changed, 326 insertions(+), 326 deletions(-) (limited to 'src') diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 7e6ce1870..6c0dec4a6 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c @@ -636,7 +636,7 @@ GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, { struct GNUNET_ARM_Handle *h; - h = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle)); + h = GNUNET_new (struct GNUNET_ARM_Handle); h->cfg = GNUNET_CONFIGURATION_dup (cfg); h->currently_down = GNUNET_YES; h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; @@ -1067,7 +1067,7 @@ GNUNET_ARM_request_service_list (struct GNUNET_ARM_Handle *h, LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting LIST from ARM service with timeout: %s\n", GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES)); - cm = GNUNET_malloc (sizeof (struct ARMControlMessage)); + cm = GNUNET_new (struct ARMControlMessage); cm->h = h; cm->list_cont = cont; cm->cont_cls = cont_cls; diff --git a/src/arm/arm_monitor_api.c b/src/arm/arm_monitor_api.c index 7b403fde8..676543f26 100644 --- a/src/arm/arm_monitor_api.c +++ b/src/arm/arm_monitor_api.c @@ -251,7 +251,7 @@ GNUNET_ARM_monitor (const struct GNUNET_CONFIGURATION_Handle *cfg, { struct GNUNET_ARM_MonitorHandle *h; - h = GNUNET_malloc (sizeof (struct GNUNET_ARM_MonitorHandle)); + h = GNUNET_new (struct GNUNET_ARM_MonitorHandle); h->cfg = GNUNET_CONFIGURATION_dup (cfg); h->currently_down = GNUNET_YES; h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 0561c3ea8..7a552cc7c 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c @@ -214,7 +214,7 @@ do_nothing_service_shutdown (struct GNUNET_CLIENT_Connection *sock, { struct ShutdownContext *shutdown_ctx; - shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext)); + shutdown_ctx = GNUNET_new (struct ShutdownContext); shutdown_ctx->cont = cont; shutdown_ctx->cont_cls = cont_cls; shutdown_ctx->sock = sock; diff --git a/src/ats-tests/perf_ats_logging.c b/src/ats-tests/perf_ats_logging.c index 6dc5a96b4..823cfaf38 100644 --- a/src/ats-tests/perf_ats_logging.c +++ b/src/ats-tests/perf_ats_logging.c @@ -513,7 +513,7 @@ collect_log_now (void) for (c_m = 0; c_m < num_peers; c_m++) { bp = &lp[c_m]; - mlt = GNUNET_malloc (sizeof (struct PeerLoggingTimestep)); + mlt = GNUNET_new (struct PeerLoggingTimestep); GNUNET_CONTAINER_DLL_insert_tail(bp->head, bp->tail, mlt); prev_log_mlt = mlt->prev; diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c index 390531d9f..90e061c1d 100644 --- a/src/ats/ats_api_performance.c +++ b/src/ats/ats_api_performance.c @@ -628,7 +628,7 @@ GNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, { struct GNUNET_ATS_PerformanceHandle *ph; - ph = GNUNET_malloc (sizeof (struct GNUNET_ATS_PerformanceHandle)); + ph = GNUNET_new (struct GNUNET_ATS_PerformanceHandle); ph->cfg = cfg; ph->addr_info_cb = addr_info_cb; ph->addr_info_cb_cls = addr_info_cb_cls; @@ -703,7 +703,7 @@ GNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph, struct PendingMessage *p; struct ReservationRequestMessage *m; - rc = GNUNET_malloc (sizeof (struct GNUNET_ATS_ReservationContext)); + rc = GNUNET_new (struct GNUNET_ATS_ReservationContext); rc->size = amount; rc->peer = *peer; rc->rcb = rcb; @@ -763,7 +763,7 @@ GNUNET_ATS_performance_list_addresses ( if (NULL == infocb) return NULL ; - alh = GNUNET_malloc (sizeof (struct GNUNET_ATS_AddressListHandle)); + alh = GNUNET_new (struct GNUNET_ATS_AddressListHandle); alh->id = handle->id; handle->id++; alh->cb = infocb; diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 1ef6ce095..7750ad1cf 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c @@ -967,7 +967,7 @@ GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg, { struct GNUNET_ATS_SchedulingHandle *sh; - sh = GNUNET_malloc (sizeof (struct GNUNET_ATS_SchedulingHandle)); + sh = GNUNET_new (struct GNUNET_ATS_SchedulingHandle); sh->cfg = cfg; sh->suggest_cb = suggest_cb; sh->suggest_cb_cls = suggest_cb_cls; @@ -1083,7 +1083,7 @@ GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh, m->peer = *peer; GNUNET_CONTAINER_DLL_insert_tail (sh->pending_head, sh->pending_tail, p); do_transmit (sh); - s = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestHandle)); + s = GNUNET_new (struct GNUNET_ATS_SuggestHandle); s->id = (*peer); GNUNET_CONTAINER_DLL_insert_tail (sh->sug_head, sh->sug_tail, s); return s; diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index ddcff962b..2cdc12766 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c @@ -1240,7 +1240,7 @@ GAS_addresses_request_address (struct GAS_Addresses_Handle *handle, } if (NULL == cur) { - cur = GNUNET_malloc (sizeof (struct GAS_Addresses_Suggestion_Requests)); + cur = GNUNET_new (struct GAS_Addresses_Suggestion_Requests); cur->id = (*peer); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding new address suggestion request for `%s'\n", @@ -1836,7 +1836,7 @@ GAS_addresses_preference_change (struct GAS_Addresses_Handle *handle, if (NULL == find_preference_client (handle, client)) { - pc = GNUNET_malloc (sizeof (struct GAS_Addresses_Preference_Clients)); + pc = GNUNET_new (struct GAS_Addresses_Preference_Clients); pc->client = client; GNUNET_CONTAINER_DLL_insert (handle->preference_clients_head, handle->preference_clients_tail, pc); @@ -2091,7 +2091,7 @@ GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg, char *plugin_short; int c; - ah = GNUNET_malloc (sizeof (struct GAS_Addresses_Handle)); + ah = GNUNET_new (struct GAS_Addresses_Handle); ah->running = GNUNET_NO; ah->stat = (struct GNUNET_STATISTICS_Handle *) stats; diff --git a/src/ats/gnunet-service-ats_normalization.c b/src/ats/gnunet-service-ats_normalization.c index 67fd32066..d75ebf42d 100644 --- a/src/ats/gnunet-service-ats_normalization.c +++ b/src/ats/gnunet-service-ats_normalization.c @@ -445,7 +445,7 @@ GAS_normalization_normalize_preference (void *src, /* Not found: create new preference client */ if (NULL == c_cur) { - c_cur = GNUNET_malloc (sizeof (struct PreferenceClient)); + c_cur = GNUNET_new (struct PreferenceClient); c_cur->client = src; GNUNET_CONTAINER_DLL_insert(pc_head, pc_tail, c_cur); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Adding new client %p \n", c_cur); @@ -459,7 +459,7 @@ GAS_normalization_normalize_preference (void *src, /* Not found: create new peer entry */ if (NULL == p_cur) { - p_cur = GNUNET_malloc (sizeof (struct PreferencePeer)); + p_cur = GNUNET_new (struct PreferencePeer); p_cur->client = c_cur; p_cur->id = (*peer); for (i = 0; i < GNUNET_ATS_PreferenceCount; i++) diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 8aad96eea..b9d918103 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c @@ -307,7 +307,7 @@ GAS_performance_add_client (struct GNUNET_SERVER_Client *client, struct PerformanceClient *pc; GNUNET_break (NULL == find_client (client)); - pc = GNUNET_malloc (sizeof (struct PerformanceClient)); + pc = GNUNET_new (struct PerformanceClient); pc->client = client; pc->flag = flag; diff --git a/src/ats/perf_ats_solver.c b/src/ats/perf_ats_solver.c index 0cfc72c69..89d0d82e2 100644 --- a/src/ats/perf_ats_solver.c +++ b/src/ats/perf_ats_solver.c @@ -456,7 +456,7 @@ solver_info_cb (void *cls, if ((GAS_STAT_SUCCESS == stat) && (NULL == ph.current_result)) { /* Create new result */ - tmp = GNUNET_malloc (sizeof (struct Result)); + tmp = GNUNET_new (struct Result); ph.current_result = tmp; GNUNET_CONTAINER_DLL_insert_tail(ph.head, ph.tail, tmp); ph.current_result->addresses = ph.current_a; diff --git a/src/ats/plugin_ats_mlp.c b/src/ats/plugin_ats_mlp.c index 0e6f60893..7dd31edf5 100644 --- a/src/ats/plugin_ats_mlp.c +++ b/src/ats/plugin_ats_mlp.c @@ -1672,7 +1672,7 @@ GAS_mlp_get_preferred_address (void *solver, LOG (GNUNET_ERROR_TYPE_INFO, "Adding peer `%s' to list of requested_peers with requests\n", GNUNET_i2s (peer)); - p = GNUNET_malloc (sizeof (struct ATS_Peer)); + p = GNUNET_new (struct ATS_Peer); p->id = (*peer); p->f = get_peer_pref_value (mlp, peer); GNUNET_CONTAINER_multipeermap_put (mlp->requested_peers, @@ -1887,7 +1887,7 @@ void * libgnunet_plugin_ats_mlp_init (void *cls) { struct GNUNET_ATS_PluginEnvironment *env = cls; - struct GAS_MLP_Handle * mlp = GNUNET_malloc (sizeof (struct GAS_MLP_Handle)); + struct GAS_MLP_Handle * mlp = GNUNET_new (struct GAS_MLP_Handle); double D; double R; diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c index 82a41d39f..62f571e5b 100644 --- a/src/ats/plugin_ats_proportional.c +++ b/src/ats/plugin_ats_proportional.c @@ -409,7 +409,7 @@ libgnunet_plugin_ats_proportional_init (void *cls) GNUNET_assert(NULL != env->get_preferences); GNUNET_assert(NULL != env->get_property); - s = GNUNET_malloc (sizeof (struct GAS_PROPORTIONAL_Handle)); + s = GNUNET_new (struct GAS_PROPORTIONAL_Handle); s->env = env; env->sf.s_add = &GAS_proportional_address_add; env->sf.s_address_update_property = &GAS_proportional_address_property_changed; @@ -1572,12 +1572,12 @@ GAS_proportional_address_add (void *solver, struct ATS_Address *address, return; } - aw = GNUNET_malloc (sizeof (struct AddressWrapper)); + aw = GNUNET_new (struct AddressWrapper); aw->addr = address; GNUNET_CONTAINER_DLL_insert(net->head, net->tail, aw); addresse_increment (s, net, GNUNET_YES, GNUNET_NO); - asi = GNUNET_malloc (sizeof (struct AddressSolverInformation)); + asi = GNUNET_new (struct AddressSolverInformation); asi->network = net; asi->calculated_quota_in_NBO = 0; asi->calculated_quota_out_NBO = 0; diff --git a/src/ats/plugin_ats_ril.c b/src/ats/plugin_ats_ril.c index db6ce5411..a918baa2b 100755 --- a/src/ats/plugin_ats_ril.c +++ b/src/ats/plugin_ats_ril.c @@ -1624,7 +1624,7 @@ agent_init (void *s, const struct GNUNET_PeerIdentity *peer) { int i; struct GAS_RIL_Handle * solver = s; - struct RIL_Peer_Agent * agent = GNUNET_malloc (sizeof (struct RIL_Peer_Agent)); + struct RIL_Peer_Agent * agent = GNUNET_new (struct RIL_Peer_Agent); agent->envi = solver; agent->peer = *peer; @@ -2045,7 +2045,7 @@ GAS_ril_address_add (void *solver, struct ATS_Address *address, uint32_t network agent = ril_get_agent (s, &address->peer, GNUNET_YES); //add address - address_wrapped = GNUNET_malloc (sizeof (struct RIL_Address_Wrapped)); + address_wrapped = GNUNET_new (struct RIL_Address_Wrapped); address_wrapped->address_naked = address; GNUNET_CONTAINER_DLL_insert_tail(agent->addresses_head, agent->addresses_tail, address_wrapped); diff --git a/src/ats/test_ats_api_bandwidth_consumption.c b/src/ats/test_ats_api_bandwidth_consumption.c index 74ee22cfb..493323657 100644 --- a/src/ats/test_ats_api_bandwidth_consumption.c +++ b/src/ats/test_ats_api_bandwidth_consumption.c @@ -189,8 +189,8 @@ run (void *cls, end (); return; } - p = GNUNET_malloc (sizeof (struct PeerContext)); - addr = GNUNET_malloc (sizeof (struct Address)); + p = GNUNET_new (struct PeerContext); + addr = GNUNET_new (struct Address); atp = GNUNET_ATS_performance_init (cfg, &performance_cb, NULL); if (atp == NULL) diff --git a/src/block/plugin_block_template.c b/src/block/plugin_block_template.c index 7c62de6b1..18809b1b1 100644 --- a/src/block/plugin_block_template.c +++ b/src/block/plugin_block_template.c @@ -111,7 +111,7 @@ libgnunet_plugin_block_template_init (void *cls) }; struct GNUNET_BLOCK_PluginFunctions *api; - api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions)); + api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); api->evaluate = &block_plugin_template_evaluate; api->get_key = &block_plugin_template_get_key; api->types = types; diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c index d8e65c52f..0a2a7d7ac 100644 --- a/src/consensus/consensus_api.c +++ b/src/consensus/consensus_api.c @@ -180,7 +180,7 @@ GNUNET_CONSENSUS_create (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_MQ_HANDLERS_END }; - consensus = GNUNET_malloc (sizeof (struct GNUNET_CONSENSUS_Handle)); + consensus = GNUNET_new (struct GNUNET_CONSENSUS_Handle); consensus->cfg = cfg; consensus->new_element_cb = new_element_cb; consensus->new_element_cls = new_element_cls; diff --git a/src/core/gnunet-service-core_clients.c b/src/core/gnunet-service-core_clients.c index 5f745e3bc..f6574b7f9 100644 --- a/src/core/gnunet-service-core_clients.c +++ b/src/core/gnunet-service-core_clients.c @@ -377,7 +377,7 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client, if (car == NULL) { /* create new entry */ - car = GNUNET_malloc (sizeof (struct GSC_ClientActiveRequest)); + car = GNUNET_new (struct GSC_ClientActiveRequest); GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (c->requests, &req->peer, diff --git a/src/core/gnunet-service-core_sessions.c b/src/core/gnunet-service-core_sessions.c index a8d3d3609..eb42d6fbc 100644 --- a/src/core/gnunet-service-core_sessions.c +++ b/src/core/gnunet-service-core_sessions.c @@ -265,7 +265,7 @@ GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating session for peer `%4s'\n", GNUNET_i2s (peer)); - session = GNUNET_malloc (sizeof (struct Session)); + session = GNUNET_new (struct Session); session->tmap = GSC_TYPEMAP_create (); session->peer = *peer; session->kxinfo = kx; diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c index d2dab5d99..c9774ddec 100644 --- a/src/core/gnunet-service-core_typemap.c +++ b/src/core/gnunet-service-core_typemap.c @@ -114,13 +114,13 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg) GNUNET_break_op (0); return NULL; } - ret = GNUNET_malloc (sizeof (struct GSC_TypeMap)); + ret = GNUNET_new (struct GSC_TypeMap); memcpy (ret, &msg[1], sizeof (struct GSC_TypeMap)); return ret; case GNUNET_MESSAGE_TYPE_CORE_COMPRESSED_TYPE_MAP: GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"), 1, GNUNET_NO); - ret = GNUNET_malloc (sizeof (struct GSC_TypeMap)); + ret = GNUNET_new (struct GSC_TypeMap); dlen = sizeof (struct GSC_TypeMap); if ((Z_OK != uncompress ((Bytef *) ret, &dlen, (const Bytef *) &msg[1], @@ -242,7 +242,7 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, const uint16_t * types, struct GSC_TypeMap *ret; unsigned int i; - ret = GNUNET_malloc (sizeof (struct GSC_TypeMap)); + ret = GNUNET_new (struct GSC_TypeMap); if (NULL != tmap) memcpy (ret, tmap, sizeof (struct GSC_TypeMap)); for (i = 0; i < tcnt; i++) @@ -259,7 +259,7 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, const uint16_t * types, struct GSC_TypeMap * GSC_TYPEMAP_create () { - return GNUNET_malloc (sizeof (struct GSC_TypeMap)); + return GNUNET_new (struct GSC_TypeMap); } diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c index c96432946..d7adb8b4d 100644 --- a/src/datacache/datacache.c +++ b/src/datacache/datacache.c @@ -153,7 +153,7 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg, } bf_size = quota / 32; /* 8 bit per entry, 1 bit per 32 kb in DB */ - ret = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_Handle)); + ret = GNUNET_new (struct GNUNET_DATACACHE_Handle); if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "DISABLE_BF")) diff --git a/src/datacache/plugin_datacache_heap.c b/src/datacache/plugin_datacache_heap.c index 85cf9487e..9689d4f05 100644 --- a/src/datacache/plugin_datacache_heap.c +++ b/src/datacache/plugin_datacache_heap.c @@ -393,12 +393,12 @@ libgnunet_plugin_datacache_heap_init (void *cls) struct GNUNET_DATACACHE_PluginFunctions *api; struct Plugin *plugin; - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->map = GNUNET_CONTAINER_multihashmap_create (1024, /* FIXME: base on quota! */ GNUNET_YES); plugin->heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); plugin->env = env; - api = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATACACHE_PluginFunctions); api->cls = plugin; api->get = &heap_plugin_get; api->put = &heap_plugin_put; diff --git a/src/datacache/plugin_datacache_postgres.c b/src/datacache/plugin_datacache_postgres.c index 6d7e28021..150a9d5dc 100644 --- a/src/datacache/plugin_datacache_postgres.c +++ b/src/datacache/plugin_datacache_postgres.c @@ -374,7 +374,7 @@ libgnunet_plugin_datacache_postgres_init (void *cls) struct GNUNET_DATACACHE_PluginFunctions *api; struct Plugin *plugin; - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->env = env; if (GNUNET_OK != init_connection (plugin)) @@ -383,7 +383,7 @@ libgnunet_plugin_datacache_postgres_init (void *cls) return NULL; } - api = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATACACHE_PluginFunctions); api->cls = plugin; api->get = &postgres_plugin_get; api->put = &postgres_plugin_put; diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 1901bdedd..b7f1757ca 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c @@ -438,11 +438,11 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) " path BLOB DEFAULT '')"); SQLITE3_EXEC (dbh, "CREATE INDEX idx_hashidx ON ds090 (key,type,expire)"); SQLITE3_EXEC (dbh, "CREATE INDEX idx_expire ON ds090 (expire)"); - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->env = env; plugin->dbh = dbh; plugin->fn = fn_utf8; - api = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATACACHE_PluginFunctions); api->cls = plugin; api->get = &sqlite_plugin_get; api->put = &sqlite_plugin_put; diff --git a/src/datacache/plugin_datacache_template.c b/src/datacache/plugin_datacache_template.c index 306615571..205cc66c7 100644 --- a/src/datacache/plugin_datacache_template.c +++ b/src/datacache/plugin_datacache_template.c @@ -114,9 +114,9 @@ libgnunet_plugin_datacache_template_init (void *cls) struct GNUNET_DATACACHE_PluginFunctions *api; struct Plugin *plugin; - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->env = env; - api = GNUNET_malloc (sizeof (struct GNUNET_DATACACHE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATACACHE_PluginFunctions); api->cls = plugin; api->get = &template_plugin_get; api->put = &template_plugin_put; diff --git a/src/datastore/gnunet-service-datastore.c b/src/datastore/gnunet-service-datastore.c index 7c4c47e90..98ef6d797 100644 --- a/src/datastore/gnunet-service-datastore.c +++ b/src/datastore/gnunet-service-datastore.c @@ -516,7 +516,7 @@ transmit (struct GNUNET_SERVER_Client *client, struct GNUNET_MessageHeader *msg) GNUNET_free (msg); return; } - tcc = GNUNET_malloc (sizeof (struct TransmitCallbackContext)); + tcc = GNUNET_new (struct TransmitCallbackContext); tcc->msg = msg; tcc->client = client; if (NULL == @@ -598,7 +598,7 @@ transmit_item (void *cls, const struct GNUNET_HashCode * key, uint32_t size, /* transmit 'DATA_END' */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting `%s' message\n", "DATA_END"); - end = GNUNET_malloc (sizeof (struct GNUNET_MessageHeader)); + end = GNUNET_new (struct GNUNET_MessageHeader); end->size = htons (sizeof (struct GNUNET_MessageHeader)); end->type = htons (GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END); transmit (client, end); @@ -698,7 +698,7 @@ handle_reserve (void *cls, struct GNUNET_SERVER_Client *client, reserved += req; GNUNET_STATISTICS_set (stats, gettext_noop ("# reserved"), reserved, GNUNET_NO); - e = GNUNET_malloc (sizeof (struct ReservationList)); + e = GNUNET_new (struct ReservationList); e->next = reservations; reservations = e; e->client = client; @@ -1274,7 +1274,7 @@ load_plugin () struct DatastorePlugin *ret; char *libname; - ret = GNUNET_malloc (sizeof (struct DatastorePlugin)); + ret = GNUNET_new (struct DatastorePlugin); ret->env.cfg = cfg; ret->env.duc = &disk_utilization_change_cb; ret->env.cls = NULL; diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c index c51502cc6..90f72d6ee 100644 --- a/src/datastore/perf_datastore_api.c +++ b/src/datastore/perf_datastore_api.c @@ -303,7 +303,7 @@ run (void *cls, datastore = GNUNET_DATASTORE_connect (cfg); start_time = GNUNET_TIME_absolute_get (); - crc = GNUNET_malloc (sizeof (struct CpsRunContext)); + crc = GNUNET_new (struct CpsRunContext); crc->cfg = cfg; crc->phase = RP_PUT; if (NULL == diff --git a/src/datastore/perf_plugin_datastore.c b/src/datastore/perf_plugin_datastore.c index 908a7ee55..1dacb3783 100644 --- a/src/datastore/perf_plugin_datastore.c +++ b/src/datastore/perf_plugin_datastore.c @@ -459,7 +459,7 @@ run (void *cls, char *const *args, const char *cfgfile, "%s", "Could not initialize plugin, assuming database not configured. Test not run!\n"); return; } - crc = GNUNET_malloc (sizeof (struct CpsRunContext)); + crc = GNUNET_new (struct CpsRunContext); crc->api = api; crc->cfg = c; crc->phase = RP_PUT; diff --git a/src/datastore/plugin_datastore_heap.c b/src/datastore/plugin_datastore_heap.c index 1f756a95c..8f7f3d1de 100644 --- a/src/datastore/plugin_datastore_heap.c +++ b/src/datastore/plugin_datastore_heap.c @@ -240,7 +240,7 @@ heap_plugin_put (void *cls, break; if (NULL == zabt) { - zabt = GNUNET_malloc (sizeof (struct ZeroAnonByType)); + zabt = GNUNET_new (struct ZeroAnonByType); zabt->type = type; GNUNET_CONTAINER_DLL_insert (plugin->zero_head, plugin->zero_tail, @@ -800,12 +800,12 @@ libgnunet_plugin_datastore_heap_init (void *cls) "HASHMAPSIZE", &esize)) esize = 128 * 1024; - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->env = env; plugin->keyvalue = GNUNET_CONTAINER_multihashmap_create (esize, GNUNET_YES); plugin->by_expiration = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); plugin->by_replication = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX); - api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATASTORE_PluginFunctions); api->cls = plugin; api->estimate_size = &heap_plugin_estimate_size; api->put = &heap_plugin_put; diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index cf0172583..fab10b206 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c @@ -946,7 +946,7 @@ libgnunet_plugin_datastore_mysql_init (void *cls) struct GNUNET_DATASTORE_PluginFunctions *api; struct Plugin *plugin; - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->env = env; plugin->mc = GNUNET_MYSQL_context_create (env->cfg, "datastore-mysql"); if (NULL == plugin->mc) @@ -1007,7 +1007,7 @@ libgnunet_plugin_datastore_mysql_init (void *cls) #undef PINIT #undef MRUNS - api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATASTORE_PluginFunctions); api->cls = plugin; api->estimate_size = &mysql_plugin_estimate_size; api->put = &mysql_plugin_put; diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index 6a96ad5d3..79217c998 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c @@ -838,14 +838,14 @@ libgnunet_plugin_datastore_postgres_init (void *cls) struct GNUNET_DATASTORE_PluginFunctions *api; struct Plugin *plugin; - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->env = env; if (GNUNET_OK != init_connection (plugin)) { GNUNET_free (plugin); return NULL; } - api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATASTORE_PluginFunctions); api->cls = plugin; api->estimate_size = &postgres_plugin_estimate_size; api->put = &postgres_plugin_put; diff --git a/src/datastore/plugin_datastore_sqlite.c b/src/datastore/plugin_datastore_sqlite.c index bd344dbb1..f2e0454f9 100644 --- a/src/datastore/plugin_datastore_sqlite.c +++ b/src/datastore/plugin_datastore_sqlite.c @@ -1179,7 +1179,7 @@ libgnunet_plugin_datastore_sqlite_init (void *cls) database_shutdown (&plugin); return NULL; } - api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATASTORE_PluginFunctions); api->cls = &plugin; api->estimate_size = &sqlite_plugin_estimate_size; api->put = &sqlite_plugin_put; diff --git a/src/datastore/plugin_datastore_template.c b/src/datastore/plugin_datastore_template.c index 2978de4fe..5e577b1bc 100644 --- a/src/datastore/plugin_datastore_template.c +++ b/src/datastore/plugin_datastore_template.c @@ -240,9 +240,9 @@ libgnunet_plugin_datastore_template_init (void *cls) struct GNUNET_DATASTORE_PluginFunctions *api; struct Plugin *plugin; - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->env = env; - api = GNUNET_malloc (sizeof (struct GNUNET_DATASTORE_PluginFunctions)); + api = GNUNET_new (struct GNUNET_DATASTORE_PluginFunctions); api->cls = plugin; api->estimate_size = &template_plugin_estimate_size; api->put = &template_plugin_put; diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c index 03939cee3..26d0f1343 100644 --- a/src/datastore/test_datastore_api.c +++ b/src/datastore/test_datastore_api.c @@ -471,7 +471,7 @@ run (void *cls, struct CpsRunContext *crc; static struct GNUNET_HashCode zkey; - crc = GNUNET_malloc (sizeof (struct CpsRunContext)); + crc = GNUNET_new (struct CpsRunContext); crc->cfg = cfg; crc->phase = RP_PUT; now = GNUNET_TIME_absolute_get (); diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 7f330031a..5553e5c0b 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -265,7 +265,7 @@ run (void *cls, struct CpsRunContext *crc; static struct GNUNET_HashCode zkey; - crc = GNUNET_malloc (sizeof (struct CpsRunContext)); + crc = GNUNET_new (struct CpsRunContext); crc->cfg = cfg; crc->phase = RP_PUT; now = GNUNET_TIME_absolute_get (); diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index 844d32a7b..4eefcaefa 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c @@ -345,7 +345,7 @@ run (void *cls, char *const *args, const char *cfgfile, "%s", "Could not initialize plugin, assuming database not configured. Test not run!\n"); return; } - crc = GNUNET_malloc (sizeof (struct CpsRunContext)); + crc = GNUNET_new (struct CpsRunContext); crc->api = api; crc->cfg = c; crc->phase = RP_PUT; diff --git a/src/dht/dht_test_lib.c b/src/dht/dht_test_lib.c index 9864da949..92b10e815 100644 --- a/src/dht/dht_test_lib.c +++ b/src/dht/dht_test_lib.c @@ -201,7 +201,7 @@ GNUNET_DHT_TEST_run (const char *testname, { struct GNUNET_DHT_TEST_Context *ctx; - ctx = GNUNET_malloc (sizeof (struct GNUNET_DHT_TEST_Context)); + ctx = GNUNET_new (struct GNUNET_DHT_TEST_Context); ctx->num_peers = num_peers; ctx->ops = GNUNET_malloc (num_peers * sizeof (struct GNUNET_TESTBED_Operation *)); ctx->dhts = GNUNET_malloc (num_peers * sizeof (struct GNUNET_DHT_Handle *)); diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c index f91311cf3..c6e72cf44 100644 --- a/src/dht/gnunet-service-dht_clients.c +++ b/src/dht/gnunet-service-dht_clients.c @@ -822,7 +822,7 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_DHT_MonitorStartStopMessage *msg; msg = (struct GNUNET_DHT_MonitorStartStopMessage *) message; - r = GNUNET_malloc (sizeof(struct ClientMonitorRecord)); + r = GNUNET_new (struct ClientMonitorRecord); r->client = find_active_client(client); r->type = ntohl(msg->type); @@ -833,7 +833,7 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client, r->key = NULL; else { - r->key = GNUNET_malloc (sizeof (struct GNUNET_HashCode)); + r->key = GNUNET_new (struct GNUNET_HashCode); memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode)); } GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r); diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index 1d7eb560c..d89f26685 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c @@ -666,7 +666,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) &phash); peer_bucket = find_bucket (&phash); GNUNET_assert ((peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS)); - ret = GNUNET_malloc (sizeof (struct PeerInfo)); + ret = GNUNET_new (struct PeerInfo); #if 0 ret->latency = latency; ret->distance = distance; diff --git a/src/dht/gnunet-service-xdht_clients.c b/src/dht/gnunet-service-xdht_clients.c index 2bcd145a1..9cc156e3d 100644 --- a/src/dht/gnunet-service-xdht_clients.c +++ b/src/dht/gnunet-service-xdht_clients.c @@ -822,7 +822,7 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client, const struct GNUNET_DHT_MonitorStartStopMessage *msg; msg = (struct GNUNET_DHT_MonitorStartStopMessage *) message; - r = GNUNET_malloc (sizeof(struct ClientMonitorRecord)); + r = GNUNET_new (struct ClientMonitorRecord); r->client = find_active_client(client); r->type = ntohl(msg->type); @@ -833,7 +833,7 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client, r->key = NULL; else { - r->key = GNUNET_malloc (sizeof (struct GNUNET_HashCode)); + r->key = GNUNET_new (struct GNUNET_HashCode); memcpy (r->key, &msg->key, sizeof (struct GNUNET_HashCode)); } GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r); diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index af7ef1612..8f47feef5 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c @@ -666,7 +666,7 @@ handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer) &phash); peer_bucket = find_bucket (&phash); GNUNET_assert ((peer_bucket >= 0) && (peer_bucket < MAX_BUCKETS)); - ret = GNUNET_malloc (sizeof (struct PeerInfo)); + ret = GNUNET_new (struct PeerInfo); #if 0 ret->latency = latency; ret->distance = distance; diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c index a21167fb0..d6798f18c 100644 --- a/src/dht/plugin_block_dht.c +++ b/src/dht/plugin_block_dht.c @@ -172,7 +172,7 @@ libgnunet_plugin_block_dht_init (void *cls) }; struct GNUNET_BLOCK_PluginFunctions *api; - api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions)); + api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); api->evaluate = &block_plugin_dht_evaluate; api->get_key = &block_plugin_dht_get_key; api->types = types; diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index 303fe8f87..98791d28f 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c @@ -380,7 +380,7 @@ run (void *cls, GNUNET_CRYPTO_hash (&i, sizeof (i), &key); for (j=0;jdh =dh; rh->request_id = req->request_id; rh->generation = dh->generation; @@ -490,7 +490,7 @@ GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, { struct GNUNET_DNS_Handle *dh; - dh = GNUNET_malloc (sizeof (struct GNUNET_DNS_Handle)); + dh = GNUNET_new (struct GNUNET_DNS_Handle); dh->cfg = cfg; dh->flags = flags; dh->rh = rh; diff --git a/src/dns/dnsstub.c b/src/dns/dnsstub.c index e494d24a2..51d6c2c21 100644 --- a/src/dns/dnsstub.c +++ b/src/dns/dnsstub.c @@ -530,7 +530,7 @@ GNUNET_DNSSTUB_start (const char *dns_ip) { struct GNUNET_DNSSTUB_Context *ctx; - ctx = GNUNET_malloc (sizeof (struct GNUNET_DNSSTUB_Context)); + ctx = GNUNET_new (struct GNUNET_DNSSTUB_Context); if (NULL != dns_ip) ctx->dns_exit = GNUNET_strdup (dns_ip); return ctx; diff --git a/src/dns/gnunet-service-dns.c b/src/dns/gnunet-service-dns.c index ded21605a..0b130f478 100644 --- a/src/dns/gnunet-service-dns.c +++ b/src/dns/gnunet-service-dns.c @@ -743,7 +743,7 @@ handle_client_init (void *cls GNUNET_UNUSED, struct ClientRecord *cr; const struct GNUNET_DNS_Register *reg = (const struct GNUNET_DNS_Register*) message; - cr = GNUNET_malloc (sizeof (struct ClientRecord)); + cr = GNUNET_new (struct ClientRecord); cr->client = client; cr->flags = (enum GNUNET_DNS_Flags) ntohl (reg->flags); GNUNET_SERVER_client_keep (client); diff --git a/src/env/env.c b/src/env/env.c index 33d12c01e..1a8c1a568 100644 --- a/src/env/env.c +++ b/src/env/env.c @@ -68,7 +68,7 @@ GNUNET_ENV_environment_add_mod (struct GNUNET_ENV_Environment *env, enum GNUNET_ENV_Operator oper, const char *name, const void *value, size_t value_size) { - struct GNUNET_ENV_Modifier *mod = GNUNET_malloc (sizeof (*mod)); + struct GNUNET_ENV_Modifier *mod = GNUNET_new (struct GNUNET_ENV_Modifier); mod->oper = oper; mod->name = name; mod->value = value; diff --git a/src/experimentation/gnunet-daemon-experimentation_nodes.c b/src/experimentation/gnunet-daemon-experimentation_nodes.c index aa8a0dbbe..65b2d9c38 100644 --- a/src/experimentation/gnunet-daemon-experimentation_nodes.c +++ b/src/experimentation/gnunet-daemon-experimentation_nodes.c @@ -1044,7 +1044,7 @@ GED_nodes_send_start_ack (struct Node *n, struct Experiment *e) "Sending %s for experiment request to peer `%s' for experiment `%s'\n", "START_ACK" ,GNUNET_i2s(&n->id), e->name); - e_ctx = GNUNET_malloc (sizeof (struct NodeComCtx)); + e_ctx = GNUNET_new (struct NodeComCtx); e_ctx->n = n; e_ctx->e = e; e_ctx->size = sizeof (struct GED_start_ack_message) + strlen (e->name) + 1; @@ -1071,7 +1071,7 @@ GED_nodes_send_start (struct Node *n, struct Experiment *e) "Sending %s for experiment request to peer `%s' for experiment `%s'\n", "START", GNUNET_i2s(&n->id), e->name); - e_ctx = GNUNET_malloc (sizeof (struct NodeComCtx)); + e_ctx = GNUNET_new (struct NodeComCtx); e_ctx->n = n; e_ctx->e = e; e_ctx->size = sizeof (struct GED_start_message) + strlen (e->name) + 1; diff --git a/src/experimentation/gnunet-daemon-experimentation_scheduler.c b/src/experimentation/gnunet-daemon-experimentation_scheduler.c index a52d60c37..c13434e9b 100644 --- a/src/experimentation/gnunet-daemon-experimentation_scheduler.c +++ b/src/experimentation/gnunet-daemon-experimentation_scheduler.c @@ -330,7 +330,7 @@ GED_scheduler_add (struct Node *n, struct Experiment *e, int outbound) return; /* End of experiment is reached */ /* Add additional checks here if required */ - se = GNUNET_malloc (sizeof (struct ScheduledExperiment)); + se = GNUNET_new (struct ScheduledExperiment); se->state = NOT_RUNNING; se->outbound = outbound; se->e = e; diff --git a/src/fragmentation/defragmentation.c b/src/fragmentation/defragmentation.c index 5f9eace13..478a9c658 100644 --- a/src/fragmentation/defragmentation.c +++ b/src/fragmentation/defragmentation.c @@ -210,7 +210,7 @@ GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, { struct GNUNET_DEFRAGMENT_Context *dc; - dc = GNUNET_malloc (sizeof (struct GNUNET_DEFRAGMENT_Context)); + dc = GNUNET_new (struct GNUNET_DEFRAGMENT_Context); dc->stats = stats; dc->cls = cls; dc->proc = proc; diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 72d5eab15..3b8d125ad 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c @@ -371,7 +371,7 @@ GNUNET_FS_make_top (struct GNUNET_FS_Handle *h, SuspendSignalFunction ssf, { struct TopLevelActivity *ret; - ret = GNUNET_malloc (sizeof (struct TopLevelActivity)); + ret = GNUNET_new (struct TopLevelActivity); ret->ssf = ssf; ret->ssf_cls = ssf_cls; GNUNET_CONTAINER_DLL_insert (h->top_head, h->top_tail, ret); @@ -852,7 +852,7 @@ deserialize_fi_node (struct GNUNET_FS_Handle *h, const char *fn, GNUNET_break (0); return NULL; } - ret = GNUNET_malloc (sizeof (struct GNUNET_FS_FileInformation)); + ret = GNUNET_new (struct GNUNET_FS_FileInformation); ret->h = h; ksks = NULL; chks = NULL; @@ -1769,7 +1769,7 @@ read_download_request (struct GNUNET_BIO_ReadHandle *rh) struct DownloadRequest *dr; unsigned int i; - dr = GNUNET_malloc (sizeof (struct DownloadRequest)); + dr = GNUNET_new (struct DownloadRequest); if ((GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->state)) || (GNUNET_OK != GNUNET_BIO_read_int64 (rh, &dr->offset)) || (GNUNET_OK != GNUNET_BIO_read_int32 (rh, &dr->num_children)) || @@ -2127,7 +2127,7 @@ deserialize_unindex_file (void *cls, const char *filename) char *uris; uint32_t state; - uc = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext)); + uc = GNUNET_new (struct GNUNET_FS_UnindexContext); uc->h = h; uc->serialization = get_serialization_short_name (filename); rh = GNUNET_BIO_read_open (filename); @@ -2994,7 +2994,7 @@ GNUNET_FS_start (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_FS_OPTIONS opt; va_list ap; - ret = GNUNET_malloc (sizeof (struct GNUNET_FS_Handle)); + ret = GNUNET_new (struct GNUNET_FS_Handle); ret->cfg = cfg; ret->client_name = GNUNET_strdup (client_name); ret->upcb = upcb; diff --git a/src/fs/fs_directory.c b/src/fs/fs_directory.c index b26ec12d3..3f7cc45c1 100644 --- a/src/fs/fs_directory.c +++ b/src/fs/fs_directory.c @@ -346,7 +346,7 @@ GNUNET_FS_directory_builder_create (const struct GNUNET_CONTAINER_MetaData { struct GNUNET_FS_DirectoryBuilder *ret; - ret = GNUNET_malloc (sizeof (struct GNUNET_FS_DirectoryBuilder)); + ret = GNUNET_new (struct GNUNET_FS_DirectoryBuilder); if (mdir != NULL) ret->meta = GNUNET_CONTAINER_meta_data_duplicate (mdir); else diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c index 3b3615f65..83e436b16 100644 --- a/src/fs/fs_dirmetascan.c +++ b/src/fs/fs_dirmetascan.c @@ -463,7 +463,7 @@ GNUNET_FS_directory_scan_start (const char *filename, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting to scan directory `%s'\n", filename_expanded); - ds = GNUNET_malloc (sizeof (struct GNUNET_FS_DirScanner)); + ds = GNUNET_new (struct GNUNET_FS_DirScanner); ds->progress_callback = cb; ds->progress_callback_cls = cb_cls; ds->filename_expanded = filename_expanded; diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index f9f5c0a06..5d4c6d899 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -1550,7 +1550,7 @@ create_download_request (struct DownloadRequest *parent, unsigned int head_skip; uint64_t child_block_size; - dr = GNUNET_malloc (sizeof (struct DownloadRequest)); + dr = GNUNET_new (struct DownloadRequest); dr->parent = parent; dr->depth = depth; dr->offset = dr_offset; diff --git a/src/fs/fs_file_information.c b/src/fs/fs_file_information.c index 87d618b07..d369598ef 100644 --- a/src/fs/fs_file_information.c +++ b/src/fs/fs_file_information.c @@ -241,7 +241,7 @@ GNUNET_FS_file_information_create_from_reader (struct GNUNET_FS_Handle *h, GNUNET_break (0); return NULL; } - ret = GNUNET_malloc (sizeof (struct GNUNET_FS_FileInformation)); + ret = GNUNET_new (struct GNUNET_FS_FileInformation); ret->h = h; ret->client_info = client_info; ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); @@ -297,7 +297,7 @@ GNUNET_FS_file_information_create_empty_directory (struct GNUNET_FS_Handle *h, { struct GNUNET_FS_FileInformation *ret; - ret = GNUNET_malloc (sizeof (struct GNUNET_FS_FileInformation)); + ret = GNUNET_new (struct GNUNET_FS_FileInformation); ret->h = h; ret->client_info = client_info; ret->meta = GNUNET_CONTAINER_meta_data_duplicate (meta); diff --git a/src/fs/fs_getopt.c b/src/fs/fs_getopt.c index d7ff97c6b..5e9510956 100644 --- a/src/fs/fs_getopt.c +++ b/src/fs/fs_getopt.c @@ -53,7 +53,7 @@ GNUNET_FS_getopt_set_keywords (struct GNUNET_GETOPT_CommandLineProcessorContext if (u == NULL) { - u = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); + u = GNUNET_new (struct GNUNET_FS_Uri); *uri = u; u->type = GNUNET_FS_URI_KSK; u->data.ksk.keywordCount = 0; diff --git a/src/fs/fs_list_indexed.c b/src/fs/fs_list_indexed.c index ef03dee76..7a891155e 100644 --- a/src/fs/fs_list_indexed.c +++ b/src/fs/fs_list_indexed.c @@ -151,7 +151,7 @@ GNUNET_FS_get_indexed_files (struct GNUNET_FS_Handle *h, _("Failed to not connect to `%s' service.\n"), "fs"); return NULL; } - gic = GNUNET_malloc (sizeof (struct GNUNET_FS_GetIndexedContext)); + gic = GNUNET_new (struct GNUNET_FS_GetIndexedContext); gic->h = h; gic->client = client; gic->iterator = iterator; diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index 085ea3764..1e098bd60 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c @@ -452,7 +452,7 @@ GNUNET_FS_TEST_publish (struct GNUNET_TESTBED_Peer *peer, { struct TestPublishOperation *po; - po = GNUNET_malloc (sizeof (struct TestPublishOperation)); + po = GNUNET_new (struct TestPublishOperation); po->publish_cont = cont; po->publish_cont_cls = cont_cls; po->publish_seed = seed; @@ -631,7 +631,7 @@ GNUNET_FS_TEST_download (struct GNUNET_TESTBED_Peer *peer, { struct TestDownloadOperation *dop; - dop = GNUNET_malloc (sizeof (struct TestDownloadOperation)); + dop = GNUNET_new (struct TestDownloadOperation); dop->uri = GNUNET_FS_uri_dup (uri); dop->size = GNUNET_FS_uri_chk_get_file_size (uri); dop->verbose = verbose; diff --git a/src/fs/fs_tree.c b/src/fs/fs_tree.c index 4e0ef8c5b..5dc39e4e6 100644 --- a/src/fs/fs_tree.c +++ b/src/fs/fs_tree.c @@ -276,7 +276,7 @@ GNUNET_FS_tree_encoder_create (struct GNUNET_FS_Handle *h, uint64_t size, { struct GNUNET_FS_TreeEncoder *te; - te = GNUNET_malloc (sizeof (struct GNUNET_FS_TreeEncoder)); + te = GNUNET_new (struct GNUNET_FS_TreeEncoder); te->h = h; te->size = size; te->cls = cls; @@ -347,7 +347,7 @@ GNUNET_FS_tree_encoder_next (struct GNUNET_FS_TreeEncoder *te) off = CHK_PER_INODE * (te->chk_tree_depth - 1); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "TE done, reading CHK `%s' from %u\n", GNUNET_h2s (&te->chk_tree[off].query), off); - te->uri = GNUNET_malloc (sizeof (struct GNUNET_FS_Uri)); + te->uri = GNUNET_new (struct GNUNET_FS_Uri); te->uri->type = GNUNET_FS_URI_CHK; te->uri->data.chk.chk = te->chk_tree[off]; te->uri->data.chk.file_length = GNUNET_htonll (te->size); diff --git a/src/fs/fs_unindex.c b/src/fs/fs_unindex.c index 14ab0fd69..b446bab1b 100644 --- a/src/fs/fs_unindex.c +++ b/src/fs/fs_unindex.c @@ -767,7 +767,7 @@ GNUNET_FS_unindex_start (struct GNUNET_FS_Handle *h, if (GNUNET_OK != GNUNET_DISK_file_size (filename, &size, GNUNET_YES, GNUNET_YES)) return NULL; - ret = GNUNET_malloc (sizeof (struct GNUNET_FS_UnindexContext)); + ret = GNUNET_new (struct GNUNET_FS_UnindexContext); ret->h = h; ret->filename = GNUNET_strdup (filename); ret->start_time = GNUNET_TIME_absolute_get (); diff --git a/src/fs/gnunet-auto-share.c b/src/fs/gnunet-auto-share.c index b001cb58c..2106d67f1 100644 --- a/src/fs/gnunet-auto-share.c +++ b/src/fs/gnunet-auto-share.c @@ -208,7 +208,7 @@ load_state () (GNUNET_OK != GNUNET_BIO_read (rh, "id", &id, sizeof (struct GNUNET_HashCode))) ) goto error; - wi = GNUNET_malloc (sizeof (struct WorkItem)); + wi = GNUNET_new (struct WorkItem); wi->id = id; wi->filename = fn; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -605,7 +605,7 @@ add_file (void *cls, } else { - wi = GNUNET_malloc (sizeof (struct WorkItem)); + wi = GNUNET_new (struct WorkItem); wi->filename = GNUNET_strdup (filename); } wi->id = id; diff --git a/src/fs/gnunet-helper-fs-publish.c b/src/fs/gnunet-helper-fs-publish.c index 214650b0f..c64dece42 100644 --- a/src/fs/gnunet-helper-fs-publish.c +++ b/src/fs/gnunet-helper-fs-publish.c @@ -328,7 +328,7 @@ preprocess_file (const char *filename, : GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_FILE, filename, strlen (filename) + 1)) return GNUNET_SYSERR; - item = GNUNET_malloc (sizeof (struct ScanTreeNode)); + item = GNUNET_new (struct ScanTreeNode); item->filename = GNUNET_strdup (filename); item->is_directory = (S_ISDIR (sbuf.st_mode)) ? GNUNET_YES : GNUNET_NO; item->file_size = fsize; diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index e3ce8dd69..0af19d537 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -1078,7 +1078,7 @@ handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Replicating result for query `%s' with priority %u\n", GNUNET_h2s (key), prq.priority); - pmc = GNUNET_malloc (sizeof (struct PutMigrationContext)); + pmc = GNUNET_new (struct PutMigrationContext); pmc->start = GNUNET_TIME_absolute_get (); pmc->requested = GNUNET_YES; if (NULL == @@ -1675,7 +1675,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Replicating result for query `%s' with priority %u\n", GNUNET_h2s (&query), prq.priority); - pmc = GNUNET_malloc (sizeof (struct PutMigrationContext)); + pmc = GNUNET_new (struct PutMigrationContext); pmc->start = GNUNET_TIME_absolute_get (); pmc->requested = prq.request_found; GNUNET_assert (0 != GSF_get_peer_performance_data_ (cp)->pid); diff --git a/src/fs/perf_gnunet_service_fs_p2p.c b/src/fs/perf_gnunet_service_fs_p2p.c index 2462bb3f2..17a27f803 100644 --- a/src/fs/perf_gnunet_service_fs_p2p.c +++ b/src/fs/perf_gnunet_service_fs_p2p.c @@ -263,7 +263,7 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free (fancy); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished download, shutting down\n", (unsigned long long) FILESIZE); - sm = GNUNET_malloc (sizeof (struct StatMaster)); + sm = GNUNET_new (struct StatMaster); sm->op = GNUNET_TESTBED_service_connect (NULL, daemons[sm->daemon], diff --git a/src/fs/perf_gnunet_service_fs_p2p_respect.c b/src/fs/perf_gnunet_service_fs_p2p_respect.c index b2471a8b4..4d6de9a90 100644 --- a/src/fs/perf_gnunet_service_fs_p2p_respect.c +++ b/src/fs/perf_gnunet_service_fs_p2p_respect.c @@ -308,7 +308,7 @@ do_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) return; /* more downloads to come */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Finished all downloads, getting statistics\n"); - sm = GNUNET_malloc (sizeof (struct StatMaster)); + sm = GNUNET_new (struct StatMaster); sm->op = GNUNET_TESTBED_service_connect (NULL, daemons[sm->daemon], diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c index 770c212ba..4defe119b 100644 --- a/src/fs/test_gnunet_service_fs_migration.c +++ b/src/fs/test_gnunet_service_fs_migration.c @@ -151,7 +151,7 @@ do_wait (void *cls, const struct GNUNET_FS_Uri *uri, return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting to allow content to migrate\n"); - dc = GNUNET_malloc (sizeof (struct DownloadContext)); + dc = GNUNET_new (struct DownloadContext); dc->uri = GNUNET_FS_uri_dup (uri); if (NULL != fn) dc->fn = GNUNET_strdup (fn); diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 3d55bc045..a19a97cf3 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c @@ -338,7 +338,7 @@ result_processor (void *cls, case GNUNET_DNSPARSER_TYPE_AAAA: GNUNET_assert (sizeof (struct in6_addr) == rd[i].data_size); rec.name = GNUNET_strdup (packet->queries[0].name); - rec.data.raw.data = GNUNET_malloc (sizeof (struct in6_addr)); + rec.data.raw.data = GNUNET_new (struct in6_addr); rec.dns_traffic_class = GNUNET_TUN_DNS_CLASS_INTERNET; rec.type = GNUNET_DNSPARSER_TYPE_AAAA; memcpy (rec.data.raw.data, diff --git a/src/gns/gnunet-gns-helper-service-w32.c b/src/gns/gnunet-gns-helper-service-w32.c index 48bbd5723..93b843697 100644 --- a/src/gns/gnunet-gns-helper-service-w32.c +++ b/src/gns/gnunet-gns-helper-service-w32.c @@ -216,7 +216,7 @@ transmit (struct GNUNET_SERVER_Client *client, GNUNET_free (msg); return; } - tcc = GNUNET_malloc (sizeof (struct TransmitCallbackContext)); + tcc = GNUNET_new (struct TransmitCallbackContext); tcc->msg = msg; if (NULL == (tcc->th = @@ -594,7 +594,7 @@ get_ip_from_hostname (struct GNUNET_SERVER_Client *client, af == AF_INET ? "IPv4" : af == AF_INET6 ? "IPv6" : "anything", hostname); - rq = GNUNET_malloc (sizeof (struct request)); + rq = GNUNET_new (struct request); rq->sc = sc; rq->client = client; rq->af = af; diff --git a/src/gnsrecord/plugin_gnsrecord_dns.c b/src/gnsrecord/plugin_gnsrecord_dns.c index 4f010dc42..362acbf87 100644 --- a/src/gnsrecord/plugin_gnsrecord_dns.c +++ b/src/gnsrecord/plugin_gnsrecord_dns.c @@ -294,7 +294,7 @@ dns_string_to_value (void *cls, s); return GNUNET_SYSERR; } - *data = GNUNET_malloc (sizeof (struct in_addr)); + *data = GNUNET_new (struct in_addr); memcpy (*data, &value_a, sizeof (value_a)); *data_size = sizeof (value_a); return GNUNET_OK; @@ -550,7 +550,7 @@ dns_string_to_value (void *cls, s); return GNUNET_SYSERR; } - *data = GNUNET_malloc (sizeof (struct in6_addr)); + *data = GNUNET_new (struct in6_addr); *data_size = sizeof (struct in6_addr); memcpy (*data, &value_aaaa, sizeof (value_aaaa)); return GNUNET_OK; diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 2cda6dd00..ef4debc05 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -433,7 +433,7 @@ process_notify (void *cls, const struct GNUNET_PeerIdentity *peer, } else { - builder = GNUNET_malloc (sizeof (struct HostSet)); + builder = GNUNET_new (struct HostSet); } GNUNET_assert (NULL != peerinfo); builder->pitr = diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c index adac4cdf1..fa54fafa6 100644 --- a/src/mesh/gnunet-service-mesh_local.c +++ b/src/mesh/gnunet-service-mesh_local.c @@ -593,7 +593,7 @@ handle_ack (void *cls, struct GNUNET_SERVER_Client *client, // struct MeshChannel *ch = value; // struct GNUNET_MESH_LocalMonitor *msg; // -// msg = GNUNET_malloc (sizeof(struct GNUNET_MESH_LocalMonitor)); +// msg = GNUNET_new (struct GNUNET_MESH_LocalMonitor); // msg->channel_id = htonl (ch->gid); // msg->header.size = htons (sizeof (struct GNUNET_MESH_LocalMonitor)); // msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS); @@ -688,7 +688,7 @@ handle_show_tunnel (void *cls, struct GNUNET_SERVER_Client *client, } /* Initialize context */ - resp = GNUNET_malloc (sizeof (struct GNUNET_MESH_LocalMonitor)); + resp = GNUNET_new (struct GNUNET_MESH_LocalMonitor); *resp = *msg; resp->header.size = htons (sizeof (struct GNUNET_MESH_LocalMonitor)); GNUNET_SERVER_notification_context_unicast (nc, c->handle, diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index 741bffc2f..def57ba56 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c @@ -1051,7 +1051,7 @@ GMP_queue_add (struct MeshPeer *peer, void *cls, uint16_t type, size_t size, LOG (GNUNET_ERROR_TYPE_DEBUG, "priority %d\n", priority); call_core = NULL == c ? GNUNET_YES : GMC_is_sendable (c, fwd); - queue = GNUNET_malloc (sizeof (struct MeshPeerQueue)); + queue = GNUNET_new (struct MeshPeerQueue); queue->cls = cls; queue->type = type; queue->size = size; diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 22ef3e19b..d670f4f30 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -404,7 +404,7 @@ create_channel (struct GNUNET_MESH_Handle *h, MESH_ChannelNumber chid) { struct GNUNET_MESH_Channel *ch; - ch = GNUNET_malloc (sizeof (struct GNUNET_MESH_Channel)); + ch = GNUNET_new (struct GNUNET_MESH_Channel); GNUNET_CONTAINER_DLL_insert (h->channels_head, h->channels_tail, ch); ch->mesh = h; if (0 == chid) @@ -1243,7 +1243,7 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, struct GNUNET_MESH_Handle *h; LOG (GNUNET_ERROR_TYPE_DEBUG, "GNUNET_MESH_connect()\n"); - h = GNUNET_malloc (sizeof (struct GNUNET_MESH_Handle)); + h = GNUNET_new (struct GNUNET_MESH_Handle); LOG (GNUNET_ERROR_TYPE_DEBUG, " addr %p\n", h); h->cfg = cfg; h->new_channel = new_channel; @@ -1496,7 +1496,7 @@ GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Channel *channel, int cork LOG (GNUNET_ERROR_TYPE_DEBUG, " payload size %u\n", notify_size); GNUNET_assert (NULL != notify); GNUNET_assert (0 == channel->packet_size); // Only one data packet allowed - th = GNUNET_malloc (sizeof (struct GNUNET_MESH_TransmitHandle)); + th = GNUNET_new (struct GNUNET_MESH_TransmitHandle); th->channel = channel; th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); th->size = notify_size + sizeof (struct GNUNET_MESH_LocalData); diff --git a/src/mesh/mesh_path.c b/src/mesh/mesh_path.c index f1c68c005..ad1f7f4db 100644 --- a/src/mesh/mesh_path.c +++ b/src/mesh/mesh_path.c @@ -60,7 +60,7 @@ path_new (unsigned int length) { struct MeshPeerPath *p; - p = GNUNET_malloc (sizeof (struct MeshPeerPath)); + p = GNUNET_new (struct MeshPeerPath); if (length > 0) { p->length = length; diff --git a/src/mesh/mesh_test_lib.c b/src/mesh/mesh_test_lib.c index 7ad888da8..0229a5bb1 100644 --- a/src/mesh/mesh_test_lib.c +++ b/src/mesh/mesh_test_lib.c @@ -237,7 +237,7 @@ mesh_test_run (void *cls, for (i = 0; i < num_peers; i++) { struct GNUNET_MESH_TEST_AdapterContext *newctx; - newctx = GNUNET_malloc (sizeof (struct GNUNET_MESH_TEST_AdapterContext)); + newctx = GNUNET_new (struct GNUNET_MESH_TEST_AdapterContext); newctx->peer = i; newctx->ctx = ctx; ctx->ops[i] = GNUNET_TESTBED_service_connect (ctx, @@ -265,7 +265,7 @@ GNUNET_MESH_TEST_run (const char *testname, { struct GNUNET_MESH_TEST_Context *ctx; - ctx = GNUNET_malloc (sizeof (struct GNUNET_MESH_TEST_Context)); + ctx = GNUNET_new (struct GNUNET_MESH_TEST_Context); ctx->num_peers = num_peers; ctx->ops = GNUNET_malloc (num_peers * sizeof (struct GNUNET_TESTBED_Operation *)); ctx->meshes = GNUNET_malloc (num_peers * sizeof (struct GNUNET_MESH_Handle *)); diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c index c2fe6c3d9..48d052ef7 100644 --- a/src/mesh/mesh_tunnel_tree.c +++ b/src/mesh/mesh_tunnel_tree.c @@ -119,7 +119,7 @@ path_new (unsigned int length) { struct MeshPeerPath *p; - p = GNUNET_malloc (sizeof (struct MeshPeerPath)); + p = GNUNET_new (struct MeshPeerPath); if (length > 0) { p->length = length; @@ -233,7 +233,7 @@ tree_node_new (struct MeshTunnelTreeNode *parent, GNUNET_PEER_Id peer) { struct MeshTunnelTreeNode *node; - node = GNUNET_malloc (sizeof (struct MeshTunnelTreeNode)); + node = GNUNET_new (struct MeshTunnelTreeNode); node->peer = peer; GNUNET_PEER_change_rc (peer, 1); node->parent = parent; @@ -322,7 +322,7 @@ tree_node_update_first_hops (struct MeshTunnelTree *tree, GNUNET_PEER_resolve (parent->peer, &id); copy = GNUNET_CONTAINER_multihashmap_get (tree->first_hops, &id.hashPubKey); if (NULL == copy) - copy = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); + copy = GNUNET_new (struct GNUNET_PeerIdentity); *copy = *hop; (void) GNUNET_CONTAINER_multihashmap_put (tree->first_hops, &id.hashPubKey, @@ -417,7 +417,7 @@ tree_new (GNUNET_PEER_Id peer) { struct MeshTunnelTree *tree; - tree = GNUNET_malloc (sizeof (struct MeshTunnelTree)); + tree = GNUNET_new (struct MeshTunnelTree); tree->first_hops = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_NO); tree->root = tree_node_new (NULL, peer); tree->root->status = MESH_PEER_ROOT; @@ -647,7 +647,7 @@ tree_iterate_all (struct MeshTunnelTree *tree, struct MeshTreePendingNode *pending; cb (cb_cls, tree->root->peer, 0); - pending = GNUNET_malloc (sizeof (struct MeshTreePendingNode)); + pending = GNUNET_new (struct MeshTreePendingNode); pending->node = tree->root; head = tail = NULL; GNUNET_CONTAINER_DLL_insert (head, tail, pending); @@ -661,7 +661,7 @@ tree_iterate_all (struct MeshTunnelTree *tree, for (n = parent->children_head; NULL != n; n = n->next) { cb (cb_cls, n->peer, parent->peer); - pending = GNUNET_malloc (sizeof (struct MeshTreePendingNode)); + pending = GNUNET_new (struct MeshTreePendingNode); pending->node = n; /* Insert_tail: breadth first, Insert: depth first */ GNUNET_CONTAINER_DLL_insert (head, tail, pending); diff --git a/src/mysql/mysql.c b/src/mysql/mysql.c index 098213b33..22804d474 100644 --- a/src/mysql/mysql.c +++ b/src/mysql/mysql.c @@ -292,7 +292,7 @@ GNUNET_MYSQL_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg, { struct GNUNET_MYSQL_Context *mc; - mc = GNUNET_malloc (sizeof (struct GNUNET_MYSQL_Context)); + mc = GNUNET_new (struct GNUNET_MYSQL_Context); mc->cfg = cfg; mc->section = section; mc->cnffile = get_my_cnf_path (cfg, section); @@ -365,7 +365,7 @@ GNUNET_MYSQL_statement_prepare (struct GNUNET_MYSQL_Context *mc, { struct GNUNET_MYSQL_StatementHandle *sh; - sh = GNUNET_malloc (sizeof (struct GNUNET_MYSQL_StatementHandle)); + sh = GNUNET_new (struct GNUNET_MYSQL_StatementHandle); sh->query = GNUNET_strdup (query); GNUNET_CONTAINER_DLL_insert (mc->shead, mc->stail, sh); return sh; diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index b3e42f818..d19a38ce9 100644 --- a/src/namestore/gnunet-namestore-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c @@ -658,7 +658,7 @@ create_response (void *cls, request = *ptr; if (NULL == request) { - request = GNUNET_malloc (sizeof (struct Request)); + request = GNUNET_new (struct Request); *ptr = request; request->pp = MHD_create_post_processor (connection, 1024, &post_iterator, request); diff --git a/src/nat/gnunet-nat-server.c b/src/nat/gnunet-nat-server.c index 1a98cdc96..82e39ee16 100644 --- a/src/nat/gnunet-nat-server.c +++ b/src/nat/gnunet-nat-server.c @@ -152,7 +152,7 @@ try_send_tcp (uint32_t dst_ipv4, uint16_t dport, uint16_t data) GNUNET_NETWORK_socket_close (s); return; } - ctx = GNUNET_malloc (sizeof (struct TcpContext)); + ctx = GNUNET_new (struct TcpContext); ctx->s = s; ctx->data = data; GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_SECONDS, s, &tcp_send, ctx); diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index dd1aede5e..497371e86 100644 --- a/src/nat/nat_mini.c +++ b/src/nat/nat_mini.c @@ -172,7 +172,7 @@ GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout, } LOG (GNUNET_ERROR_TYPE_DEBUG, "Running `external-ip' to determine our external IP\n"); - eh = GNUNET_malloc (sizeof (struct GNUNET_NAT_ExternalHandle)); + eh = GNUNET_new (struct GNUNET_NAT_ExternalHandle); eh->cb = cb; eh->cb_cls = cb_cls; eh->opipe = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO, GNUNET_YES); @@ -507,7 +507,7 @@ GNUNET_NAT_mini_map_start (uint16_t port, int is_tcp, } LOG (GNUNET_ERROR_TYPE_DEBUG, "Running `upnpc' to install mapping\n"); - ret = GNUNET_malloc (sizeof (struct GNUNET_NAT_MiniHandle)); + ret = GNUNET_new (struct GNUNET_NAT_MiniHandle); ret->ac = ac; ret->ac_cls = ac_cls; ret->is_tcp = is_tcp; diff --git a/src/nse/gnunet-nse-profiler.c b/src/nse/gnunet-nse-profiler.c index 2dbca7541..3e39056be 100644 --- a/src/nse/gnunet-nse-profiler.c +++ b/src/nse/gnunet-nse-profiler.c @@ -511,7 +511,7 @@ connect_nse_service () (0 != (i % (num_peers_in_round[current_round] / connection_limit)))) continue; LOG_DEBUG ("Connecting to nse service of peer %d\n", i); - current_peer = GNUNET_malloc (sizeof (struct NSEPeer)); + current_peer = GNUNET_new (struct NSEPeer); current_peer->daemon = daemons[i]; current_peer->nse_op = GNUNET_TESTBED_service_connect (NULL, @@ -593,7 +593,7 @@ make_oplist_entry () { struct OpListEntry *entry; - entry = GNUNET_malloc (sizeof (struct OpListEntry)); + entry = GNUNET_new (struct OpListEntry); GNUNET_CONTAINER_DLL_insert_tail (oplist_head, oplist_tail, entry); return entry; } diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index e62df3047..f4a9d3aa6 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c @@ -364,7 +364,7 @@ print_peer_info (void *cls, const struct GNUNET_PeerIdentity *peer, GNUNET_i2s_full (peer)); return; } - pc = GNUNET_malloc (sizeof (struct PrintContext)); + pc = GNUNET_new (struct PrintContext); GNUNET_CONTAINER_DLL_insert (pc_head, pc_tail, pc); diff --git a/src/peerinfo-tool/gnunet-peerinfo_plugins.c b/src/peerinfo-tool/gnunet-peerinfo_plugins.c index 29dc4d017..37553f2f7 100644 --- a/src/peerinfo-tool/gnunet-peerinfo_plugins.c +++ b/src/peerinfo-tool/gnunet-peerinfo_plugins.c @@ -109,7 +109,7 @@ GPI_plugins_load (const struct GNUNET_CONFIGURATION_Handle *cfg) GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' transport plugin\n"), pos); GNUNET_asprintf (&libname, "libgnunet_plugin_transport_%s", pos); - plug = GNUNET_malloc (sizeof (struct TransportPlugin)); + plug = GNUNET_new (struct TransportPlugin); plug->short_name = GNUNET_strdup (pos); plug->lib_name = libname; plug->env.cfg = cfg; diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index a78855101..60ecaeb41 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -1138,7 +1138,7 @@ handle_notify (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received\n", "NOTIFY"); - nc = GNUNET_malloc (sizeof (struct NotificationContext)); + nc = GNUNET_new (struct NotificationContext); nc->client = client; nc->include_friend_only = ntohl (nm->include_friend_only); diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 794060487..716802389 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c @@ -201,7 +201,7 @@ GNUNET_PEERINFO_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_PEERINFO_Handle *h; - h = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_Handle)); + h = GNUNET_new (struct GNUNET_PEERINFO_Handle); h->client = GNUNET_CLIENT_connect ("peerinfo", cfg); h->cfg = cfg; return h; @@ -708,7 +708,7 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h, struct GNUNET_PEERINFO_IteratorContext *ic; struct GNUNET_PEERINFO_AddContext *ac; - ic = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_IteratorContext)); + ic = GNUNET_new (struct GNUNET_PEERINFO_IteratorContext); if (NULL == peer) { LOG (GNUNET_ERROR_TYPE_DEBUG, diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c index f5a076a20..af41b08f9 100644 --- a/src/peerinfo/peerinfo_api_notify.c +++ b/src/peerinfo/peerinfo_api_notify.c @@ -269,7 +269,7 @@ GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, "peerinfo"); return NULL; } - nc = GNUNET_malloc (sizeof (struct GNUNET_PEERINFO_NotifyContext)); + nc = GNUNET_new (struct GNUNET_PEERINFO_NotifyContext); nc->cfg = cfg; nc->client = client; nc->callback = callback; diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c index fdbc918c2..4b3cf5bcd 100644 --- a/src/regex/gnunet-regex-simulation-profiler.c +++ b/src/regex/gnunet-regex-simulation-profiler.c @@ -179,7 +179,7 @@ create_meter (unsigned int total, char *start_string, int print) { struct ProgressMeter *ret; - ret = GNUNET_malloc (sizeof (struct ProgressMeter)); + ret = GNUNET_new (struct ProgressMeter); ret->print = print; ret->total = total; ret->modnum = total / 4; diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index 1db1d0d5e..ac9eee07c 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c @@ -320,7 +320,7 @@ libgnunet_plugin_block_regex_init (void *cls) }; struct GNUNET_BLOCK_PluginFunctions *api; - api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions)); + api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); api->evaluate = &block_plugin_regex_evaluate; api->get_key = &block_plugin_regex_get_key; api->types = types; diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index 4e0d5acc5..2eeb48b3b 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c @@ -132,7 +132,7 @@ state_add_transition (struct REGEX_INTERNAL_Context *ctx, break; } - t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition)); + t = GNUNET_new (struct REGEX_INTERNAL_Transition); if (NULL != ctx) t->id = ctx->transition_id++; if (NULL != label) @@ -1774,7 +1774,7 @@ dfa_state_create (struct REGEX_INTERNAL_Context *ctx, struct REGEX_INTERNAL_Transition *ctran; unsigned int i; - s = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_State)); + s = GNUNET_new (struct REGEX_INTERNAL_State); s->id = ctx->state_id++; s->index = -1; s->lowlink = -1; @@ -2143,7 +2143,7 @@ dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, if (depth == ctx->stride) { - t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition)); + t = GNUNET_new (struct REGEX_INTERNAL_Transition); t->label = GNUNET_strdup (label); t->to_state = s; t->from_state = start; @@ -2258,7 +2258,7 @@ dfa_compress_paths_helper (struct REGEX_INTERNAL_Automaton *dfa, max_len == strlen (label)) || (start == dfa->start && GNUNET_REGEX_INITIAL_BYTES == strlen (label)))) { - t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition)); + t = GNUNET_new (struct REGEX_INTERNAL_Transition); t->label = GNUNET_strdup (label); t->to_state = cur; t->from_state = start; @@ -2375,7 +2375,7 @@ nfa_fragment_create (struct REGEX_INTERNAL_State *start, { struct REGEX_INTERNAL_Automaton *n; - n = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Automaton)); + n = GNUNET_new (struct REGEX_INTERNAL_Automaton); n->type = NFA; n->start = NULL; @@ -2448,7 +2448,7 @@ nfa_state_create (struct REGEX_INTERNAL_Context *ctx, int accepting) { struct REGEX_INTERNAL_State *s; - s = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_State)); + s = GNUNET_new (struct REGEX_INTERNAL_State); s->id = ctx->state_id++; s->accepting = accepting; s->marked = GNUNET_NO; @@ -3043,7 +3043,7 @@ REGEX_INTERNAL_construct_dfa (const char *regex, const size_t len, return NULL; } - dfa = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Automaton)); + dfa = GNUNET_new (struct REGEX_INTERNAL_Automaton); dfa->type = DFA; dfa->regex = GNUNET_strdup (regex); diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c index e87881902..f7d383406 100644 --- a/src/regex/regex_internal_dht.c +++ b/src/regex/regex_internal_dht.c @@ -187,7 +187,7 @@ REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht, struct REGEX_INTERNAL_Announcement *h; GNUNET_assert (NULL != dht); - h = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Announcement)); + h = GNUNET_new (struct REGEX_INTERNAL_Announcement); h->regex = regex; h->dht = dht; h->stats = stats; @@ -614,7 +614,7 @@ regex_next_edge (const struct RegexBlock *block, } hash = &ctx->hash; - new_ctx = GNUNET_malloc (sizeof (struct RegexSearchContext)); + new_ctx = GNUNET_new (struct RegexSearchContext); new_ctx->info = info; new_ctx->position = ctx->position + ctx->longest_match; GNUNET_array_append (info->contexts, info->n_contexts, new_ctx); @@ -693,7 +693,7 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht, LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_INTERNAL_search: %s\n", string); GNUNET_assert (NULL != dht); GNUNET_assert (NULL != callback); - h = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Search)); + h = GNUNET_new (struct REGEX_INTERNAL_Search); h->dht = dht; h->description = GNUNET_strdup (string); h->callback = callback; @@ -708,7 +708,7 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht, LOG (GNUNET_ERROR_TYPE_INFO, " initial key for %s: %s (%.*s)\n", string, GNUNET_h2s (&key), size, string); - ctx = GNUNET_malloc (sizeof (struct RegexSearchContext)); + ctx = GNUNET_new (struct RegexSearchContext); ctx->position = size; ctx->info = h; GNUNET_array_append (h->contexts, h->n_contexts, ctx); diff --git a/src/regex/regex_test_lib.c b/src/regex/regex_test_lib.c index 09d608e65..2f3abdc65 100644 --- a/src/regex/regex_test_lib.c +++ b/src/regex/regex_test_lib.c @@ -245,7 +245,7 @@ regex_add (struct RegexCombineCtx *ctx, const char *regex) len = strlen (p->s); if (prefix_l < len) /* only partial match, split existing state */ { - newctx = GNUNET_malloc (sizeof (struct RegexCombineCtx)); + newctx = GNUNET_new (struct RegexCombineCtx); newctx->head = p->head; newctx->tail = p->tail; newctx->s = GNUNET_malloc(len - prefix_l + 1); @@ -262,14 +262,14 @@ regex_add (struct RegexCombineCtx *ctx, const char *regex) if (NULL == ctx->head && NULL != ctx->s) { /* this was the end before, add empty string */ - newctx = GNUNET_malloc (sizeof (struct RegexCombineCtx)); + newctx = GNUNET_new (struct RegexCombineCtx); newctx->s = GNUNET_strdup (""); GNUNET_CONTAINER_DLL_insert (ctx->head, ctx->tail, newctx); } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " no match\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " new state %s\n", regex); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " under %s\n", ctx->s); - newctx = GNUNET_malloc (sizeof (struct RegexCombineCtx)); + newctx = GNUNET_new (struct RegexCombineCtx); newctx->s = GNUNET_strdup (regex); GNUNET_CONTAINER_DLL_insert (ctx->head, ctx->tail, newctx); } @@ -312,7 +312,7 @@ REGEX_TEST_combine (char * const regexes[]) const char *current; struct RegexCombineCtx *ctx; - ctx = GNUNET_malloc (sizeof (struct RegexCombineCtx)); + ctx = GNUNET_new (struct RegexCombineCtx); for (i = 0; regexes[i]; i++) { current = regexes[i]; diff --git a/src/set/ibf.c b/src/set/ibf.c index 4d40f1f35..152f9b190 100644 --- a/src/set/ibf.c +++ b/src/set/ibf.c @@ -78,7 +78,7 @@ ibf_create (uint32_t size, uint8_t hash_num) /* TODO: use malloc_large */ - ibf = GNUNET_malloc (sizeof (struct InvertibleBloomFilter)); + ibf = GNUNET_new (struct InvertibleBloomFilter); ibf->count = GNUNET_malloc (size * sizeof (uint8_t)); ibf->key_sum = GNUNET_malloc (size * sizeof (struct IBF_Key)); ibf->key_hash_sum = GNUNET_malloc (size * sizeof (struct IBF_KeyHash)); diff --git a/src/set/strata_estimator.c b/src/set/strata_estimator.c index c719a5836..a148c1488 100644 --- a/src/set/strata_estimator.c +++ b/src/set/strata_estimator.c @@ -89,7 +89,7 @@ strata_estimator_create (unsigned int strata_count, uint32_t ibf_size, uint8_t i /* fixme: allocate everything in one chunk */ - se = GNUNET_malloc (sizeof (struct StrataEstimator)); + se = GNUNET_new (struct StrataEstimator); se->strata_count = strata_count; se->ibf_size = ibf_size; se->strata = GNUNET_malloc (sizeof (struct InvertibleBloomFilter *) * strata_count); @@ -159,7 +159,7 @@ strata_estimator_dup (struct StrataEstimator *se) struct StrataEstimator *c; int i; - c = GNUNET_malloc (sizeof (struct StrataEstimator)); + c = GNUNET_new (struct StrataEstimator); c->strata_count = se->strata_count; c->ibf_size = se->ibf_size; c->strata = GNUNET_malloc (sizeof (struct InvertibleBloomFilter *) * se->strata_count); diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index d99ad8aec..04e85a07e 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -343,7 +343,7 @@ schedule_watch_request (struct GNUNET_STATISTICS_Handle *h, GNUNET_break (0); return; } - ai = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_GetHandle)); + ai = GNUNET_new (struct GNUNET_STATISTICS_GetHandle); ai->sh = h; ai->subsystem = GNUNET_strdup (watch->subsystem); ai->name = GNUNET_strdup (watch->name); @@ -932,7 +932,7 @@ GNUNET_STATISTICS_create (const char *subsystem, return NULL; GNUNET_assert (NULL != subsystem); GNUNET_assert (NULL != cfg); - ret = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_Handle)); + ret = GNUNET_new (struct GNUNET_STATISTICS_Handle); ret->cfg = cfg; ret->subsystem = GNUNET_strdup (subsystem); ret->backoff = GNUNET_TIME_UNIT_MILLISECONDS; @@ -1158,7 +1158,7 @@ GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, slen2 = strlen (name) + 1; GNUNET_assert (slen1 + slen2 + sizeof (struct GNUNET_MessageHeader) < GNUNET_SERVER_MAX_MESSAGE_SIZE); - ai = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_GetHandle)); + ai = GNUNET_new (struct GNUNET_STATISTICS_GetHandle); ai->sh = handle; ai->subsystem = GNUNET_strdup (subsystem); ai->name = GNUNET_strdup (name); @@ -1220,7 +1220,7 @@ GNUNET_STATISTICS_watch (struct GNUNET_STATISTICS_Handle *handle, if (NULL == handle) return GNUNET_SYSERR; - w = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_WatchEntry)); + w = GNUNET_new (struct GNUNET_STATISTICS_WatchEntry); w->subsystem = GNUNET_strdup (subsystem); w->name = GNUNET_strdup (name); w->proc = proc; @@ -1354,7 +1354,7 @@ add_setter_action (struct GNUNET_STATISTICS_Handle *h, const char *name, return; } /* no existing entry matches, create a fresh one */ - ai = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_GetHandle)); + ai = GNUNET_new (struct GNUNET_STATISTICS_GetHandle); ai->sh = h; ai->subsystem = GNUNET_strdup (h->subsystem); ai->name = GNUNET_strdup (name); diff --git a/src/testbed/gnunet-helper-testbed.c b/src/testbed/gnunet-helper-testbed.c index 4c68b2cd4..e8c70a354 100644 --- a/src/testbed/gnunet-helper-testbed.c +++ b/src/testbed/gnunet-helper-testbed.c @@ -480,7 +480,7 @@ tokenizer_cb (void *cls, void *client, xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); GNUNET_free (config); - wc = GNUNET_malloc (sizeof (struct WriteContext)); + wc = GNUNET_new (struct WriteContext); wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply); reply = GNUNET_realloc (xconfig, wc->length); memmove (&reply[1], reply, xconfig_size); diff --git a/src/testbed/gnunet-service-testbed-logger.c b/src/testbed/gnunet-service-testbed-logger.c index dfa9da52f..8129c7cbf 100644 --- a/src/testbed/gnunet-service-testbed-logger.c +++ b/src/testbed/gnunet-service-testbed-logger.c @@ -145,7 +145,7 @@ queue_message (struct GNUNET_SERVER_Client *client, type = ntohs (msg->type); size = ntohs (msg->size); - mq_entry = GNUNET_malloc (sizeof (struct MessageQueue)); + mq_entry = GNUNET_new (struct MessageQueue); mq_entry->msg = msg; mq_entry->client = client; GNUNET_SERVER_client_keep (client); diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 6f806e21b..a1d6aed09 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c @@ -191,7 +191,7 @@ GST_queue_message (struct GNUNET_SERVER_Client *client, size = ntohs (msg->size); GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) && (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type)); - mq_entry = GNUNET_malloc (sizeof (struct MessageQueue)); + mq_entry = GNUNET_new (struct MessageQueue); mq_entry->msg = msg; mq_entry->client = client; GNUNET_SERVER_client_keep (client); @@ -364,7 +364,7 @@ GST_queue_host_registration (struct Slave *slave, "Queueing host registration for host %u at %u\n", GNUNET_TESTBED_host_get_id_ (host), GNUNET_TESTBED_host_get_id_ (GST_host_list[slave->host_id])); - hr = GNUNET_malloc (sizeof (struct HostRegistration)); + hr = GNUNET_new (struct HostRegistration); hr->cb = cb; hr->cb_cls = cb_cls; hr->host = host; @@ -525,7 +525,7 @@ handle_init (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_free (ss_str); ss_str = NULL; } - GST_context = GNUNET_malloc (sizeof (struct Context)); + GST_context = GNUNET_new (struct Context); GNUNET_SERVER_client_keep (client); GST_context->client = client; GST_context->host_id = ntohl (msg->host_id); diff --git a/src/testbed/gnunet-service-testbed_barriers.c b/src/testbed/gnunet-service-testbed_barriers.c index 482d0ddcd..de2c175f1 100644 --- a/src/testbed/gnunet-service-testbed_barriers.c +++ b/src/testbed/gnunet-service-testbed_barriers.c @@ -306,7 +306,7 @@ queue_message (struct ClientCtx *ctx, struct GNUNET_MessageHeader *msg) struct MessageQueue *mq; struct GNUNET_SERVER_Client *client = ctx->client; - mq = GNUNET_malloc (sizeof (struct MessageQueue)); + mq = GNUNET_new (struct MessageQueue); mq->msg = msg; LOG_DEBUG ("Queueing message of type %u, size %u for sending\n", ntohs (msg->type), ntohs (msg->size)); @@ -494,7 +494,7 @@ handle_barrier_wait (void *cls, struct GNUNET_SERVER_Client *client, client_ctx = GNUNET_SERVER_client_get_user_context (client, struct ClientCtx); if (NULL == client_ctx) { - client_ctx = GNUNET_malloc (sizeof (struct ClientCtx)); + client_ctx = GNUNET_new (struct ClientCtx); client_ctx->client = client; GNUNET_SERVER_client_keep (client); client_ctx->barrier = barrier; @@ -747,7 +747,7 @@ GST_handle_barrier_init (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_SERVER_receive_done (client, GNUNET_OK); return; } - barrier = GNUNET_malloc (sizeof (struct Barrier)); + barrier = GNUNET_new (struct Barrier); (void) memcpy (&barrier->hash, &hash, sizeof (struct GNUNET_HashCode)); barrier->quorum = msg->quorum; barrier->name = name; @@ -769,7 +769,7 @@ GST_handle_barrier_init (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_break (0);/* May happen when we are connecting to the controller */ continue; } - wrapper = GNUNET_malloc (sizeof (struct WBarrier)); + wrapper = GNUNET_new (struct WBarrier); wrapper->barrier = barrier; GNUNET_CONTAINER_DLL_insert_tail (barrier->whead, barrier->wtail, wrapper); wrapper->hbarrier = GNUNET_TESTBED_barrier_init_ (slave->controller, diff --git a/src/testbed/gnunet-service-testbed_cache.c b/src/testbed/gnunet-service-testbed_cache.c index 50ffe7679..7f2a35a7d 100644 --- a/src/testbed/gnunet-service-testbed_cache.c +++ b/src/testbed/gnunet-service-testbed_cache.c @@ -132,7 +132,7 @@ add_entry (unsigned int peer_id) entry->peer_id, entry)); } - entry = GNUNET_malloc (sizeof (struct CacheEntry)); + entry = GNUNET_new (struct CacheEntry); entry->peer_id = peer_id; GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap32_put (cache, diff --git a/src/testbed/gnunet-service-testbed_links.c b/src/testbed/gnunet-service-testbed_links.c index 766c47471..cb908f12b 100644 --- a/src/testbed/gnunet-service-testbed_links.c +++ b/src/testbed/gnunet-service-testbed_links.c @@ -970,7 +970,7 @@ GST_neighbour_get_connection (struct Neighbour *n, GNUNET_assert (NULL != cb); LOG_DEBUG ("Attempting to get connection to controller on host %u\n", n->host_id); - h = GNUNET_malloc (sizeof (struct NeighbourConnectNotification)); + h = GNUNET_new (struct NeighbourConnectNotification); h->n = n; h->cb = cb; h->cb_cls = cb_cls; @@ -1163,7 +1163,7 @@ GST_create_neighbour (struct GNUNET_TESTBED_Host *host) { struct Neighbour *n; - n = GNUNET_malloc (sizeof (struct Neighbour)); + n = GNUNET_new (struct Neighbour); n->host_id = GNUNET_TESTBED_host_get_id_ (host); neighbour_list_add (n); /* just add; connect on-demand */ return n; @@ -1249,7 +1249,7 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, LOG_DEBUG ("Received request to establish a link to host %u\n", delegated_host_id); n = GST_create_neighbour (GST_host_list[delegated_host_id]); - ncc = GNUNET_malloc (sizeof (struct NeighbourConnectCtxt)); + ncc = GNUNET_new (struct NeighbourConnectCtxt); ncc->n = n; ncc->op_id = op_id; ncc->client = client; @@ -1271,11 +1271,11 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, } LOG_DEBUG ("Received request to start and establish a link to host %u\n", delegated_host_id); - slave = GNUNET_malloc (sizeof (struct Slave)); + slave = GNUNET_new (struct Slave); slave->host_id = delegated_host_id; slave->reghost_map = GNUNET_CONTAINER_multihashmap_create (100, GNUNET_NO); slave_list_add (slave); - lcc = GNUNET_malloc (sizeof (struct LinkControllersContext)); + lcc = GNUNET_new (struct LinkControllersContext); lcc->operation_id = op_id; GNUNET_SERVER_client_keep (client); lcc->client = client; @@ -1284,7 +1284,7 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_TESTBED_controller_start (GST_context->master_ip, GST_host_list[slave->host_id], &slave_status_cb, slave); - new_route = GNUNET_malloc (sizeof (struct Route)); + new_route = GNUNET_new (struct Route); new_route->dest = delegated_host_id; new_route->thru = GST_context->host_id; route_list_add (new_route); @@ -1298,8 +1298,8 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - lcfq = GNUNET_malloc (sizeof (struct LCFContextQueue)); - lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext)); + lcfq = GNUNET_new (struct LCFContextQueue); + lcfq->lcf = GNUNET_new (struct LCFContext); lcfq->lcf->delegated_host_id = delegated_host_id; lcfq->lcf->slave_host_id = slave_host_id; route = GST_find_dest_route (slave_host_id); @@ -1335,7 +1335,7 @@ GST_handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - new_route = GNUNET_malloc (sizeof (struct Route)); + new_route = GNUNET_new (struct Route); new_route->dest = delegated_host_id; new_route->thru = route->dest; route_list_add (new_route); diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index 5ea6e48e1..c2978728c 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c @@ -444,7 +444,7 @@ GST_process_next_focc (struct RegisteredHostContext *rhc) peer = GST_peer_list[focc->peer1]; GNUNET_assert (GNUNET_YES == peer->is_remote); GNUNET_assert (NULL != (slave = peer->details.remote.slave)); - fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); + fopc = GNUNET_new (struct ForwardedOperationContext); GNUNET_SERVER_client_keep (focc->client); fopc->client = focc->client; fopc->operation_id = focc->operation_id; @@ -605,7 +605,7 @@ send_overlay_connect_success_msg (struct OverlayConnectContext *occ) LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n", occ->op_id); - msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); + msg = GNUNET_new (struct GNUNET_TESTBED_ConnectionEventMessage); msg->header.size = htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT); @@ -1223,7 +1223,7 @@ register_host (struct Slave *slave, struct GNUNET_TESTBED_Host *host) struct GNUNET_HashCode hash; struct RegisteredHostContext *rhc; - rhc = GNUNET_malloc (sizeof (struct RegisteredHostContext)); + rhc = GNUNET_new (struct RegisteredHostContext); rhc->reg_host = host; rhc->host = GST_host_list[slave->host_id]; GNUNET_assert (NULL != rhc->reg_host); @@ -1304,7 +1304,7 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, GST_host_list[peer2_host_id]))) { LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2); - focc = GNUNET_malloc (sizeof (struct ForwardedOverlayConnectContext)); + focc = GNUNET_new (struct ForwardedOverlayConnectContext); focc->peer1 = p1; focc->peer2 = p2; focc->peer2_host_id = peer2_host_id; @@ -1319,7 +1319,7 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, forward: LOG_DEBUG ("Forwarding without FOCC for connecting peers %u and %u\n", p1, p2); - fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); + fopc = GNUNET_new (struct ForwardedOperationContext); GNUNET_SERVER_client_keep (client); fopc->client = client; fopc->operation_id = op_id; @@ -1429,7 +1429,7 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, return; } p2n = NULL; - occ = GNUNET_malloc (sizeof (struct OverlayConnectContext)); + occ = GNUNET_new (struct OverlayConnectContext); occ->type = OCC_TYPE_LOCAL; if (!VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */ { @@ -1743,7 +1743,7 @@ GST_handle_remote_overlay_connect (void *cls, GNUNET_SERVER_receive_done (client, GNUNET_OK); return; } - rocc = GNUNET_malloc (sizeof (struct RemoteOverlayConnectCtx)); + rocc = GNUNET_new (struct RemoteOverlayConnectCtx); rocc->op_id = GNUNET_ntohll (msg->operation_id); GNUNET_CONTAINER_DLL_insert_tail (roccq_head, roccq_tail, rocc); memcpy (&rocc->a_id, &msg->peer_identity, diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 2ee17c9e0..a65102ead 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c @@ -200,7 +200,7 @@ exop_insert (struct GNUNET_TESTBED_Operation *op) { struct ExpireOperationEntry *entry; - entry = GNUNET_malloc (sizeof (struct ExpireOperationEntry)); + entry = GNUNET_new (struct ExpireOperationEntry); entry->op = op; GNUNET_CONTAINER_DLL_insert_tail (exop_head, exop_tail, entry); } @@ -737,7 +737,7 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, peer = data->peer; GNUNET_assert (NULL != peer); GNUNET_assert (ntohl (msg->peer_id) == peer->unique_id); - pinfo = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerInformation)); + pinfo = GNUNET_new (struct GNUNET_TESTBED_PeerInformation); pinfo->pit = data->pit; cb = data->cb; cb_cls = data->cb_cls; @@ -747,7 +747,7 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, switch (pinfo->pit) { case GNUNET_TESTBED_PIT_IDENTITY: - pinfo->result.id = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); + pinfo->result.id = GNUNET_new (struct GNUNET_PeerIdentity); (void) memcpy (pinfo->result.id, &msg->peer_identity, sizeof (struct GNUNET_PeerIdentity)); break; @@ -1253,7 +1253,7 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, size = ntohs (msg->size); GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) && (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type)); - mq_entry = GNUNET_malloc (sizeof (struct MessageQueue)); + mq_entry = GNUNET_new (struct MessageQueue); mq_entry->msg = msg; LOG (GNUNET_ERROR_TYPE_DEBUG, "Queueing message of type %u, size %u for sending\n", type, @@ -1295,10 +1295,10 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller struct GNUNET_MessageHeader *dup_msg; uint16_t msize; - data = GNUNET_malloc (sizeof (struct ForwardedOperationData)); + data = GNUNET_new (struct ForwardedOperationData); data->cc = cc; data->cc_cls = cc_cls; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->c = controller; opc->type = OP_FORWARDED; opc->data = data; @@ -1482,7 +1482,7 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host, GNUNET_break (0); return NULL; } - controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller)); + controller = GNUNET_new (struct GNUNET_TESTBED_Controller); controller->cc = cc; controller->cc_cls = cc_cls; controller->event_mask = event_mask; @@ -1706,10 +1706,10 @@ GNUNET_TESTBED_controller_link (void *op_cls, msg->delegated_host_id = htonl (delegated_host_id); msg->slave_host_id = htonl (slave_host_id); msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0; - data = GNUNET_malloc (sizeof (struct ControllerLinkData)); + data = GNUNET_new (struct ControllerLinkData); data->msg = msg; data->host_id = delegated_host_id; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->c = master; opc->data = data; opc->type = OP_LINK_CONTROLLERS; @@ -1747,9 +1747,9 @@ GNUNET_TESTBED_get_slave_config_ (void *op_cls, struct OperationContext *opc; struct GetSlaveConfigData *data; - data = GNUNET_malloc (sizeof (struct GetSlaveConfigData)); + data = GNUNET_new (struct GetSlaveConfigData); data->slave_id = slave_host_id; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->state = OPC_STATE_INIT; opc->c = master; opc->id = GNUNET_TESTBED_get_next_op_id (master); @@ -2076,7 +2076,7 @@ opstart_shutdown_peers (void *cls) struct GNUNET_TESTBED_ShutdownPeersMessage *msg; opc->state = OPC_STATE_STARTED; - msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ShutdownPeersMessage)); + msg = GNUNET_new (struct GNUNET_TESTBED_ShutdownPeersMessage); msg->header.size = htons (sizeof (struct GNUNET_TESTBED_ShutdownPeersMessage)); msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS); @@ -2137,10 +2137,10 @@ GNUNET_TESTBED_shutdown_peers (struct GNUNET_TESTBED_Controller *c, if (0 != GNUNET_CONTAINER_multihashmap32_size (c->opc_map)) return NULL; - data = GNUNET_malloc (sizeof (struct ShutdownPeersData)); + data = GNUNET_new (struct ShutdownPeersData); data->cb = cb; data->cb_cls = cb_cls; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->c = c; opc->op_cls = op_cls; opc->data = data; diff --git a/src/testbed/testbed_api_barriers.c b/src/testbed/testbed_api_barriers.c index 2ec34bb1b..e407b173e 100644 --- a/src/testbed/testbed_api_barriers.c +++ b/src/testbed/testbed_api_barriers.c @@ -234,7 +234,7 @@ GNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller, return NULL; } LOG_DEBUG ("Initialising barrier `%s'\n", name); - barrier = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Barrier)); + barrier = GNUNET_new (struct GNUNET_TESTBED_Barrier); barrier->c = controller; barrier->name = GNUNET_strdup (name); barrier->cb = cb; @@ -488,7 +488,7 @@ GNUNET_TESTBED_barrier_wait (const char *name, GNUNET_CONFIGURATION_destroy (cfg); return NULL; } - h = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_BarrierWaitHandle)); + h = GNUNET_new (struct GNUNET_TESTBED_BarrierWaitHandle); h->name = GNUNET_strdup (name); h->cfg = cfg; h->conn = GNUNET_CLIENT_connect ("testbed-barrier", h->cfg); diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index 8af8e23d0..5a5b00e5a 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c @@ -331,7 +331,7 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname, LOG (GNUNET_ERROR_TYPE_WARNING, "Host with id: %u already created\n", id); return NULL; } - host = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host)); + host = GNUNET_new (struct GNUNET_TESTBED_Host); host->hostname = (NULL != hostname) ? GNUNET_strdup (hostname) : NULL; host->username = (NULL != username) ? GNUNET_strdup (username) : NULL; host->id = id; @@ -649,7 +649,7 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, return; } } - rc = GNUNET_malloc (sizeof (struct RegisteredController)); + rc = GNUNET_new (struct RegisteredController); rc->controller = controller; GNUNET_CONTAINER_DLL_insert_tail (host->rc_head, host->rc_tail, rc); } @@ -1079,7 +1079,7 @@ GNUNET_TESTBED_controller_start (const char *trusted_ip, host->locked = GNUNET_YES; API_VIOLATION (GNUNET_NO == host->controller_started, "Attempting to start a controller on a host which is already started a controller"); - cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc)); + cp = GNUNET_new (struct GNUNET_TESTBED_ControllerProc); if (0 == GNUNET_TESTBED_host_get_id_ (host)) { cp->helper = @@ -1324,7 +1324,7 @@ GNUNET_TESTBED_is_host_habitable (const struct GNUNET_TESTBED_Host *host, const char *hostname; char *port; - h = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HostHabitableCheckHandle)); + h = GNUNET_new (struct GNUNET_TESTBED_HostHabitableCheckHandle); h->cb = cb; h->cb_cls = cb_cls; h->host = host; @@ -1449,7 +1449,7 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, (NULL == hostname) ? "localhost" : hostname); return NULL; } - rh = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HostRegistrationHandle)); + rh = GNUNET_new (struct GNUNET_TESTBED_HostRegistrationHandle); rh->host = host; rh->c = controller; GNUNET_assert (NULL != cc); diff --git a/src/testbed/testbed_api_operations.c b/src/testbed/testbed_api_operations.c index ce2ef5715..2a559a90e 100644 --- a/src/testbed/testbed_api_operations.c +++ b/src/testbed/testbed_api_operations.c @@ -455,7 +455,7 @@ change_state (struct GNUNET_TESTBED_Operation *op, enum OperationState state) { if (OP_STATE_INIT == op->state) { - entry = GNUNET_malloc (sizeof (struct QueueEntry)); + entry = GNUNET_new (struct QueueEntry); entry->op = op; entry->nres = op->nres[cnt]; s = cnt; @@ -557,7 +557,7 @@ rq_add (struct GNUNET_TESTBED_Operation *op) struct ReadyQueueEntry *rq_entry; GNUNET_assert (NULL == op->rq_entry); - rq_entry = GNUNET_malloc (sizeof (struct ReadyQueueEntry)); + rq_entry = GNUNET_new (struct ReadyQueueEntry); rq_entry->op = op; GNUNET_CONTAINER_DLL_insert_tail (rq_head, rq_tail, rq_entry); op->rq_entry = rq_entry; @@ -970,7 +970,7 @@ GNUNET_TESTBED_operation_create_ (void *cls, OperationStart start, { struct GNUNET_TESTBED_Operation *op; - op = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Operation)); + op = GNUNET_new (struct GNUNET_TESTBED_Operation); op->start = start; op->state = OP_STATE_INIT; op->release = release; @@ -994,7 +994,7 @@ GNUNET_TESTBED_operation_queue_create_ (enum OperationQueueType type, struct OperationQueue *queue; struct FeedbackCtx *fctx; - queue = GNUNET_malloc (sizeof (struct OperationQueue)); + queue = GNUNET_new (struct OperationQueue); queue->type = type; if (OPERATION_QUEUE_TYPE_FIXED == type) { @@ -1002,7 +1002,7 @@ GNUNET_TESTBED_operation_queue_create_ (enum OperationQueueType type, } else { - fctx = GNUNET_malloc (sizeof (struct FeedbackCtx)); + fctx = GNUNET_new (struct FeedbackCtx); fctx->max_active_bound = max_active; fctx->sd = GNUNET_TESTBED_SD_init_ (10); /* FIXME: Why 10? */ queue->fctx = fctx; diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index 5d55e3ef6..a8a87c057 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c @@ -167,7 +167,7 @@ opstart_peer_destroy (void *cls) GNUNET_assert (OP_PEER_DESTROY == opc->type); GNUNET_assert (NULL != peer); opc->state = OPC_STATE_STARTED; - msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)); + msg = GNUNET_new (struct GNUNET_TESTBED_PeerDestroyMessage); msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)); msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER); msg->peer_id = htonl (peer->unique_id); @@ -219,7 +219,7 @@ opstart_peer_start (void *cls) GNUNET_assert (NULL != (peer = data->peer)); GNUNET_assert ((TESTBED_PS_CREATED == peer->state) || (TESTBED_PS_STOPPED == peer->state)); opc->state = OPC_STATE_STARTED; - msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStartMessage)); + msg = GNUNET_new (struct GNUNET_TESTBED_PeerStartMessage); msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerStartMessage)); msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_START_PEER); msg->peer_id = htonl (peer->unique_id); @@ -271,7 +271,7 @@ opstart_peer_stop (void *cls) GNUNET_assert (NULL != (peer = data->peer)); GNUNET_assert (TESTBED_PS_STARTED == peer->state); opc->state = OPC_STATE_STARTED; - msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStopMessage)); + msg = GNUNET_new (struct GNUNET_TESTBED_PeerStopMessage); msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER); msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerStopMessage)); msg->peer_id = htonl (peer->unique_id); @@ -410,7 +410,7 @@ opstart_overlay_connect (void *cls) opc->state = OPC_STATE_STARTED; data = opc->data; GNUNET_assert (NULL != data); - msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)); + msg = GNUNET_new (struct GNUNET_TESTBED_OverlayConnectMessage); msg->header.size = htons (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)); msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT); @@ -570,18 +570,18 @@ GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller, struct OperationContext *opc; static uint32_t id_gen; - peer = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer)); + peer = GNUNET_new (struct GNUNET_TESTBED_Peer); peer->controller = controller; peer->host = host; peer->unique_id = id_gen++; peer->state = TESTBED_PS_INVALID; - data = GNUNET_malloc (sizeof (struct PeerCreateData)); + data = GNUNET_new (struct PeerCreateData); data->host = host; data->cfg = cfg; data->cb = cb; data->cls = cls; data->peer = peer; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->c = controller; opc->data = data; opc->id = GNUNET_TESTBED_get_next_op_id (controller); @@ -613,11 +613,11 @@ GNUNET_TESTBED_peer_start (void *op_cls, struct GNUNET_TESTBED_Peer *peer, struct OperationContext *opc; struct PeerEventData *data; - data = GNUNET_malloc (sizeof (struct PeerEventData)); + data = GNUNET_new (struct PeerEventData); data->peer = peer; data->pcc = pcc; data->pcc_cls = pcc_cls; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->c = peer->controller; opc->data = data; opc->op_cls = op_cls; @@ -653,11 +653,11 @@ GNUNET_TESTBED_peer_stop (void *op_cls, struct OperationContext *opc; struct PeerEventData *data; - data = GNUNET_malloc (sizeof (struct PeerEventData)); + data = GNUNET_new (struct PeerEventData); data->peer = peer; data->pcc = pcc; data->pcc_cls = pcc_cls; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->c = peer->controller; opc->data = data; opc->op_cls = op_cls; @@ -698,12 +698,12 @@ GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC != pit); GNUNET_assert (NULL != cb); - data = GNUNET_malloc (sizeof (struct PeerInfoData)); + data = GNUNET_new (struct PeerInfoData); data->peer = peer; data->pit = pit; data->cb = cb; data->cb_cls = cb_cls; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->c = peer->controller; opc->data = data; opc->type = OP_PEER_INFO; @@ -737,7 +737,7 @@ GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, struct PeerReconfigureData *data; size_t csize; - data = GNUNET_malloc (sizeof (struct PeerReconfigureData)); + data = GNUNET_new (struct PeerReconfigureData); data->peer = peer; data->config = GNUNET_CONFIGURATION_serialize (cfg, &csize); if (NULL == data->config) @@ -753,7 +753,7 @@ GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, return NULL; } data->cfg_size = (uint16_t) csize; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->c = peer->controller; opc->data = data; opc->type = OP_PEER_RECONFIGURE; @@ -780,7 +780,7 @@ GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) { struct OperationContext *opc; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->data = peer; opc->c = peer->controller; opc->id = GNUNET_TESTBED_get_next_op_id (peer->controller); @@ -843,12 +843,12 @@ GNUNET_TESTBED_overlay_connect (void *op_cls, struct OverlayConnectData *data; GNUNET_assert ((TESTBED_PS_STARTED == p1->state) && (TESTBED_PS_STARTED == p2->state)); - data = GNUNET_malloc (sizeof (struct OverlayConnectData)); + data = GNUNET_new (struct OverlayConnectData); data->p1 = p1; data->p2 = p2; data->cb = cb; data->cb_cls = cb_cls; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->data = data; opc->c = p1->controller; opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); @@ -953,14 +953,14 @@ GNUNET_TESTBED_peer_manage_service (void *op_cls, msize += sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage); if (GNUNET_SERVER_MAX_MESSAGE_SIZE < msize) return NULL; - data = GNUNET_malloc (sizeof (struct ManageServiceData)); + data = GNUNET_new (struct ManageServiceData); data->cb = cb; data->cb_cls = cb_cls; data->peer = peer; data->service_name = GNUNET_strdup (service_name); data->start = start; data->msize = (uint16_t) msize; - opc = GNUNET_malloc (sizeof (struct OperationContext)); + opc = GNUNET_new (struct OperationContext); opc->data = data; opc->c = peer->controller; opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); diff --git a/src/testbed/testbed_api_sd.c b/src/testbed/testbed_api_sd.c index 7a1da6b80..08f697248 100644 --- a/src/testbed/testbed_api_sd.c +++ b/src/testbed/testbed_api_sd.c @@ -109,7 +109,7 @@ GNUNET_TESTBED_SD_init_ (unsigned int max_cnt) struct SDHandle *h; GNUNET_assert (1 < max_cnt); - h = GNUNET_malloc (sizeof (struct SDHandle)); + h = GNUNET_new (struct SDHandle); h->max_cnt = max_cnt; return h; } @@ -159,7 +159,7 @@ GNUNET_TESTBED_SD_add_data_ (struct SDHandle *h, unsigned int amount) } GNUNET_assert (h->cnt < h->max_cnt); if (NULL == entry) - entry = GNUNET_malloc (sizeof (struct SDEntry)); + entry = GNUNET_new (struct SDEntry); entry->amount = amount; GNUNET_CONTAINER_DLL_insert_tail (h->head, h->tail, entry); h->sum += amount; diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c index 86ec284ed..2c390719e 100644 --- a/src/testbed/testbed_api_services.c +++ b/src/testbed/testbed_api_services.c @@ -263,7 +263,7 @@ GNUNET_TESTBED_service_connect (void *op_cls, struct GNUNET_TESTBED_Peer *peer, { struct ServiceConnectData *data; - data = GNUNET_malloc (sizeof (struct ServiceConnectData)); + data = GNUNET_new (struct ServiceConnectData); data->ca = ca; data->da = da; data->cada_cls = cada_cls; diff --git a/src/testbed/testbed_api_statistics.c b/src/testbed/testbed_api_statistics.c index 5fa0750e3..e6efc1fb0 100644 --- a/src/testbed/testbed_api_statistics.c +++ b/src/testbed/testbed_api_statistics.c @@ -340,7 +340,7 @@ opstart_get_stats (void *cls) GNUNET_break (0); continue; } - peer_sc = GNUNET_malloc (sizeof (struct PeerGetStatsContext)); + peer_sc = GNUNET_new (struct PeerGetStatsContext); peer_sc->sc = sc; peer_sc->peer_index = peer; sc->ops[peer] = @@ -417,7 +417,7 @@ GNUNET_TESTBED_get_statistics (unsigned int num_peers, if (NULL == no_wait_queue) no_wait_queue = GNUNET_TESTBED_operation_queue_create_ (OPERATION_QUEUE_TYPE_FIXED, UINT_MAX); - sc = GNUNET_malloc (sizeof (struct GetStatsContext)); + sc = GNUNET_new (struct GetStatsContext); sc->peers = peers; sc->subsystem = (NULL == subsystem) ? NULL : GNUNET_strdup (subsystem); sc->name = (NULL == name) ? NULL : GNUNET_strdup (name); diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 0bad02a7f..cbfc4812d 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c @@ -592,7 +592,7 @@ wait_op_completion (void *cls) if (NULL == rc->peers) goto cleanup_; rc->shutdown = GNUNET_YES; - rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); + rcop = GNUNET_new (struct RunContextOperation); rcop->rc = rc; rcop->op = GNUNET_TESTBED_shutdown_peers (rc->c, rcop, NULL, NULL); GNUNET_assert (NULL != rcop->op); @@ -673,7 +673,7 @@ start_peers_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) rc->pstart_time = GNUNET_TIME_absolute_get (); for (peer = 0; peer < rc->num_peers; peer++) { - rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); + rcop = GNUNET_new (struct RunContextOperation); rcop->rc = rc; rcop->op = GNUNET_TESTBED_peer_start (NULL, rc->peers[peer], NULL, NULL); GNUNET_assert (NULL != rcop->op); @@ -782,7 +782,7 @@ create_peers (struct GNUNET_TESTBED_RunHandle *rc) rc->peer_count = 0; for (peer = 0; peer < rc->num_peers; peer++) { - rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); + rcop = GNUNET_new (struct RunContextOperation); rcop->rc = rc; rcop->op = GNUNET_TESTBED_peer_create (rc->c, @@ -1014,7 +1014,7 @@ register_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Start slaves */ for (slave = 0; slave < rc->num_hosts; slave++) { - rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); + rcop = GNUNET_new (struct RunContextOperation); rcop->rc = rc; rcop->op = GNUNET_TESTBED_controller_link (rcop, rc->c, rc->hosts[slave], @@ -1253,7 +1253,7 @@ GNUNET_TESTBED_run (const char *host_filename, unsigned int nhost; GNUNET_assert (num_peers > 0); - rc = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_RunHandle)); + rc = GNUNET_new (struct GNUNET_TESTBED_RunHandle); rc->cfg = GNUNET_CONFIGURATION_dup (cfg); #if ENABLE_SUPERMUC rc->num_hosts = GNUNET_TESTBED_hosts_load_from_loadleveler (rc->cfg, diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c index 8d8883c96..d4eaec0c5 100644 --- a/src/testbed/testbed_api_topology.c +++ b/src/testbed/testbed_api_topology.c @@ -275,7 +275,7 @@ overlay_link_completed (void *cls, struct GNUNET_TESTBED_Operation *op, { LOG (GNUNET_ERROR_TYPE_WARNING, "Error while establishing a link: %s -- Retrying\n", emsg); - retry_entry = GNUNET_malloc (sizeof (struct RetryListEntry)); + retry_entry = GNUNET_new (struct RetryListEntry); retry_entry->link = link; GNUNET_CONTAINER_DLL_insert_tail (tc->rl_head, tc->rl_tail, retry_entry); } @@ -923,7 +923,7 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, if (num_peers < 2) return NULL; c = peers[0]->controller; - tc = GNUNET_malloc (sizeof (struct TopologyContext)); + tc = GNUNET_new (struct TopologyContext); tc->peers = peers; tc->num_peers = num_peers; tc->op_cls = op_cls; diff --git a/src/testbed/testbed_logger_api.c b/src/testbed/testbed_logger_api.c index 562902218..399e26a2f 100644 --- a/src/testbed/testbed_logger_api.c +++ b/src/testbed/testbed_logger_api.c @@ -277,7 +277,7 @@ queue_message (struct GNUNET_TESTBED_LOGGER_Handle *h, type = ntohs (msg->type); size = ntohs (msg->size); - mq = GNUNET_malloc (sizeof (struct MessageQueue)); + mq = GNUNET_new (struct MessageQueue); mq->msg = msg; LOG (GNUNET_ERROR_TYPE_DEBUG, "Queueing message of type %u, size %u for sending\n", type, @@ -333,7 +333,7 @@ GNUNET_TESTBED_LOGGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) client = GNUNET_CLIENT_connect ("testbed-logger", cfg); if (NULL == client) return NULL; - h = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_LOGGER_Handle)); + h = GNUNET_new (struct GNUNET_TESTBED_LOGGER_Handle); h->client = client; return h; } diff --git a/src/testing/test_testing_peerstartup.c b/src/testing/test_testing_peerstartup.c index b871ed1e3..e025b4138 100644 --- a/src/testing/test_testing_peerstartup.c +++ b/src/testing/test_testing_peerstartup.c @@ -95,7 +95,7 @@ run (void *cls, char *const *args, const char *cfgfile, char *emsg; struct GNUNET_PeerIdentity id; - test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); + test_ctx = GNUNET_new (struct TestingContext); test_ctx->system = GNUNET_TESTING_system_create ("test-gnunet-testing", "127.0.0.1", NULL, NULL); diff --git a/src/testing/test_testing_peerstartup2.c b/src/testing/test_testing_peerstartup2.c index a4bdd4d65..2bdae72eb 100644 --- a/src/testing/test_testing_peerstartup2.c +++ b/src/testing/test_testing_peerstartup2.c @@ -164,7 +164,7 @@ run (void *cls, char *const *args, const char *cfgfile, char *emsg; struct GNUNET_PeerIdentity id; - test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); + test_ctx = GNUNET_new (struct TestingContext); test_ctx->system = GNUNET_TESTING_system_create ("test-gnunet-testing", "127.0.0.1", NULL, NULL); diff --git a/src/testing/test_testing_sharedservices.c b/src/testing/test_testing_sharedservices.c index 5b5bc0a24..e2f956e62 100644 --- a/src/testing/test_testing_sharedservices.c +++ b/src/testing/test_testing_sharedservices.c @@ -107,7 +107,7 @@ run (void *cls, char *const *args, const char *cfgfile, struct GNUNET_TESTING_Peer *peer; unsigned int cnt; - test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); + test_ctx = GNUNET_new (struct TestingContext); test_ctx->system = GNUNET_TESTING_system_create ("test-gnunet-testing", "127.0.0.1", NULL, ss); diff --git a/src/testing/testing.c b/src/testing/testing.c index f414032a0..5cb823575 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -387,7 +387,7 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir, unsigned int cnt; GNUNET_assert (NULL != testdir); - system = GNUNET_malloc (sizeof (struct GNUNET_TESTING_System)); + system = GNUNET_new (struct GNUNET_TESTING_System); if (NULL == (system->tmppath = getenv (GNUNET_TESTING_PREFIX))) system->tmppath = GNUNET_DISK_mkdtemp (testdir); else @@ -413,7 +413,7 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir, for (cnt = 0; NULL != shared_services[cnt].service; cnt++) { tss = shared_services[cnt]; - ss = GNUNET_malloc (sizeof (struct SharedService)); + ss = GNUNET_new (struct SharedService); ss->sname = GNUNET_strdup (tss.service); ss->cfg = GNUNET_CONFIGURATION_create (); GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, ss->sname, @@ -1242,7 +1242,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, GNUNET_free (config_filename); goto err_ret; } - peer = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Peer)); + peer = GNUNET_new (struct GNUNET_TESTING_Peer); peer->ss_instances = ss_instances; peer->cfgfile = config_filename; /* Free in peer_destroy */ peer->cfg = GNUNET_CONFIGURATION_dup (cfg); @@ -1291,7 +1291,7 @@ GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer, memcpy (id, peer->id, sizeof (struct GNUNET_PeerIdentity)); return; } - peer->id = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); + peer->id = GNUNET_new (struct GNUNET_PeerIdentity); GNUNET_free (GNUNET_TESTING_hostkey_get (peer->system, peer->key_number, peer->id)); diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 7e21d882b..e4e9808e4 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -483,7 +483,7 @@ make_peer (const struct GNUNET_PeerIdentity *peer, { struct Peer *ret; - ret = GNUNET_malloc (sizeof (struct Peer)); + ret = GNUNET_new (struct Peer); ret->pid = *peer; ret->is_friend = is_friend; if (hello != NULL) diff --git a/src/transport/gnunet-service-transport_blacklist.c b/src/transport/gnunet-service-transport_blacklist.c index 87d753929..db154d911 100644 --- a/src/transport/gnunet-service-transport_blacklist.c +++ b/src/transport/gnunet-service-transport_blacklist.c @@ -494,7 +494,7 @@ test_connection_ok (void *cls, const struct GNUNET_PeerIdentity *neighbour, struct TestConnectionContext *tcc = cls; struct GST_BlacklistCheck *bc; - bc = GNUNET_malloc (sizeof (struct GST_BlacklistCheck)); + bc = GNUNET_new (struct GST_BlacklistCheck); GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc); bc->peer = *neighbour; bc->cont = &confirm_or_drop_neighbour; @@ -538,7 +538,7 @@ GST_blacklist_handle_init (void *cls, struct GNUNET_SERVER_Client *client, bl = bl->next; } GNUNET_SERVER_client_mark_monitor (client); - bl = GNUNET_malloc (sizeof (struct Blacklisters)); + bl = GNUNET_new (struct Blacklisters); bl->client = client; GNUNET_SERVER_client_keep (client); GNUNET_CONTAINER_DLL_insert_after (bl_head, bl_tail, bl_tail, bl); @@ -739,7 +739,7 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, } /* need to query blacklist clients */ - bc = GNUNET_malloc (sizeof (struct GST_BlacklistCheck)); + bc = GNUNET_new (struct GST_BlacklistCheck); GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc); bc->peer = *peer; bc->cont = cont; diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 0aeb661d4..8679f40b4 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -677,7 +677,7 @@ clients_handle_send (void *cls, return; } GNUNET_SERVER_receive_done (client, GNUNET_OK); - stcc = GNUNET_malloc (sizeof (struct SendTransmitContinuationContext)); + stcc = GNUNET_new (struct SendTransmitContinuationContext); stcc->target = obm->peer; stcc->client = client; GNUNET_SERVER_client_keep (client); diff --git a/src/transport/gnunet-service-transport_hello.c b/src/transport/gnunet-service-transport_hello.c index 6bf707755..626be54c1 100644 --- a/src/transport/gnunet-service-transport_hello.c +++ b/src/transport/gnunet-service-transport_hello.c @@ -288,7 +288,7 @@ GST_hello_modify_addresses (int addremove, GNUNET_break (0); return; } - al = GNUNET_malloc (sizeof (struct OwnAddressList)); + al = GNUNET_new (struct OwnAddressList); GNUNET_CONTAINER_DLL_insert (oal_head, oal_tail, al); al->address = GNUNET_HELLO_address_copy (address); refresh_hello (); diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c index 1b708cb70..da3fc2de9 100644 --- a/src/transport/gnunet-service-transport_manipulation.c +++ b/src/transport/gnunet-service-transport_manipulation.c @@ -210,7 +210,7 @@ set_metric (struct TM_Peer *dest, int direction, uint32_t type, uint32_t value) } if (NULL == cur) { - cur = GNUNET_malloc (sizeof (struct PropManipulationEntry)); + cur = GNUNET_new (struct PropManipulationEntry); GNUNET_CONTAINER_DLL_insert (dest->head, dest->tail, cur); cur->type = type; cur->metrics[TM_SEND] = UINT32_MAX; @@ -327,7 +327,7 @@ GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client, if (NULL == (tmp = GNUNET_CONTAINER_multipeermap_get (man_handle.peers, &tm->peer))) { - tmp = GNUNET_malloc (sizeof (struct TM_Peer)); + tmp = GNUNET_new (struct TM_Peer); tmp->peer = (tm->peer); for (c = 0; c < TM_BOTH; c++) { diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index c0e605114..d56aac8ad 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c @@ -718,7 +718,7 @@ find_validation_entry (const struct GNUNET_CRYPTO_EddsaPublicKey *public_key, return ve; if (public_key == NULL) return NULL; - ve = GNUNET_malloc (sizeof (struct ValidationEntry)); + ve = GNUNET_new (struct ValidationEntry); ve->in_use = GNUNET_SYSERR; /* not defined */ ve->last_line_set_to_no = 0; ve->last_line_set_to_yes = 0; diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c index 51e8a89bd..a7d3cf3f5 100644 --- a/src/transport/plugin_transport_bluetooth.c +++ b/src/transport/plugin_transport_bluetooth.c @@ -730,7 +730,7 @@ create_session (struct MacEndpoint *endpoint, } GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# Bluetooth sessions allocated"), 1, GNUNET_NO); - session = GNUNET_malloc (sizeof (struct Session)); + session = GNUNET_new (struct Session); GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head, endpoint->sessions_tail, session); @@ -897,7 +897,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint, struct Plugin *plugin; plugin = endpoint->plugin; - fm = GNUNET_malloc (sizeof (struct FragmentMessage)); + fm = GNUNET_new (struct FragmentMessage); fm->macendpoint = endpoint; fm->target = *target; fm->size_payload = payload_size; @@ -1001,7 +1001,7 @@ create_macendpoint (struct Plugin *plugin, for (pos = plugin->mac_head; NULL != pos; pos = pos->next) if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) return pos; - pos = GNUNET_malloc (sizeof (struct MacEndpoint)); + pos = GNUNET_new (struct MacEndpoint); pos->addr = *addr; pos->plugin = plugin; pos->defrag = @@ -1790,7 +1790,7 @@ bluetooth_string_to_address (void *cls, const char *addr, uint16_t addrlen, GNUNET_break (0); return GNUNET_SYSERR; } - wa = GNUNET_malloc (sizeof (struct WlanAddress)); + wa = GNUNET_new (struct WlanAddress); for (i=0;i<6;i++) wa->mac.mac[i] = a[i]; wa->options = htonl (0); @@ -1833,7 +1833,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) { /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully initialze the plugin or the API */ - api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); + api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); api->cls = NULL; api->address_pretty_printer = &bluetooth_plugin_address_pretty_printer; api->address_to_string = &bluetooth_plugin_address_to_string; @@ -1875,7 +1875,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) return NULL; } - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->interface = interface; plugin->env = env; GNUNET_STATISTICS_set (plugin->env->stats, _("# Bluetooth sessions allocated"), @@ -1933,7 +1933,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls) GNUNET_assert (0); } - api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); + api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); api->cls = plugin; api->send = &bluetooth_plugin_send; api->get_session = &bluetooth_plugin_get_session; diff --git a/src/transport/plugin_transport_http_common.c b/src/transport/plugin_transport_http_common.c index de4cb9a26..c020118ac 100644 --- a/src/transport/plugin_transport_http_common.c +++ b/src/transport/plugin_transport_http_common.c @@ -60,7 +60,7 @@ http_split_address (const char * addr) char *port_start = NULL; char *path_start = NULL; protocol_start = src; - sp = GNUNET_malloc (sizeof (struct SplittedHTTPAddress)); + sp = GNUNET_new (struct SplittedHTTPAddress); /* Address string consists of protocol://host[:port]path*/ @@ -455,7 +455,7 @@ http_common_socket_from_address (const void *addr, size_t addrlen, int *res) return NULL; } - s = GNUNET_malloc (sizeof (struct sockaddr_storage)); + s = GNUNET_new (struct sockaddr_storage); GNUNET_asprintf (&to_conv, "%s:%u", spa->host, spa->port); if (GNUNET_SYSERR == GNUNET_STRINGS_to_address_ip (to_conv, strlen(to_conv), s)) { diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index f08c7072a..15c0323c6 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -2219,7 +2219,7 @@ server_add_address (void *cls, int add_remove, const struct sockaddr *addr, struct HTTP_Server_Plugin *plugin = cls; struct HttpAddressWrapper *w = NULL; - w = GNUNET_malloc (sizeof (struct HttpAddressWrapper)); + w = GNUNET_new (struct HttpAddressWrapper); w->address = http_common_address_from_socket (plugin->protocol, addr, addrlen); if (NULL == w->address) { @@ -2769,7 +2769,7 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin) GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Binding %s plugin to specific IPv4 address: `%s'\n", plugin->protocol, bind4_address); - plugin->server_addr_v4 = GNUNET_malloc (sizeof (struct sockaddr_in)); + plugin->server_addr_v4 = GNUNET_new (struct sockaddr_in); if (1 != inet_pton (AF_INET, bind4_address, &plugin->server_addr_v4->sin_addr)) { @@ -2800,7 +2800,7 @@ server_configure_plugin (struct HTTP_Server_Plugin *plugin) GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Binding %s plugin to specific IPv6 address: `%s'\n", plugin->protocol, bind6_address); - plugin->server_addr_v6 = GNUNET_malloc (sizeof (struct sockaddr_in6)); + plugin->server_addr_v6 = GNUNET_new (struct sockaddr_in6); if (1 != inet_pton (AF_INET6, bind6_address, &plugin->server_addr_v6->sin6_addr)) { diff --git a/src/transport/plugin_transport_smtp.c b/src/transport/plugin_transport_smtp.c index c886fd132..fd2089367 100644 --- a/src/transport/plugin_transport_smtp.c +++ b/src/transport/plugin_transport_smtp.c @@ -233,7 +233,7 @@ listenAndDistribute (void *unused) } if (stats != NULL) stats->change (stat_bytesReceived, size); - coreMP = GNUNET_malloc (sizeof (GNUNET_TransportPacket)); + coreMP = GNUNET_new (GNUNET_TransportPacket); coreMP->msg = out; coreMP->size = size - sizeof (SMTPMessage); coreMP->tsession = NULL; @@ -541,7 +541,7 @@ api_connect (const GNUNET_MessageHello * hello, GNUNET_TSession ** tsessionPtr, { GNUNET_TSession *tsession; - tsession = GNUNET_malloc (sizeof (GNUNET_TSession)); + tsession = GNUNET_new (GNUNET_TSession); tsession->internal = GNUNET_malloc (GNUNET_sizeof_hello (hello)); tsession->peer = hello->senderIdentity; memcpy (tsession->internal, hello, GNUNET_sizeof_hello (hello)); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index d3f27dec4..04fac9cde 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -1906,7 +1906,7 @@ tcp_plugin_address_pretty_printer (void *cls, const char *type, asc (asc_cls, NULL); return; } - ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext)); + ppc = GNUNET_new (struct PrettyPrinterContext); if (addrlen == sizeof (struct IPv6TcpAddress)) ppc->ipv6 = GNUNET_YES; else @@ -2524,7 +2524,7 @@ try_connection_reversal (void *cls, const struct sockaddr *addr, /* FIXME: do we need to track these probe context objects so that * we can clean them up on plugin unload? */ - tcp_probe_ctx = GNUNET_malloc (sizeof (struct TCPProbeContext)); + tcp_probe_ctx = GNUNET_new (struct TCPProbeContext); tcp_probe_ctx->message.header.size = htons (sizeof (struct TCP_NAT_ProbeMessage)); tcp_probe_ctx->message.header.type = diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 5b46c93c7..a5ee6494a 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -684,7 +684,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen, { struct IPv4UdpAddress *u4; struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address; - u4 = GNUNET_malloc (sizeof (struct IPv4UdpAddress)); + u4 = GNUNET_new (struct IPv4UdpAddress); u4->options = htonl (options); u4->ipv4_addr = in4->sin_addr.s_addr; u4->u4_port = in4->sin_port; @@ -696,7 +696,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen, { struct IPv6UdpAddress *u6; struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address; - u6 = GNUNET_malloc (sizeof (struct IPv6UdpAddress)); + u6 = GNUNET_new (struct IPv6UdpAddress); u6->options = htonl (options); u6->ipv6_addr = in6->sin6_addr; u6->u6_port = in6->sin6_port; @@ -1911,7 +1911,7 @@ udp_plugin_send (void *cls, if (s->frag_ctx != NULL) return GNUNET_SYSERR; memcpy (&udp[1], msgbuf, msgbuf_size); - frag_ctx = GNUNET_malloc (sizeof (struct UDP_FragmentationContext)); + frag_ctx = GNUNET_new (struct UDP_FragmentationContext); frag_ctx->plugin = plugin; frag_ctx->session = s; frag_ctx->cont = cont; diff --git a/src/transport/plugin_transport_udp_broadcasting.c b/src/transport/plugin_transport_udp_broadcasting.c index 61ac3d10e..5448b4eff 100644 --- a/src/transport/plugin_transport_udp_broadcasting.c +++ b/src/transport/plugin_transport_udp_broadcasting.c @@ -242,7 +242,7 @@ udp_broadcast_receive (struct Plugin *plugin, size, GNUNET_a2s ((const struct sockaddr *) addr, addrlen)); struct Mstv4Context *mc; - mc = GNUNET_malloc (sizeof (struct Mstv4Context)); + mc = GNUNET_new (struct Mstv4Context); struct sockaddr_in *av4 = (struct sockaddr_in *) addr; mc->addr.ipv4_addr = av4->sin_addr.s_addr; @@ -263,7 +263,7 @@ udp_broadcast_receive (struct Plugin *plugin, size, GNUNET_a2s ((const struct sockaddr *) &addr, addrlen)); struct Mstv6Context *mc; - mc = GNUNET_malloc (sizeof (struct Mstv6Context)); + mc = GNUNET_new (struct Mstv6Context); struct sockaddr_in6 *av6 = (struct sockaddr_in6 *) addr; mc->addr.ipv6_addr = av6->sin6_addr; diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 6f5c66ad3..1fafc4070 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c @@ -777,7 +777,7 @@ create_session (struct MacEndpoint *endpoint, GNUNET_STATISTICS_update (endpoint->plugin->env->stats, _("# WLAN sessions allocated"), 1, GNUNET_NO); - session = GNUNET_malloc (sizeof (struct Session)); + session = GNUNET_new (struct Session); GNUNET_CONTAINER_DLL_insert_tail (endpoint->sessions_head, endpoint->sessions_tail, session); @@ -974,7 +974,7 @@ send_with_fragmentation (struct MacEndpoint *endpoint, struct Plugin *plugin; plugin = endpoint->plugin; - fm = GNUNET_malloc (sizeof (struct FragmentMessage)); + fm = GNUNET_new (struct FragmentMessage); fm->macendpoint = endpoint; fm->target = *target; fm->size_payload = payload_size; @@ -1079,7 +1079,7 @@ create_macendpoint (struct Plugin *plugin, for (pos = plugin->mac_head; NULL != pos; pos = pos->next) if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) return pos; - pos = GNUNET_malloc (sizeof (struct MacEndpoint)); + pos = GNUNET_new (struct MacEndpoint); pos->addr = *addr; pos->plugin = plugin; pos->defrag = @@ -1846,7 +1846,7 @@ wlan_string_to_address (void *cls, const char *addr, uint16_t addrlen, GNUNET_break (0); return GNUNET_SYSERR; } - wa = GNUNET_malloc (sizeof (struct WlanAddress)); + wa = GNUNET_new (struct WlanAddress); for (i=0;i<6;i++) wa->mac.mac[i] = a[i]; wa->options = htonl (0); @@ -1889,7 +1889,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) { /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully initialze the plugin or the API */ - api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); + api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); api->cls = NULL; api->address_pretty_printer = &wlan_plugin_address_pretty_printer; api->address_to_string = &wlan_plugin_address_to_string; @@ -1931,7 +1931,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) return NULL; } - plugin = GNUNET_malloc (sizeof (struct Plugin)); + plugin = GNUNET_new (struct Plugin); plugin->interface = interface; plugin->env = env; GNUNET_STATISTICS_set (plugin->env->stats, _("# WLAN sessions allocated"), @@ -1989,7 +1989,7 @@ libgnunet_plugin_transport_wlan_init (void *cls) GNUNET_assert (0); } - api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); + api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); api->cls = plugin; api->send = &wlan_plugin_send; api->get_session = &wlan_plugin_get_session; diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c index 51aa0a55f..f9182b57f 100644 --- a/src/transport/transport-testing.c +++ b/src/transport/transport-testing.c @@ -246,7 +246,7 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle *tth return NULL; } - struct PeerContext *p = GNUNET_malloc (sizeof (struct PeerContext)); + struct PeerContext *p = GNUNET_new (struct PeerContext); GNUNET_CONTAINER_DLL_insert (tth->p_head, tth->p_tail, p); /* Create configuration and call testing lib to modify it */ @@ -471,7 +471,7 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct GNUNET_TRANSPORT_TESTING_handle * GNUNET_assert (tth != NULL); struct ConnectingContext *cc = - GNUNET_malloc (sizeof (struct ConnectingContext)); + GNUNET_new (struct ConnectingContext); GNUNET_assert (p1 != NULL); GNUNET_assert (p2 != NULL); @@ -574,7 +574,7 @@ GNUNET_TRANSPORT_TESTING_init () struct GNUNET_TRANSPORT_TESTING_handle *tth; /* prepare hostkeys */ - tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); + tth = GNUNET_new (struct GNUNET_TRANSPORT_TESTING_handle); /* Init testing the testing lib */ tth->tl_system = GNUNET_TESTING_system_create ("transport-testing", NULL, diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index 515be9bf8..d547b8ed8 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c @@ -322,7 +322,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct return NULL; if (GNUNET_YES != one_shot) timeout = GNUNET_TIME_UNIT_FOREVER_REL; - pal_ctx = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PeerIterateContext)); + pal_ctx = GNUNET_new (struct GNUNET_TRANSPORT_PeerIterateContext); pal_ctx->cb = peer_address_callback; pal_ctx->cb_cls = peer_address_callback_cls; pal_ctx->cfg = cfg; diff --git a/src/transport/transport_api_address_to_string.c b/src/transport/transport_api_address_to_string.c index 94c9ac45a..0fb0623dc 100644 --- a/src/transport/transport_api_address_to_string.c +++ b/src/transport/transport_api_address_to_string.c @@ -152,7 +152,7 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle memcpy (addrbuf, address->address, alen); memcpy (&addrbuf[alen], address->transport_name, slen); - alc = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_AddressToStringContext)); + alc = GNUNET_new (struct GNUNET_TRANSPORT_AddressToStringContext); alc->cb = aluc; alc->cb_cls = aluc_cls; alc->timeout = GNUNET_TIME_relative_to_absolute (timeout); diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c index dcd1ae781..1c17bd498 100644 --- a/src/transport/transport_api_blacklist.c +++ b/src/transport/transport_api_blacklist.c @@ -256,7 +256,7 @@ GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, client = GNUNET_CLIENT_connect ("transport", cfg); if (NULL == client) return NULL; - ret = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_Blacklist)); + ret = GNUNET_new (struct GNUNET_TRANSPORT_Blacklist); ret->client = client; ret->cfg = cfg; ret->cb = cb; diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 582435651..a2338f1c9 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -710,7 +710,7 @@ GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls) { struct CustomLogger *entry; - entry = GNUNET_malloc (sizeof (struct CustomLogger)); + entry = GNUNET_new (struct CustomLogger); entry->logger = logger; entry->logger_cls = logger_cls; entry->next = loggers; diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c index 645729553..9554e0ec0 100644 --- a/src/util/container_bloomfilter.c +++ b/src/util/container_bloomfilter.c @@ -494,7 +494,7 @@ GNUNET_CONTAINER_bloomfilter_load (const char *filename, size_t size, ui *= 2; size = ui; /* make sure it's a power of 2 */ - bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter)); + bf = GNUNET_new (struct GNUNET_CONTAINER_BloomFilter); /* Try to open a bloomfilter file */ if (GNUNET_YES == GNUNET_DISK_file_test (filename)) bf->fh = @@ -631,7 +631,7 @@ GNUNET_CONTAINER_bloomfilter_init (const char *data, size_t size, if ((0 == k) || (0 == size)) return NULL; - bf = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_BloomFilter)); + bf = GNUNET_new (struct GNUNET_CONTAINER_BloomFilter); bf->filename = NULL; bf->fh = NULL; bf->bitArray = GNUNET_malloc_large (size); diff --git a/src/util/container_heap.c b/src/util/container_heap.c index 0f63f957d..54da89f7a 100644 --- a/src/util/container_heap.c +++ b/src/util/container_heap.c @@ -142,7 +142,7 @@ GNUNET_CONTAINER_heap_create (enum GNUNET_CONTAINER_HeapOrder order) { struct GNUNET_CONTAINER_Heap *heap; - heap = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_Heap)); + heap = GNUNET_new (struct GNUNET_CONTAINER_Heap); heap->order = order; return heap; } @@ -351,7 +351,7 @@ GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *heap, void *element, { struct GNUNET_CONTAINER_HeapNode *node; - node = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_HeapNode)); + node = GNUNET_new (struct GNUNET_CONTAINER_HeapNode); node->heap = heap; node->element = element; node->cost = cost; diff --git a/src/util/container_slist.c b/src/util/container_slist.c index 10af916c3..e75c695c5 100644 --- a/src/util/container_slist.c +++ b/src/util/container_slist.c @@ -101,7 +101,7 @@ create_elem (enum GNUNET_CONTAINER_SListDisposition disp, const void *buf, } else { - e = GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_SList_Elem)); + e = GNUNET_new (struct GNUNET_CONTAINER_SList_Elem); e->elem = (void *) buf; } e->disp = disp; @@ -190,7 +190,7 @@ GNUNET_CONTAINER_slist_append (struct GNUNET_CONTAINER_SList *dst, struct GNUNET_CONTAINER_SList * GNUNET_CONTAINER_slist_create () { - return GNUNET_malloc (sizeof (struct GNUNET_CONTAINER_SList)); + return GNUNET_new (struct GNUNET_CONTAINER_SList); } diff --git a/src/util/disk.c b/src/util/disk.c index 074355c0a..aac730eec 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -1899,8 +1899,8 @@ GNUNET_DISK_get_handle_from_w32_handle (HANDLE osfh) * otherwise we're screwed, as selecting on non-overlapped handle * will block. */ - fh->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED)); - fh->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED)); + fh->oOverlapRead = GNUNET_new (OVERLAPPED); + fh->oOverlapWrite = GNUNET_new (OVERLAPPED); fh->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); fh->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); } @@ -2356,10 +2356,10 @@ GNUNET_DISK_pipe (int blocking_read, int blocking_write, int inherit_read, int i p->fd[0]->type = GNUNET_DISK_HANLDE_TYPE_PIPE; p->fd[1]->type = GNUNET_DISK_HANLDE_TYPE_PIPE; - p->fd[0]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED)); - p->fd[0]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED)); - p->fd[1]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED)); - p->fd[1]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED)); + p->fd[0]->oOverlapRead = GNUNET_new (OVERLAPPED); + p->fd[0]->oOverlapWrite = GNUNET_new (OVERLAPPED); + p->fd[1]->oOverlapRead = GNUNET_new (OVERLAPPED); + p->fd[1]->oOverlapWrite = GNUNET_new (OVERLAPPED); p->fd[0]->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); p->fd[0]->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); @@ -2462,8 +2462,8 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2]) if (p->fd[0]->h != INVALID_HANDLE_VALUE) { p->fd[0]->type = GNUNET_DISK_HANLDE_TYPE_PIPE; - p->fd[0]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED)); - p->fd[0]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED)); + p->fd[0]->oOverlapRead = GNUNET_new (OVERLAPPED); + p->fd[0]->oOverlapWrite = GNUNET_new (OVERLAPPED); p->fd[0]->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); p->fd[0]->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); } @@ -2480,8 +2480,8 @@ GNUNET_DISK_pipe_from_fd (int blocking_read, int blocking_write, int fd[2]) if (p->fd[1]->h != INVALID_HANDLE_VALUE) { p->fd[1]->type = GNUNET_DISK_HANLDE_TYPE_PIPE; - p->fd[1]->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED)); - p->fd[1]->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED)); + p->fd[1]->oOverlapRead = GNUNET_new (OVERLAPPED); + p->fd[1]->oOverlapWrite = GNUNET_new (OVERLAPPED); p->fd[1]->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); p->fd[1]->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); } diff --git a/src/util/os_priority.c b/src/util/os_priority.c index ab82b7b58..2cabd214e 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -1089,7 +1089,7 @@ start_process (int pipe_control, return NULL; } - gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process)); + gnunet_proc = GNUNET_new (struct GNUNET_OS_Process); gnunet_proc->pid = proc.dwProcessId; gnunet_proc->handle = proc.hProcess; gnunet_proc->control_pipe = childpipe_write; @@ -1774,7 +1774,7 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, void *proc_cls, return NULL; } GNUNET_DISK_pipe_close_end (opipe, GNUNET_DISK_PIPE_END_WRITE); - cmd = GNUNET_malloc (sizeof (struct GNUNET_OS_CommandHandle)); + cmd = GNUNET_new (struct GNUNET_OS_CommandHandle); cmd->timeout = GNUNET_TIME_relative_to_absolute (timeout); cmd->eip = eip; cmd->opipe = opipe; diff --git a/src/util/peer.c b/src/util/peer.c index fa376d333..3e4e1712d 100644 --- a/src/util/peer.c +++ b/src/util/peer.c @@ -127,7 +127,7 @@ GNUNET_PEER_intern (const struct GNUNET_PeerIdentity *pid) GNUNET_array_grow (table, size, size + 16); for (i = ret; i < size; i++) { - table[i] = GNUNET_malloc (sizeof (struct PeerEntry)); + table[i] = GNUNET_new (struct PeerEntry); table[i]->pid = i + 1; } } diff --git a/src/util/server_tc.c b/src/util/server_tc.c index 780b5f003..5324a6ab9 100644 --- a/src/util/server_tc.c +++ b/src/util/server_tc.c @@ -127,7 +127,7 @@ GNUNET_SERVER_transmit_context_create (struct GNUNET_SERVER_Client *client) struct GNUNET_SERVER_TransmitContext *tc; GNUNET_assert (NULL != client); - tc = GNUNET_malloc (sizeof (struct GNUNET_SERVER_TransmitContext)); + tc = GNUNET_new (struct GNUNET_SERVER_TransmitContext); GNUNET_SERVER_client_keep (client); tc->client = client; return tc; diff --git a/src/util/signal.c b/src/util/signal.c index 5cf50e8dc..b76c658c8 100644 --- a/src/util/signal.c +++ b/src/util/signal.c @@ -64,7 +64,7 @@ GNUNET_SIGNAL_handler_install (int signum, GNUNET_SIGNAL_Handler handler) struct sigaction sig; #endif - ret = GNUNET_malloc (sizeof (struct GNUNET_SIGNAL_Context)); + ret = GNUNET_new (struct GNUNET_SIGNAL_Context); ret->sig = signum; ret->method = handler; #ifndef MINGW diff --git a/src/util/test_client.c b/src/util/test_client.c index 6dfb8349a..2b44c1690 100644 --- a/src/util/test_client.c +++ b/src/util/test_client.c @@ -73,7 +73,7 @@ echo_cb (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving message from client, bouncing back\n"); GNUNET_assert (sizeof (struct GNUNET_MessageHeader) == ntohs (message->size)); - cc = GNUNET_malloc (sizeof (struct CopyContext)); + cc = GNUNET_new (struct CopyContext); cc->client = client; cpy = GNUNET_malloc (ntohs (message->size)); memcpy (cpy, message, ntohs (message->size)); diff --git a/src/util/test_container_slist.c b/src/util/test_container_slist.c index 8b4ff93d0..443d5c7c5 100644 --- a/src/util/test_container_slist.c +++ b/src/util/test_container_slist.c @@ -136,7 +136,7 @@ main (int argc, char *argv[]) for (i = 0; i < 100; i++) { - ip = GNUNET_malloc (sizeof (int)); + ip = GNUNET_new (int); *ip = i; GNUNET_CONTAINER_slist_add (l, GNUNET_CONTAINER_SLIST_DISPOSITION_DYNAMIC, ip, sizeof (int)); -- cgit v1.2.3