aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-05-16 11:58:27 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-05-16 11:58:27 +0000
commite21ae52bafc3384fbc6948e91d419f45b57e898c (patch)
tree031202082a98b0d701c84f75dfe3d6c0cabbc32a /src/transport
parent95fdfb956d324c205b6822d3b5eca25e3851b941 (diff)
downloadgnunet-e21ae52bafc3384fbc6948e91d419f45b57e898c.tar.gz
gnunet-e21ae52bafc3384fbc6948e91d419f45b57e898c.zip
remove memory debug code
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_udp.c259
1 files changed, 41 insertions, 218 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 53e884979..b6d4b3f30 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -62,9 +62,6 @@
62 */ 62 */
63#define UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG 128 63#define UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG 128
64 64
65
66#define DEBUG_MALLOC GNUNET_NO
67
68/** 65/**
69 * Closure for 'append_port'. 66 * Closure for 'append_port'.
70 */ 67 */
@@ -434,176 +431,6 @@ reschedule_session_timeout (struct Session *s);
434static void 431static void
435stop_session_timeout (struct Session *s); 432stop_session_timeout (struct Session *s);
436 433
437#if DEBUG_MALLOC
438
439struct Allocator
440{
441 struct Allocator *prev;
442 struct Allocator *next;
443
444 unsigned int bytes_alloced;
445 unsigned int max_alloced;
446 unsigned int diff;
447 unsigned int line;
448
449 struct GNUNET_TIME_Absolute max_alloced_when;
450 struct GNUNET_TIME_Absolute last_alloced_when;
451
452};
453
454struct Allocator *aehead;
455struct Allocator *aetail;
456
457struct Allocation
458{
459 struct Allocation *prev;
460 struct Allocation *next;
461
462 struct Allocator *alloc;
463 unsigned int bytes_alloced;
464 void *p;
465 unsigned int line;
466};
467
468struct Allocation *ahead;
469struct Allocation *atail;
470
471static int bytes_alloced;
472
473static struct Allocator *
474find_allocator (int line)
475{
476 struct Allocator *cur = aehead;
477 while (NULL != cur)
478 {
479 if (line == cur->line)
480 return cur;
481 cur = cur->next;
482 }
483 return cur;
484}
485
486static void
487print_allocators ()
488{
489 static int start = GNUNET_YES;
490 static struct GNUNET_TIME_Absolute next;
491 static struct GNUNET_TIME_Relative rem;
492 struct Allocator *cur = aehead;
493 if (start)
494 {
495 next = GNUNET_TIME_UNIT_ZERO_ABS;
496 start = GNUNET_NO;
497 }
498 if (0 == (rem = GNUNET_TIME_absolute_get_remaining(next)).rel_value)
499 {
500 fprintf (stderr, "Allocated in `%s' total: %5u bytes\n", __FILE__, bytes_alloced);
501 while (NULL != cur)
502 {
503 char *last_alloc = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string(cur->max_alloced_when));
504 fprintf (stderr, "Allocated from line %4u :%5u bytes (diff %5i bytes, max alloc: %5u @ %s, last alloc %s)\n",
505 cur->line, cur->bytes_alloced, cur->diff, cur->max_alloced,
506 last_alloc,
507 GNUNET_STRINGS_absolute_time_to_string(cur->last_alloced_when));
508 GNUNET_free (last_alloc);
509 cur->diff = 0;
510 cur = cur->next;
511 }
512 fprintf (stderr, "\n");
513 next = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), GNUNET_TIME_UNIT_SECONDS);
514 }
515}
516
517#endif
518
519static void
520MEMDEBUG_add_alloc (void *p, size_t size, int line)
521{
522#if DEBUG_MALLOC
523 struct Allocation *alloc = GNUNET_malloc (sizeof (struct Allocation));
524 struct Allocator *allocator = find_allocator(line);
525 if (NULL == allocator)
526 {
527 allocator = GNUNET_malloc (sizeof (struct Allocator));
528 allocator->line = line;
529 GNUNET_CONTAINER_DLL_insert (aehead, aetail, allocator);
530 }
531 alloc->alloc = allocator;
532 alloc->p = p;
533 alloc->line = line;
534 alloc->bytes_alloced = size;
535 allocator->bytes_alloced += size;
536 allocator->last_alloced_when = GNUNET_TIME_absolute_get();
537 if (allocator->bytes_alloced >= allocator->max_alloced)
538 {
539 allocator->max_alloced = allocator->bytes_alloced;
540 allocator->max_alloced_when = allocator->last_alloced_when;
541 }
542 allocator->diff += size;
543 GNUNET_CONTAINER_DLL_insert (ahead, atail, alloc);
544 print_allocators ();
545 bytes_alloced += size;
546#endif
547}
548
549
550static void *
551MEMDEBUG_malloc (size_t size, int line)
552{
553 void * ret;
554
555 ret = GNUNET_malloc (size);
556#if DEBUG_MALLOC
557 if (NULL != ret)
558 MEMDEBUG_add_alloc (ret, size, line);
559#endif
560 return ret;
561
562}
563
564static void
565MEMDEBUG_free (void * alloc, int line)
566{
567#if DEBUG_MALLOC
568 struct Allocation *cur;
569 struct Allocator *allocator;
570 cur = ahead;
571 while (NULL != cur)
572 {
573 if (alloc == cur->p)
574 break;
575 cur = cur->next;
576 }
577 if (NULL == cur)
578 {
579 fprintf (stderr, "Unmonitored free from line %4u\n", line);
580 GNUNET_break (0);
581 return;
582 }
583 allocator = cur->alloc;
584 if (NULL == allocator)
585 {
586 GNUNET_break (0);
587 }
588 GNUNET_CONTAINER_DLL_remove (ahead, atail, cur);
589 allocator->bytes_alloced -= cur->bytes_alloced;
590 allocator->diff -= cur->bytes_alloced;
591 GNUNET_assert (allocator->bytes_alloced >= 0);
592 bytes_alloced -= cur->bytes_alloced;
593 GNUNET_assert (bytes_alloced >= 0);
594 GNUNET_free (cur);
595#endif
596 GNUNET_free (alloc);
597}
598
599static void
600MEMDEBUG_free_non_null (void * alloc, int line)
601{
602 if (alloc != NULL)
603 MEMDEBUG_free (alloc, line);
604}
605
606
607/** 434/**
608 * (re)schedule select tasks for this plugin. 435 * (re)schedule select tasks for this plugin.
609 * 436 *
@@ -754,7 +581,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
754 { 581 {
755 struct IPv4UdpAddress *u4; 582 struct IPv4UdpAddress *u4;
756 struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address; 583 struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address;
757 u4 = MEMDEBUG_malloc (sizeof (struct IPv4UdpAddress), __LINE__ ); 584 u4 = GNUNET_malloc (sizeof (struct IPv4UdpAddress));
758 u4->ipv4_addr = in4->sin_addr.s_addr; 585 u4->ipv4_addr = in4->sin_addr.s_addr;
759 u4->u4_port = in4->sin_port; 586 u4->u4_port = in4->sin_port;
760 *buf = u4; 587 *buf = u4;
@@ -765,7 +592,7 @@ udp_string_to_address (void *cls, const char *addr, uint16_t addrlen,
765 { 592 {
766 struct IPv6UdpAddress *u6; 593 struct IPv6UdpAddress *u6;
767 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address; 594 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address;
768 u6 = MEMDEBUG_malloc (sizeof (struct IPv6UdpAddress), __LINE__ ); 595 u6 = GNUNET_malloc (sizeof (struct IPv6UdpAddress));
769 u6->ipv6_addr = in6->sin6_addr; 596 u6->ipv6_addr = in6->sin6_addr;
770 u6->u6_port = in6->sin6_port; 597 u6->u6_port = in6->sin6_port;
771 *buf = u6; 598 *buf = u6;
@@ -794,13 +621,12 @@ append_port (void *cls, const char *hostname)
794 if (hostname == NULL) 621 if (hostname == NULL)
795 { 622 {
796 ppc->asc (ppc->asc_cls, NULL); 623 ppc->asc (ppc->asc_cls, NULL);
797 MEMDEBUG_free (ppc, __LINE__); 624 GNUNET_free (ppc);
798 return; 625 return;
799 } 626 }
800 GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port); 627 GNUNET_asprintf (&ret, "%s:%d", hostname, ppc->port);
801 MEMDEBUG_add_alloc (ret, strlen (ret)+ 1, __LINE__);
802 ppc->asc (ppc->asc_cls, ret); 628 ppc->asc (ppc->asc_cls, ret);
803 MEMDEBUG_free (ret, __LINE__); 629 GNUNET_free (ret);
804} 630}
805 631
806 632
@@ -876,7 +702,7 @@ udp_plugin_address_pretty_printer (void *cls, const char *type,
876 asc (asc_cls, NULL); 702 asc (asc_cls, NULL);
877 return; 703 return;
878 } 704 }
879 ppc = MEMDEBUG_malloc (sizeof (struct PrettyPrinterContext), __LINE__ ); 705 ppc = GNUNET_malloc (sizeof (struct PrettyPrinterContext));
880 ppc->asc = asc; 706 ppc->asc = asc;
881 ppc->asc_cls = asc_cls; 707 ppc->asc_cls = asc_cls;
882 ppc->port = port; 708 ppc->port = port;
@@ -1140,10 +966,10 @@ free_session (struct Session *s)
1140 if (NULL != s->frag_ctx) 966 if (NULL != s->frag_ctx)
1141 { 967 {
1142 GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag, NULL, NULL); 968 GNUNET_FRAGMENT_context_destroy(s->frag_ctx->frag, NULL, NULL);
1143 MEMDEBUG_free (s->frag_ctx, __LINE__); 969 GNUNET_free (s->frag_ctx);
1144 s->frag_ctx = NULL; 970 s->frag_ctx = NULL;
1145 } 971 }
1146 MEMDEBUG_free (s, __LINE__); 972 GNUNET_free (s);
1147} 973}
1148 974
1149 975
@@ -1203,7 +1029,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
1203 { 1029 {
1204 dequeue (plugin, udpw); 1030 dequeue (plugin, udpw);
1205 call_continuation (udpw, GNUNET_SYSERR); 1031 call_continuation (udpw, GNUNET_SYSERR);
1206 MEMDEBUG_free (udpw, __LINE__); 1032 GNUNET_free (udpw);
1207 } 1033 }
1208 udpw = tmp; 1034 udpw = tmp;
1209 } 1035 }
@@ -1218,7 +1044,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
1218 { 1044 {
1219 dequeue (plugin, udpw); 1045 dequeue (plugin, udpw);
1220 call_continuation (udpw, GNUNET_SYSERR); 1046 call_continuation (udpw, GNUNET_SYSERR);
1221 MEMDEBUG_free (udpw, __LINE__); 1047 GNUNET_free (udpw);
1222 } 1048 }
1223 udpw = tmp; 1049 udpw = tmp;
1224 } 1050 }
@@ -1229,7 +1055,7 @@ fragmented_message_done (struct UDP_FragmentationContext *fc, int result)
1229 &s->last_expected_msg_delay, 1055 &s->last_expected_msg_delay,
1230 &s->last_expected_ack_delay); 1056 &s->last_expected_ack_delay);
1231 s->frag_ctx = NULL; 1057 s->frag_ctx = NULL;
1232 MEMDEBUG_free (fc , __LINE__); 1058 GNUNET_free (fc );
1233} 1059}
1234 1060
1235/** 1061/**
@@ -1267,7 +1093,7 @@ disconnect_session (struct Session *s)
1267 { 1093 {
1268 dequeue (plugin, udpw); 1094 dequeue (plugin, udpw);
1269 call_continuation(udpw, GNUNET_SYSERR); 1095 call_continuation(udpw, GNUNET_SYSERR);
1270 MEMDEBUG_free (udpw, __LINE__); 1096 GNUNET_free (udpw);
1271 } 1097 }
1272 } 1098 }
1273 next = plugin->ipv6_queue_head; 1099 next = plugin->ipv6_queue_head;
@@ -1278,7 +1104,7 @@ disconnect_session (struct Session *s)
1278 { 1104 {
1279 dequeue (plugin, udpw); 1105 dequeue (plugin, udpw);
1280 call_continuation(udpw, GNUNET_SYSERR); 1106 call_continuation(udpw, GNUNET_SYSERR);
1281 MEMDEBUG_free (udpw, __LINE__); 1107 GNUNET_free (udpw);
1282 } 1108 }
1283 udpw = next; 1109 udpw = next;
1284 } 1110 }
@@ -1440,7 +1266,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
1440 return NULL; 1266 return NULL;
1441 } 1267 }
1442 t4 = addr; 1268 t4 = addr;
1443 s = MEMDEBUG_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in), __LINE__ ); 1269 s = GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in));
1444 len = sizeof (struct sockaddr_in); 1270 len = sizeof (struct sockaddr_in);
1445 v4 = (struct sockaddr_in *) &s[1]; 1271 v4 = (struct sockaddr_in *) &s[1];
1446 v4->sin_family = AF_INET; 1272 v4->sin_family = AF_INET;
@@ -1458,7 +1284,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target,
1458 } 1284 }
1459 t6 = addr; 1285 t6 = addr;
1460 s = 1286 s =
1461 MEMDEBUG_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6), __LINE__ ); 1287 GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6));
1462 len = sizeof (struct sockaddr_in6); 1288 len = sizeof (struct sockaddr_in6);
1463 v6 = (struct sockaddr_in6 *) &s[1]; 1289 v6 = (struct sockaddr_in6 *) &s[1];
1464 v6->sin6_family = AF_INET6; 1290 v6->sin6_family = AF_INET6;
@@ -1681,7 +1507,7 @@ enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
1681 LOG (GNUNET_ERROR_TYPE_DEBUG, 1507 LOG (GNUNET_ERROR_TYPE_DEBUG,
1682 "Enqueuing fragment with %u bytes\n", msg_len); 1508 "Enqueuing fragment with %u bytes\n", msg_len);
1683 frag_ctx->fragments_used ++; 1509 frag_ctx->fragments_used ++;
1684 udpw = MEMDEBUG_malloc (sizeof (struct UDP_MessageWrapper) + msg_len, __LINE__ ); 1510 udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len);
1685 udpw->session = frag_ctx->session; 1511 udpw->session = frag_ctx->session;
1686 udpw->msg_buf = (char *) &udpw[1]; 1512 udpw->msg_buf = (char *) &udpw[1];
1687 udpw->msg_size = msg_len; 1513 udpw->msg_size = msg_len;
@@ -1773,7 +1599,7 @@ udp_plugin_send (void *cls,
1773 if (udpmlen <= UDP_MTU) 1599 if (udpmlen <= UDP_MTU)
1774 { 1600 {
1775 /* unfragmented message */ 1601 /* unfragmented message */
1776 udpw = MEMDEBUG_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen, __LINE__ ); 1602 udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + udpmlen);
1777 udpw->session = s; 1603 udpw->session = s;
1778 udpw->msg_buf = (char *) &udpw[1]; 1604 udpw->msg_buf = (char *) &udpw[1];
1779 udpw->msg_size = udpmlen; /* message size with UDP overhead */ 1605 udpw->msg_size = udpmlen; /* message size with UDP overhead */
@@ -1800,7 +1626,7 @@ udp_plugin_send (void *cls,
1800 if (s->frag_ctx != NULL) 1626 if (s->frag_ctx != NULL)
1801 return GNUNET_SYSERR; 1627 return GNUNET_SYSERR;
1802 memcpy (&udp[1], msgbuf, msgbuf_size); 1628 memcpy (&udp[1], msgbuf, msgbuf_size);
1803 frag_ctx = MEMDEBUG_malloc (sizeof (struct UDP_FragmentationContext), __LINE__ ); 1629 frag_ctx = GNUNET_malloc (sizeof (struct UDP_FragmentationContext));
1804 frag_ctx->plugin = plugin; 1630 frag_ctx->plugin = plugin;
1805 frag_ctx->session = s; 1631 frag_ctx->session = s;
1806 frag_ctx->cont = cont; 1632 frag_ctx->cont = cont;
@@ -1984,9 +1810,8 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg,
1984 GNUNET_a2s (sender_addr, sender_addr_len)); 1810 GNUNET_a2s (sender_addr, sender_addr_len));
1985 1811
1986 struct GNUNET_HELLO_Address * address = GNUNET_HELLO_address_allocate(&msg->sender, "udp", arg, args); 1812 struct GNUNET_HELLO_Address * address = GNUNET_HELLO_address_allocate(&msg->sender, "udp", arg, args);
1987 MEMDEBUG_add_alloc (address, GNUNET_HELLO_address_get_size(address), __LINE__);
1988 s = udp_plugin_get_session(plugin, address); 1813 s = udp_plugin_get_session(plugin, address);
1989 MEMDEBUG_free (address, __LINE__); 1814 GNUNET_free (address);
1990 1815
1991 /* iterate over all embedded messages */ 1816 /* iterate over all embedded messages */
1992 si.session = s; 1817 si.session = s;
@@ -2121,7 +1946,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
2121 AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct 1946 AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct
2122 sockaddr_in6)), 1947 sockaddr_in6)),
2123 delay); 1948 delay);
2124 udpw = MEMDEBUG_malloc (sizeof (struct UDP_MessageWrapper) + msize, __LINE__ ); 1949 udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize);
2125 udpw->msg_size = msize; 1950 udpw->msg_size = msize;
2126 udpw->payload_size = 0; 1951 udpw->payload_size = 0;
2127 udpw->session = s; 1952 udpw->session = s;
@@ -2250,7 +2075,7 @@ read_process_fragment (struct Plugin *plugin,
2250 if (d_ctx == NULL) 2075 if (d_ctx == NULL)
2251 { 2076 {
2252 /* Create a new defragmentation context */ 2077 /* Create a new defragmentation context */
2253 d_ctx = MEMDEBUG_malloc (sizeof (struct DefragContext) + fromlen, __LINE__ ); 2078 d_ctx = GNUNET_malloc (sizeof (struct DefragContext) + fromlen);
2254 memcpy (&d_ctx[1], addr, fromlen); 2079 memcpy (&d_ctx[1], addr, fromlen);
2255 d_ctx->src_addr = (const struct sockaddr *) &d_ctx[1]; 2080 d_ctx->src_addr = (const struct sockaddr *) &d_ctx[1];
2256 d_ctx->addr_len = fromlen; 2081 d_ctx->addr_len = fromlen;
@@ -2290,7 +2115,7 @@ read_process_fragment (struct Plugin *plugin,
2290 d_ctx = GNUNET_CONTAINER_heap_remove_root (plugin->defrag_ctxs); 2115 d_ctx = GNUNET_CONTAINER_heap_remove_root (plugin->defrag_ctxs);
2291 GNUNET_assert (NULL != d_ctx); 2116 GNUNET_assert (NULL != d_ctx);
2292 GNUNET_DEFRAGMENT_context_destroy (d_ctx->defrag); 2117 GNUNET_DEFRAGMENT_context_destroy (d_ctx->defrag);
2293 MEMDEBUG_free (d_ctx, __LINE__); 2118 GNUNET_free (d_ctx);
2294 } 2119 }
2295} 2120}
2296 2121
@@ -2421,7 +2246,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2421 call_continuation (udpw, GNUNET_SYSERR); 2246 call_continuation (udpw, GNUNET_SYSERR);
2422 /* Remove message */ 2247 /* Remove message */
2423 dequeue (plugin, udpw); 2248 dequeue (plugin, udpw);
2424 MEMDEBUG_free (udpw, __LINE__); 2249 GNUNET_free (udpw);
2425 break; 2250 break;
2426 case MSG_FRAGMENTED: 2251 case MSG_FRAGMENTED:
2427 /* Fragmented message */ 2252 /* Fragmented message */
@@ -2458,7 +2283,7 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2458 GNUNET_i2s(&udpw->session->target), udpw->payload_size); 2283 GNUNET_i2s(&udpw->session->target), udpw->payload_size);
2459 call_continuation (udpw, GNUNET_SYSERR); 2284 call_continuation (udpw, GNUNET_SYSERR);
2460 dequeue (plugin, udpw); 2285 dequeue (plugin, udpw);
2461 MEMDEBUG_free (udpw, __LINE__); 2286 GNUNET_free (udpw);
2462 break; 2287 break;
2463 default: 2288 default:
2464 break; 2289 break;
@@ -2600,7 +2425,7 @@ udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock)
2600 call_continuation (udpw, GNUNET_OK); 2425 call_continuation (udpw, GNUNET_OK);
2601 } 2426 }
2602 dequeue (plugin, udpw); 2427 dequeue (plugin, udpw);
2603 MEMDEBUG_free (udpw, __LINE__); 2428 GNUNET_free (udpw);
2604 udpw = NULL; 2429 udpw = NULL;
2605 2430
2606 return sent; 2431 return sent;
@@ -2904,7 +2729,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
2904 { 2729 {
2905 /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully 2730 /* run in 'stub' mode (i.e. as part of gnunet-peerinfo), don't fully
2906 initialze the plugin or the API */ 2731 initialze the plugin or the API */
2907 api = MEMDEBUG_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions), __LINE__ ); 2732 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
2908 api->cls = NULL; 2733 api->cls = NULL;
2909 api->address_pretty_printer = &udp_plugin_address_pretty_printer; 2734 api->address_pretty_printer = &udp_plugin_address_pretty_printer;
2910 api->address_to_string = &udp_address_to_string; 2735 api->address_to_string = &udp_address_to_string;
@@ -2955,7 +2780,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
2955 bind4_address); 2780 bind4_address);
2956 if (1 != inet_pton (AF_INET, bind4_address, &serverAddrv4.sin_addr)) 2781 if (1 != inet_pton (AF_INET, bind4_address, &serverAddrv4.sin_addr))
2957 { 2782 {
2958 MEMDEBUG_free (bind4_address, __LINE__); 2783 GNUNET_free (bind4_address);
2959 return NULL; 2784 return NULL;
2960 } 2785 }
2961 have_bind4 = GNUNET_YES; 2786 have_bind4 = GNUNET_YES;
@@ -2974,8 +2799,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
2974 { 2799 {
2975 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), 2800 LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"),
2976 bind6_address); 2801 bind6_address);
2977 MEMDEBUG_free_non_null (bind4_address, __LINE__); 2802 GNUNET_free_non_null (bind4_address);
2978 MEMDEBUG_free (bind6_address, __LINE__); 2803 GNUNET_free (bind6_address);
2979 return NULL; 2804 return NULL;
2980 } 2805 }
2981 have_bind6 = GNUNET_YES; 2806 have_bind6 = GNUNET_YES;
@@ -2994,12 +2819,11 @@ libgnunet_plugin_transport_udp_init (void *cls)
2994 } 2819 }
2995 else 2820 else
2996 { 2821 {
2997 MEMDEBUG_add_alloc (fancy_interval, strlen (fancy_interval)+ 1, __LINE__);
2998 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_time_to_relative(fancy_interval, &interval)) 2822 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_time_to_relative(fancy_interval, &interval))
2999 { 2823 {
3000 interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); 2824 interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30);
3001 } 2825 }
3002 MEMDEBUG_free (fancy_interval, __LINE__); 2826 GNUNET_free (fancy_interval);
3003 } 2827 }
3004 2828
3005 /* Maximum datarate */ 2829 /* Maximum datarate */
@@ -3009,8 +2833,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
3009 udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */ 2833 udp_max_bps = 1024 * 1024 * 50; /* 50 MB/s == infinity for practical purposes */
3010 } 2834 }
3011 2835
3012 p = MEMDEBUG_malloc (sizeof (struct Plugin), __LINE__ ); 2836 p = GNUNET_malloc (sizeof (struct Plugin));
3013 api = MEMDEBUG_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions), __LINE__ );
3014 2837
3015 GNUNET_BANDWIDTH_tracker_init (&p->tracker, 2838 GNUNET_BANDWIDTH_tracker_init (&p->tracker,
3016 GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30); 2839 GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30);
@@ -3024,7 +2847,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
3024 p->env = env; 2847 p->env = env;
3025 2848
3026 plugin = p; 2849 plugin = p;
3027 2850 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
3028 api->cls = p; 2851 api->cls = p;
3029 api->send = NULL; 2852 api->send = NULL;
3030 api->disconnect = &udp_disconnect; 2853 api->disconnect = &udp_disconnect;
@@ -3043,8 +2866,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
3043 /* FIXME: memory leaks here! (i.e. p->mst, sessions, defrag_ctxs, etc.) */ 2866 /* FIXME: memory leaks here! (i.e. p->mst, sessions, defrag_ctxs, etc.) */
3044 LOG (GNUNET_ERROR_TYPE_ERROR, 2867 LOG (GNUNET_ERROR_TYPE_ERROR,
3045 _("Failed to create network sockets, plugin failed\n")); 2868 _("Failed to create network sockets, plugin failed\n"));
3046 MEMDEBUG_free (p, __LINE__); 2869 GNUNET_free (p);
3047 MEMDEBUG_free (api, __LINE__); 2870 GNUNET_free (api);
3048 return NULL; 2871 return NULL;
3049 } 2872 }
3050 2873
@@ -3054,8 +2877,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
3054 setup_broadcast (p, &serverAddrv6, &serverAddrv4); 2877 setup_broadcast (p, &serverAddrv6, &serverAddrv4);
3055 } 2878 }
3056 2879
3057 MEMDEBUG_free_non_null (bind4_address, __LINE__); 2880 GNUNET_free_non_null (bind4_address);
3058 MEMDEBUG_free_non_null (bind6_address, __LINE__); 2881 GNUNET_free_non_null (bind6_address);
3059 return api; 2882 return api;
3060} 2883}
3061 2884
@@ -3071,7 +2894,7 @@ heap_cleanup_iterator (void *cls,
3071 2894
3072 GNUNET_CONTAINER_heap_remove_node (node); 2895 GNUNET_CONTAINER_heap_remove_node (node);
3073 GNUNET_DEFRAGMENT_context_destroy(d_ctx->defrag); 2896 GNUNET_DEFRAGMENT_context_destroy(d_ctx->defrag);
3074 MEMDEBUG_free (d_ctx, __LINE__); 2897 GNUNET_free (d_ctx);
3075 2898
3076 return GNUNET_YES; 2899 return GNUNET_YES;
3077} 2900}
@@ -3092,7 +2915,7 @@ libgnunet_plugin_transport_udp_done (void *cls)
3092 2915
3093 if (NULL == plugin) 2916 if (NULL == plugin)
3094 { 2917 {
3095 MEMDEBUG_free (api, __LINE__); 2918 GNUNET_free (api);
3096 return NULL; 2919 return NULL;
3097 } 2920 }
3098 2921
@@ -3149,7 +2972,7 @@ libgnunet_plugin_transport_udp_done (void *cls)
3149 struct UDP_MessageWrapper *tmp = udpw->next; 2972 struct UDP_MessageWrapper *tmp = udpw->next;
3150 dequeue (plugin, udpw); 2973 dequeue (plugin, udpw);
3151 call_continuation(udpw, GNUNET_SYSERR); 2974 call_continuation(udpw, GNUNET_SYSERR);
3152 MEMDEBUG_free (udpw, __LINE__); 2975 GNUNET_free (udpw);
3153 2976
3154 udpw = tmp; 2977 udpw = tmp;
3155 } 2978 }
@@ -3159,7 +2982,7 @@ libgnunet_plugin_transport_udp_done (void *cls)
3159 struct UDP_MessageWrapper *tmp = udpw->next; 2982 struct UDP_MessageWrapper *tmp = udpw->next;
3160 dequeue (plugin, udpw); 2983 dequeue (plugin, udpw);
3161 call_continuation(udpw, GNUNET_SYSERR); 2984 call_continuation(udpw, GNUNET_SYSERR);
3162 MEMDEBUG_free (udpw, __LINE__); 2985 GNUNET_free (udpw);
3163 2986
3164 udpw = tmp; 2987 udpw = tmp;
3165 } 2988 }
@@ -3171,8 +2994,8 @@ libgnunet_plugin_transport_udp_done (void *cls)
3171 GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); 2994 GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions);
3172 2995
3173 plugin->nat = NULL; 2996 plugin->nat = NULL;
3174 MEMDEBUG_free (plugin, __LINE__); 2997 GNUNET_free (plugin);
3175 MEMDEBUG_free (api, __LINE__); 2998 GNUNET_free (api);
3176#if DEBUG_MALLOC 2999#if DEBUG_MALLOC
3177 struct Allocation *allocation; 3000 struct Allocation *allocation;
3178 while (NULL != ahead) 3001 while (NULL != ahead)