X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fcore%2Fgnunet-service-core_typemap.c;h=d2dab5d9988baa27b00852889ccbfcd25c352a43;hb=b0c7119fa2f43fe1b5978651152974359de5a5d2;hp=5d40820dfd731abf11c942d92800dfb39fad23b0;hpb=b0f5a7b53015ad3de87da115c940ba92f6143116;p=oweals%2Fgnunet.git diff --git a/src/core/gnunet-service-core_typemap.c b/src/core/gnunet-service-core_typemap.c index 5d40820df..d2dab5d99 100644 --- a/src/core/gnunet-service-core_typemap.c +++ b/src/core/gnunet-service-core_typemap.c @@ -36,7 +36,7 @@ * A type map describing which messages a given neighbour is able * to process. */ -struct GSC_TypeMap +struct GSC_TypeMap { uint32_t bits[(UINT16_MAX + 1) / 32]; }; @@ -107,10 +107,8 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg) switch (ntohs (msg->type)) { case GNUNET_MESSAGE_TYPE_CORE_BINARY_TYPE_MAP: - GNUNET_STATISTICS_update (GSC_stats, - gettext_noop ("# type maps received"), - 1, - GNUNET_NO); + GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"), + 1, GNUNET_NO); if (size != sizeof (struct GSC_TypeMap)) { GNUNET_break_op (0); @@ -120,16 +118,13 @@ GSC_TYPEMAP_get_from_message (const struct GNUNET_MessageHeader *msg) 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); + GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# type maps received"), + 1, GNUNET_NO); ret = GNUNET_malloc (sizeof (struct GSC_TypeMap)); dlen = sizeof (struct GSC_TypeMap); - if ( (Z_OK != - uncompress ((Bytef*) ret, &dlen, - (const Bytef*) &msg[1], (uLong) size)) || - (dlen != sizeof (struct GSC_TypeMap) ) ) + if ((Z_OK != + uncompress ((Bytef *) ret, &dlen, (const Bytef *) &msg[1], + (uLong) size)) || (dlen != sizeof (struct GSC_TypeMap))) { GNUNET_break_op (0); GNUNET_free (ret); @@ -152,10 +147,9 @@ broadcast_my_type_map () struct GNUNET_MessageHeader *hdr; hdr = GSC_TYPEMAP_compute_type_map_message (); - GNUNET_STATISTICS_update (GSC_stats, - gettext_noop ("# updates to my type map"), - 1, - GNUNET_NO); + GNUNET_STATISTICS_update (GSC_stats, + gettext_noop ("# updates to my type map"), 1, + GNUNET_NO); GSC_SESSIONS_broadcast (hdr); GNUNET_free (hdr); } @@ -165,14 +159,13 @@ broadcast_my_type_map () * Add a set of types to our type map. */ void -GSC_TYPEMAP_add (const uint16_t *types, - unsigned int tlen) +GSC_TYPEMAP_add (const uint16_t * types, unsigned int tlen) { unsigned int i; int changed; changed = GNUNET_NO; - for (i=0;ibits[types[i] / 32] & (1 << (types[i] % 32)))) return GNUNET_YES; return GNUNET_NO; @@ -237,15 +230,14 @@ GSC_TYPEMAP_test_match (const struct GSC_TypeMap *tmap, /** * Add additional types to a given typemap. * - * @param map map to extend (not changed) + * @param tmap map to extend (not changed) * @param types array of types to add * @param tcnt number of entries in types * @return updated type map (fresh copy) - */ + */ struct GSC_TypeMap * -GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, - const uint16_t *types, - unsigned int tcnt) +GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, const uint16_t * types, + unsigned int tcnt) { struct GSC_TypeMap *ret; unsigned int i; @@ -253,7 +245,7 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, ret = GNUNET_malloc (sizeof (struct GSC_TypeMap)); if (NULL != tmap) memcpy (ret, tmap, sizeof (struct GSC_TypeMap)); - for (i=0;ibits[types[i] / 32] |= (1 << (types[i] % 32)); return ret; } @@ -262,7 +254,7 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap, /** * Create an empty type map. * - * @param map a type map + * @return an empty type map */ struct GSC_TypeMap * GSC_TYPEMAP_create () @@ -274,7 +266,7 @@ GSC_TYPEMAP_create () /** * Free the given type map. * - * @param map a type map + * @param tmap a type map */ void GSC_TYPEMAP_destroy (struct GSC_TypeMap *tmap)