From 3f5dc2ddcfc59ca54f18a3688fa1f8aa89340ce6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 18 Jul 2013 09:07:36 +0000 Subject: [PATCH] -minor code cleanup --- src/fs/gnunet-service-fs_cp.c | 8 ++++---- src/fs/gnunet-service-fs_lc.c | 12 ++++++------ src/fs/gnunet-service-fs_pe.c | 8 ++++---- src/fs/gnunet-service-fs_push.c | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 7c8921ec8..e1a3e1ac9 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -581,7 +581,7 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s\n", GNUNET_i2s (peer)); - cp = GNUNET_malloc (sizeof (struct GSF_ConnectedPeer)); + cp = GNUNET_new (struct GSF_ConnectedPeer); cp->ppd.pid = GNUNET_PEER_intern (peer); cp->ppd.transmission_delay = GNUNET_LOAD_value_init (GNUNET_TIME_UNIT_ZERO); cp->rc = @@ -930,7 +930,7 @@ handle_p2p_reply (void *cls, enum GNUNET_BLOCK_EvaluationResult eval, { struct GSF_DelayedHandle *dh; - dh = GNUNET_malloc (sizeof (struct GSF_DelayedHandle)); + dh = GNUNET_new (struct GSF_DelayedHandle); dh->cp = cp; dh->pm = pm; dh->msize = msize; @@ -1273,7 +1273,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, } } - peerreq = GNUNET_malloc (sizeof (struct PeerRequest)); + peerreq = GNUNET_new (struct PeerRequest); peerreq->cp = cp; pr = GSF_pending_request_create_ (options, type, &gm->query, target, @@ -1356,7 +1356,7 @@ GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query, struct GSF_PeerTransmitHandle *pos; struct GSF_PeerTransmitHandle *prev; - pth = GNUNET_malloc (sizeof (struct GSF_PeerTransmitHandle)); + pth = GNUNET_new (struct GSF_PeerTransmitHandle); pth->transmission_request_start_time = GNUNET_TIME_absolute_get (); pth->timeout = GNUNET_TIME_relative_to_absolute (timeout); pth->gmc = gmc; diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c index f90131815..8066b264a 100644 --- a/src/fs/gnunet-service-fs_lc.c +++ b/src/fs/gnunet-service-fs_lc.c @@ -170,11 +170,11 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client) struct GSF_LocalClient *pos; pos = client_head; - while ((pos != NULL) && (pos->client != client)) + while ((NULL != pos) && (pos->client != client)) pos = pos->next; - if (pos != NULL) + if (NULL != pos) return pos; - pos = GNUNET_malloc (sizeof (struct GSF_LocalClient)); + pos = GNUNET_new (struct GSF_LocalClient); pos->client = client; GNUNET_CONTAINER_DLL_insert (client_head, client_tail, pos); return pos; @@ -340,7 +340,7 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, (type == GNUNET_BLOCK_TYPE_ANY)) { cr = lc->cr_head; - while (cr != NULL) + while (NULL != cr) { prd = GSF_pending_request_get_data_ (cr->pr); /* only unify with queries that hae not yet started local processing @@ -368,7 +368,7 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client, GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# client searches active"), 1, GNUNET_NO); - cr = GNUNET_malloc (sizeof (struct ClientRequest)); + cr = GNUNET_new (struct ClientRequest); cr->lc = lc; GNUNET_CONTAINER_DLL_insert (lc->cr_head, lc->cr_tail, cr); options = GSF_PRO_LOCAL_REQUEST; @@ -498,7 +498,7 @@ GSF_client_disconnect_handler_ (void *cls, struct GNUNET_SERVER_Client *client) GNUNET_CONTAINER_DLL_remove (pos->res_head, pos->res_tail, res); GNUNET_free (res); } - if (pos->th != NULL) + if (NULL != pos->th) { GNUNET_SERVER_notify_transmit_ready_cancel (pos->th); pos->th = NULL; diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c index 0992d2163..5c63e7b66 100644 --- a/src/fs/gnunet-service-fs_pe.c +++ b/src/fs/gnunet-service-fs_pe.c @@ -539,7 +539,7 @@ merge_pr (void *cls, const struct GNUNET_HashCode * query, void *element) GSF_pending_request_is_compatible_ (mpr->pr, rp->pe_head->pr)) return GNUNET_YES; /* merge new request with existing request plan */ - bi = GNUNET_malloc (sizeof (struct GSF_PendingRequestPlanBijection)); + bi = GNUNET_new (struct GSF_PendingRequestPlanBijection); bi->rp = rp; bi->pr = mpr->pr; prd = GSF_pending_request_get_data_ (mpr->pr); @@ -585,7 +585,7 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) pp = GNUNET_CONTAINER_multihashmap_get (plans, &id->hashPubKey); if (NULL == pp) { - pp = GNUNET_malloc (sizeof (struct PeerPlan)); + pp = GNUNET_new (struct PeerPlan); pp->plan_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); pp->priority_heap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX); @@ -615,8 +615,8 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Planning transmission of query `%s' to peer `%s'\n", GNUNET_h2s (&prd->query), GNUNET_i2s (id)); - rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan)); // 8 MB - bi = GNUNET_malloc (sizeof (struct GSF_PendingRequestPlanBijection)); + rp = GNUNET_new (struct GSF_RequestPlan); // 8 MB + bi = GNUNET_new (struct GSF_PendingRequestPlanBijection); bi->rp = rp; bi->pr = pr; GNUNET_CONTAINER_MDLL_insert (PR, prd->pr_head, prd->pr_tail, bi); diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c index 936cf5164..e7fbbdcaf 100644 --- a/src/fs/gnunet-service-fs_push.c +++ b/src/fs/gnunet-service-fs_push.c @@ -567,7 +567,7 @@ GSF_push_start_ (struct GSF_ConnectedPeer *peer) if (GNUNET_YES != enabled) return; - mrp = GNUNET_malloc (sizeof (struct MigrationReadyPeer)); + mrp = GNUNET_new (struct MigrationReadyPeer); mrp->peer = peer; find_content (mrp); GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, mrp); -- 2.25.1