clean up for configs
[oweals/gnunet.git] / src / scalarproduct / gnunet-scalarproduct.c
index f81a56c66e04a884a606b3b13917254a85a19073..012ce91b8c2d043d0d92c7dbf7904ac724842925 100644 (file)
@@ -94,18 +94,30 @@ responder_callback (void *cls,
   {
   case GNUNET_SCALARPRODUCT_Status_Success:
     ret = 0;
-    LOG (GNUNET_ERROR_TYPE_INFO, "Session %s concluded.\n", GNUNET_h2s (&closure->key));
+    LOG (GNUNET_ERROR_TYPE_INFO,
+         "Session %s concluded.\n",
+         GNUNET_h2s (&closure->key));
     break;
   case GNUNET_SCALARPRODUCT_Status_InvalidResponse:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: invalid response\n", GNUNET_h2s (&closure->key));
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Session %s failed: invalid response\n",
+         GNUNET_h2s (&closure->key));
     break;
   case GNUNET_SCALARPRODUCT_Status_Failure:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: service failure\n", GNUNET_h2s (&closure->key));
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Session %s failed: service failure\n",
+         GNUNET_h2s (&closure->key));
+    break;
   case GNUNET_SCALARPRODUCT_Status_ServiceDisconnected:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: service disconnect!!\n", GNUNET_h2s (&closure->key));
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Session %s failed: service disconnect!\n",
+         GNUNET_h2s (&closure->key));
     break;
   default:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s failed: return code %d\n", GNUNET_h2s (&closure->key), status);
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Session %s failed: return code %d\n",
+         GNUNET_h2s (&closure->key),
+         status);
   }
   GNUNET_SCHEDULER_shutdown();
 }
@@ -136,22 +148,39 @@ requester_callback (void *cls,
       printf ("%s", buf);
     }
     else
-      LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_aprint", rc);
+      LOG_GCRY (GNUNET_ERROR_TYPE_ERROR,
+                "gcry_mpi_aprint",
+                rc);
     break;
   case GNUNET_SCALARPRODUCT_Status_InvalidResponse:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s with peer %s failed: invalid response received\n", GNUNET_h2s (&closure->key), GNUNET_i2s (&closure->peer));
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Session %s with peer %s failed: invalid response received\n",
+         GNUNET_h2s (&closure->key),
+         GNUNET_i2s (&closure->peer));
     break;
   case GNUNET_SCALARPRODUCT_Status_Failure:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s with peer %s failed: API failure\n", GNUNET_h2s (&closure->key), GNUNET_i2s (&closure->peer));
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Session %s with peer %s failed: API failure\n",
+         GNUNET_h2s (&closure->key),
+         GNUNET_i2s (&closure->peer));
+    break;
   case GNUNET_SCALARPRODUCT_Status_ServiceDisconnected:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s with peer %s was disconnected from service.\n", GNUNET_h2s (&closure->key), GNUNET_i2s (&closure->peer));
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Session %s with peer %s was disconnected from service.\n",
+         GNUNET_h2s (&closure->key),
+         GNUNET_i2s (&closure->peer));
     break;
   default:
-    LOG (GNUNET_ERROR_TYPE_ERROR, "Session %s with peer %s failed: return code %d\n", GNUNET_h2s (&closure->key), GNUNET_i2s (&closure->peer), status);
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         "Session %s with peer %s failed: return code %d\n",
+         GNUNET_h2s (&closure->key),
+         GNUNET_i2s (&closure->peer),
+         status);
   }
   GNUNET_SCHEDULER_shutdown();
 }
 
+
 /**
  * Task run during shutdown.
  *
@@ -165,6 +194,7 @@ shutdown_task (void *cls,
   GNUNET_SCALARPRODUCT_disconnect ();
 }
 
+
 /**
  * Main function that will be run by the scheduler.
  *
@@ -184,7 +214,7 @@ run (void *cls,
   int32_t element;
   int i;
   int32_t *elements;
-  unsigned char * mask;
+  unsigned char *mask;
   uint32_t mask_bytes;
   uint32_t element_count = 0;
   struct ScalarProductCallbackClosure * closure;
@@ -277,7 +307,7 @@ run (void *cls,
   }
   while (1);
 
-  mask_bytes = element_count / 8 + (element_count % 8 ? 1 : 0);
+  mask_bytes = element_count / 8 + ( (element_count % 8) ? 1 : 0);
   mask = GNUNET_malloc ((element_count / 8) + 1);
 
   /* Read input_mask_peer1 and read in mask_peer1 array */
@@ -325,7 +355,11 @@ run (void *cls,
                                              mask, mask_bytes,
                                              &requester_callback,
                                              (void *) &closure)))
+  {
+    GNUNET_free (elements);
+    GNUNET_free (mask);
     return;
+  }
 
   if ((NULL == input_peer_id) &&
       (NULL == GNUNET_SCALARPRODUCT_response (cfg,
@@ -333,7 +367,13 @@ run (void *cls,
                                               elements, element_count,
                                               &responder_callback,
                                               (void *) &closure)))
+  {
+    GNUNET_free (elements);
+    GNUNET_free (mask);
     return;
+  }
+  GNUNET_free (elements);
+  GNUNET_free (mask);
   GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
                                 &shutdown_task,
                                 NULL);