gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r26549 - in gnunet/src: consensus include


From: gnunet
Subject: [GNUnet-SVN] r26549 - in gnunet/src: consensus include
Date: Thu, 21 Mar 2013 15:45:10 +0100

Author: grothoff
Date: 2013-03-21 15:45:09 +0100 (Thu, 21 Mar 2013)
New Revision: 26549

Modified:
   gnunet/src/consensus/consensus_api.c
   gnunet/src/include/gnunet_common.h
   gnunet/src/include/gnunet_pseudonym_lib.h
Log:
-idea for improved allocator

Modified: gnunet/src/consensus/consensus_api.c
===================================================================
--- gnunet/src/consensus/consensus_api.c        2013-03-21 14:43:47 UTC (rev 
26548)
+++ gnunet/src/consensus/consensus_api.c        2013-03-21 14:45:09 UTC (rev 
26549)
@@ -201,7 +201,8 @@
   {
     qmsg->idc (qmsg->idc_cls, GNUNET_YES);
   }
-
+  GNUNET_free (qmsg->msg);
+  GNUNET_free (qmsg);
   /* FIXME: free the messages */
 
   send_next (consensus);
@@ -262,12 +263,12 @@
 
   ret = consensus->new_element_cb (consensus->new_element_cls, &element);
 
-  ack_msg = GNUNET_malloc (sizeof *ack_msg);
+  ack_msg = GNUNET_new (struct GNUNET_CONSENSUS_AckMessage);
   ack_msg->header.size = htons (sizeof *ack_msg);
   ack_msg->header.type = htons (GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_ACK);
   ack_msg->keep = ret;
 
-  queue_message (consensus, (struct GNUNET_MessageHeader *) ack_msg);
+  queue_message (consensus, &ack_msg->header);
 
   send_next (consensus);
 }

Modified: gnunet/src/include/gnunet_common.h
===================================================================
--- gnunet/src/include/gnunet_common.h  2013-03-21 14:43:47 UTC (rev 26548)
+++ gnunet/src/include/gnunet_common.h  2013-03-21 14:45:09 UTC (rev 26549)
@@ -669,6 +669,15 @@
 #define GNUNET_MAX_MALLOC_CHECKED (1024 * 1024 * 40)
 
 /**
+ * Allocate a struct or union of the given 'type'.
+ * Wrapper around GNUNET_malloc that returns a pointer
+ * to the newly created object of the correct type.
+ *
+ * @param type name of the struct or union, i.e. pass 'struct Foo'.
+ */
+#define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type))
+
+/**
  * Wrapper around malloc. Allocates size bytes of memory.
  * The memory will be zero'ed out.
  *

Modified: gnunet/src/include/gnunet_pseudonym_lib.h
===================================================================
--- gnunet/src/include/gnunet_pseudonym_lib.h   2013-03-21 14:43:47 UTC (rev 
26548)
+++ gnunet/src/include/gnunet_pseudonym_lib.h   2013-03-21 14:45:09 UTC (rev 
26549)
@@ -47,16 +47,17 @@
 struct GNUNET_PseudonymIdentifier
 {
   /**
-   * Q consists of an x- and a y-value, each mod p (256 bits);
-   * however, (to speed up calculations and/or represent infinity)
-   * libgcrypt uses projective coordinates, which add an extra
-   * dimension.  Thus, the MPI value is typically one additional byte
-   * longer (512 bit + 8 bits).  As we want a size that is a
-   * multiplicative of 8, we add 8 bytes (not 8 bits), which should
-   * always suffice to represent Q.
+   * Q consists of an x- and a y-value, each mod p (256 bits),
+   * given here in affine coordinates.
    */
-  unsigned char q[(256 + 256 / 8) + 8];
+  unsigned char q_x[256 / 8];
 
+  /**
+   * Q consists of an x- and a y-value, each mod p (256 bits),
+   * given here in affine coordinates.
+   */
+  unsigned char q_y[256 / 8];
+
 };
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]