qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From astitc...@apache.org
Subject qpid-proton git commit: PROTON-1607: Make sure C examples are valid C89 so that VS 2010 can compile them
Date Mon, 02 Oct 2017 21:33:16 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/master b0a0633be -> 9e862258f


PROTON-1607: Make sure C examples are valid C89 so that VS 2010 can compile them


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/9e862258
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/9e862258
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/9e862258

Branch: refs/heads/master
Commit: 9e862258f10a7c1ce16b4ca644202cc4c3e5af57
Parents: b0a0633
Author: Andrew Stitcher <astitcher@apache.org>
Authored: Mon Oct 2 17:28:45 2017 -0400
Committer: Andrew Stitcher <astitcher@apache.org>
Committed: Mon Oct 2 17:27:47 2017 -0400

----------------------------------------------------------------------
 examples/c/broker.c     | 48 ++++++++++++++++++++++++++++----------------
 examples/c/direct.c     | 14 +++++++++----
 examples/c/receive.c    | 15 +++++++++-----
 examples/c/send-abort.c | 20 ++++++++++++------
 examples/c/send.c       | 16 +++++++++++----
 examples/c/thread.h     |  6 ++----
 6 files changed, 79 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e862258/examples/c/broker.c
----------------------------------------------------------------------
diff --git a/examples/c/broker.c b/examples/c/broker.c
index 3a4d04a..b509910 100644
--- a/examples/c/broker.c
+++ b/examples/c/broker.c
@@ -34,9 +34,9 @@
 
 #define VEC_INIT(V)                             \
   do {                                          \
+    void **vp = (void**)&V.data;                \
     V.len = 0;                                  \
     V.cap = 16;                                 \
-    void **vp = (void**)&V.data;                \
     *vp = malloc(V.cap * sizeof(*V.data));      \
   } while(0)
 
@@ -45,8 +45,8 @@
 #define VEC_PUSH(V, X)                                  \
   do {                                                  \
     if (V.len == V.cap) {                               \
-      V.cap *= 2;                                       \
       void **vp = (void**)&V.data;                      \
+      V.cap *= 2;                                       \
       *vp = realloc(V.data, V.cap * sizeof(*V.data));   \
     }                                                   \
     V.data[V.len++] = X;                                \
@@ -78,12 +78,13 @@ static void queue_init(queue_t *q, const char* name, queue_t *next) {
 }
 
 static void queue_destroy(queue_t *q) {
+  size_t i;
   pthread_mutex_destroy(&q->lock);
   free(q->name);
-  for (size_t i = 0; i < q->messages.len; ++i)
+  for (i = 0; i < q->messages.len; ++i)
     free(q->messages.data[i].start);
   VEC_FINAL(q->messages);
-  for (size_t i = 0; i < q->waiting.len; ++i)
+  for (i = 0; i < q->waiting.len; ++i)
     pn_decref(q->waiting.data[i]);
   VEC_FINAL(q->waiting);
 }
@@ -144,7 +145,8 @@ static void queue_receive(pn_proactor_t *d, queue_t *q, pn_rwbytes_t m)
{
   pthread_mutex_lock(&q->lock);
   VEC_PUSH(q->messages, m);
   if (q->messages.len == 1) { /* Was empty, notify waiting connections */
-    for (size_t i = 0; i < q->waiting.len; ++i) {
+    size_t i;
+    for (i = 0; i < q->waiting.len; ++i) {
       pn_connection_t *c = q->waiting.data[i];
       set_check_queues(c, true);
       pn_connection_wake(c); /* Wake the connection */
@@ -167,7 +169,8 @@ void queues_init(queues_t *qs) {
 }
 
 void queues_destroy(queues_t *qs) {
-  for (queue_t *q = qs->queues; q; q = q->next) {
+  queue_t *q;
+  for (q = qs->queues; q; q = q->next) {
     queue_destroy(q);
     free(q);
   }
@@ -176,8 +179,8 @@ void queues_destroy(queues_t *qs) {
 
 /** Get or create the named queue. */
 queue_t* queues_get(queues_t *qs, const char* name) {
-  pthread_mutex_lock(&qs->lock);
   queue_t *q;
+  pthread_mutex_lock(&qs->lock);
   for (q = qs->queues; q && strcmp(q->name, name) != 0; q = q->next)
     ;
   if (!q) {
@@ -213,8 +216,9 @@ static void link_send(broker_t *b, pn_link_t *s) {
 }
 
 static void queue_unsub(queue_t *q, pn_connection_t *c) {
+  size_t i;
   pthread_mutex_lock(&q->lock);
-  for (size_t i = 0; i < q->waiting.len; ++i) {
+  for (i = 0; i < q->waiting.len; ++i) {
     if (q->waiting.data[i] == c){
       q->waiting.data[i] = q->waiting.data[0]; /* save old [0] */
       VEC_POP(q->waiting);
@@ -237,13 +241,15 @@ static void link_unsub(broker_t *b, pn_link_t *s) {
 
 /* Called in connection's event loop when a connection is woken for messages.*/
 static void connection_unsub(broker_t *b, pn_connection_t *c) {
-  for (pn_link_t *l = pn_link_head(c, 0); l != NULL; l = pn_link_next(l, 0))
+  pn_link_t *l;
+  for (l = pn_link_head(c, 0); l != NULL; l = pn_link_next(l, 0))
     link_unsub(b, l);
 }
 
 static void session_unsub(broker_t *b, pn_session_t *ssn) {
   pn_connection_t *c = pn_session_connection(ssn);
-  for (pn_link_t *l = pn_link_head(c, 0); l != NULL; l = pn_link_next(l, 0)) {
+  pn_link_t *l;
+  for (l = pn_link_head(c, 0); l != NULL; l = pn_link_next(l, 0)) {
     if (pn_link_session(l) == ssn)
       link_unsub(b, l);
   }
@@ -289,9 +295,10 @@ static void handle(broker_t* b, pn_event_t* e) {
    }
    case PN_CONNECTION_WAKE: {
      if (get_check_queues(c)) {
-       set_check_queues(c, false);
        int flags = PN_LOCAL_ACTIVE&PN_REMOTE_ACTIVE;
-       for (pn_link_t *l = pn_link_head(c, flags); l != NULL; l = pn_link_next(l, flags))
+       pn_link_t *l;
+       set_check_queues(c, false);
+       for (l = pn_link_head(c, flags); l != NULL; l = pn_link_next(l, flags))
          link_send(b, l);
      }
      break;
@@ -331,9 +338,10 @@ static void handle(broker_t* b, pn_event_t* e) {
        pn_link_t *l = pn_delivery_link(d);
        size_t size = pn_delivery_pending(d);
        pn_rwbytes_t* m = message_buffer(l); /* Append data to incoming message buffer */
+       int err;
        m->size += size;
        m->start = (char*)realloc(m->start, m->size);
-       int err = pn_link_recv(l, m->start, m->size);
+       err = pn_link_recv(l, m->start, m->size);
        if (err < 0 && err != PN_EOS) {
          fprintf(stderr, "PN_DELIVERY error: %s\n", pn_code(err));
          pn_delivery_settle(d); /* Free the delivery so we can receive the next message */
@@ -409,30 +417,36 @@ static void* broker_thread(void *void_broker) {
 }
 
 int main(int argc, char **argv) {
+  const char *host = (argc > 1) ? argv[1] : "";
+  const char *port = (argc > 2) ? argv[2] : "amqp";
+
   broker_t b = {0};
   b.proactor = pn_proactor();
   queues_init(&b.queues);
   b.container_id = argv[0];
   b.threads = 4;
-  const char *host = (argc > 1) ? argv[1] : "";
-  const char *port = (argc > 2) ? argv[2] : "amqp";
 
+  {
   /* Listen on addr */
   char addr[PN_MAX_ADDR];
   pn_proactor_addr(addr, sizeof(addr), host, port);
   pn_proactor_listen(b.proactor, pn_listener(), addr, 16);
+  }
 
+  {
   /* Start n-1 threads */
   pthread_t* threads = (pthread_t*)calloc(sizeof(pthread_t), b.threads);
-  for (size_t i = 0; i < b.threads-1; ++i) {
+  size_t i;
+  for (i = 0; i < b.threads-1; ++i) {
     pthread_create(&threads[i], NULL, broker_thread, &b);
   }
   broker_thread(&b);            /* Use the main thread too. */
   /* Join the other threads */
-  for (size_t i = 0; i < b.threads-1; ++i) {
+  for (i = 0; i < b.threads-1; ++i) {
     pthread_join(threads[i], NULL);
   }
   pn_proactor_free(b.proactor);
   free(threads);
   return 0;
+  }
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e862258/examples/c/direct.c
----------------------------------------------------------------------
diff --git a/examples/c/direct.c b/examples/c/direct.c
index f55519e..5f72ba7 100644
--- a/examples/c/direct.c
+++ b/examples/c/direct.c
@@ -78,8 +78,8 @@ static void check_condition(pn_event_t *e, pn_condition_t *cond, app_data_t
*app
 static pn_bytes_t encode_message(app_data_t* app) {
   /* Construct a message with the map { "sequence": app.sent } */
   pn_message_t* message = pn_message();
-  pn_data_put_int(pn_message_id(message), app->sent); /* Set the message_id also */
   pn_data_t* body = pn_message_body(message);
+  pn_data_put_int(pn_message_id(message), app->sent); /* Set the message_id also */
   pn_data_put_map(body);
   pn_data_enter(body);
   pn_data_put_string(body, pn_bytes(sizeof("sequence")-1, "sequence"));
@@ -93,6 +93,7 @@ static pn_bytes_t encode_message(app_data_t* app) {
   }
   /* app->msgout is the total buffer space available. */
   /* mbuf wil point at just the portion used by the encoded message */
+  {
   pn_rwbytes_t mbuf = pn_rwbytes(app->msgout.size, app->msgout.start);
   int status = 0;
   while ((status = pn_message_encode(message, mbuf.start, &mbuf.size)) == PN_OVERFLOW)
{
@@ -106,6 +107,7 @@ static pn_bytes_t encode_message(app_data_t* app) {
   }
   pn_message_free(message);
   return pn_bytes(mbuf.size, mbuf.start);
+  }
 }
 
 static void decode_message(pn_rwbytes_t data) {
@@ -142,9 +144,10 @@ static void handle_receive(app_data_t* app, pn_event_t* event) {
        pn_link_t *l = pn_delivery_link(d);
        size_t size = pn_delivery_pending(d);
        pn_rwbytes_t* m = &app->msgin; /* Append data to incoming message buffer */
+       int err;
        m->size += size;
        m->start = (char*)realloc(m->start, m->size);
-       int err = pn_link_recv(l, m->start, m->size);
+       err = pn_link_recv(l, m->start, m->size);
        if (err < 0 && err != PN_EOS) {
          fprintf(stderr, "PN_DELIVERY error: %s\n", pn_code(err));
          pn_delivery_settle(d); /* Free the delivery so we can receive the next message */
@@ -189,9 +192,11 @@ static void handle_send(app_data_t* app, pn_event_t* event) {
        ++app->sent;
        // Use sent counter as unique delivery tag.
        pn_delivery(sender, pn_dtag((const char *)&app->sent, sizeof(app->sent)));
+       {
        pn_bytes_t msgbuf = encode_message(app);
        pn_link_send(sender, msgbuf.start, msgbuf.size);
        pn_link_advance(sender);
+       }
      }
      break;
    }
@@ -301,7 +306,8 @@ void run(app_data_t *app) {
   /* Loop and handle events */
   do {
     pn_event_batch_t *events = pn_proactor_wait(app->proactor);
-    for (pn_event_t *e = pn_event_batch_next(events); e; e = pn_event_batch_next(events))
{
+    pn_event_t *e;
+    for (e = pn_event_batch_next(events); e; e = pn_event_batch_next(events)) {
       if (!handle(app, e)) {
         return;
       }
@@ -312,6 +318,7 @@ void run(app_data_t *app) {
 
 int main(int argc, char **argv) {
   struct app_data_t app = {0};
+  char addr[PN_MAX_ADDR];
   app.container_id = argv[0];   /* Should be unique */
   app.host = (argc > 1) ? argv[1] : "";
   app.port = (argc > 2) ? argv[2] : "amqp";
@@ -321,7 +328,6 @@ int main(int argc, char **argv) {
   /* Create the proactor and connect */
   app.proactor = pn_proactor();
   app.listener = pn_listener();
-  char addr[PN_MAX_ADDR];
   pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
   pn_proactor_listen(app.proactor, app.listener, addr, 16);
   run(&app);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e862258/examples/c/receive.c
----------------------------------------------------------------------
diff --git a/examples/c/receive.c b/examples/c/receive.c
index 7df955a..16f1a66 100644
--- a/examples/c/receive.c
+++ b/examples/c/receive.c
@@ -79,27 +79,30 @@ static bool handle(app_data_t* app, pn_event_t* event) {
 
    case PN_CONNECTION_INIT: {
      pn_connection_t* c = pn_event_connection(event);
+     pn_session_t* s = pn_session(c);
      pn_connection_set_container(c, app->container_id);
      pn_connection_open(c);
-     pn_session_t* s = pn_session(c);
      pn_session_open(s);
+     {
      pn_link_t* l = pn_receiver(s, "my_receiver");
      pn_terminus_set_address(pn_link_source(l), app->amqp_address);
      pn_link_open(l);
      /* cannot receive without granting credit: */
      pn_link_flow(l, app->message_count ? app->message_count : BATCH);
+     }
    } break;
 
    case PN_DELIVERY: {
      /* A message has been received */
      pn_delivery_t *d = pn_event_delivery(event);
+     int err;
      if (pn_delivery_readable(d)) {
        pn_link_t *l = pn_delivery_link(d);
        size_t size = pn_delivery_pending(d);
        pn_rwbytes_t* m = &app->msgin; /* Append data to incoming message buffer */
        m->size += size;
        m->start = (char*)realloc(m->start, m->size);
-       int err = pn_link_recv(l, m->start, m->size);
+       err = pn_link_recv(l, m->start, m->size);
        if (err < 0 && err != PN_EOS) {
          fprintf(stderr, "PN_DELIVERY error: %s\n", pn_code(err));
          pn_delivery_settle(d); /* Free the delivery so we can receive the next message */
@@ -117,8 +120,8 @@ static bool handle(app_data_t* app, pn_event_t* event) {
              pn_link_flow(l, BATCH - pn_link_credit(l));
            }
          } else if (++app->received >= app->message_count) {
-           printf("%d messages received\n", app->received);
            pn_session_t *ssn = pn_link_session(l);
+           printf("%d messages received\n", app->received);
            pn_link_close(l);
            pn_session_close(ssn);
            pn_connection_close(pn_session_connection(ssn));
@@ -162,7 +165,8 @@ void run(app_data_t *app) {
   /* Loop and handle events */
   do {
     pn_event_batch_t *events = pn_proactor_wait(app->proactor);
-    for (pn_event_t *e = pn_event_batch_next(events); e; e = pn_event_batch_next(events))
{
+    pn_event_t *e;
+    for (e = pn_event_batch_next(events); e; e = pn_event_batch_next(events)) {
       if (!handle(app, e) || exit_code != 0) {
         return;
       }
@@ -173,6 +177,8 @@ void run(app_data_t *app) {
 
 int main(int argc, char **argv) {
   struct app_data_t app = {0};
+  char addr[PN_MAX_ADDR];
+
   app.container_id = argv[0];   /* Should be unique */
   app.host = (argc > 1) ? argv[1] : "";
   app.port = (argc > 2) ? argv[2] : "amqp";
@@ -181,7 +187,6 @@ int main(int argc, char **argv) {
 
   /* Create the proactor and connect */
   app.proactor = pn_proactor();
-  char addr[PN_MAX_ADDR];
   pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
   pn_proactor_connect(app.proactor, pn_connection(), addr);
   run(&app);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e862258/examples/c/send-abort.c
----------------------------------------------------------------------
diff --git a/examples/c/send-abort.c b/examples/c/send-abort.c
index 535a416..fcf3550 100644
--- a/examples/c/send-abort.c
+++ b/examples/c/send-abort.c
@@ -78,10 +78,12 @@ static pn_bytes_t encode_message(app_data_t* app) {
   /* Construct a message with the map { "sequence": app.sent } */
   pn_message_t* message = pn_message();
   char data[MSG_SIZE + 11];
-  for (size_t i=0; i<MSG_SIZE; i+=10) 
+  size_t i;
+  pn_data_t* body;
+  for (i=0; i<MSG_SIZE; i+=10) 
       sprintf(&data[i], "<%09zu", i);
   pn_data_put_int(pn_message_id(message), app->sent); /* Set the message_id also */
-  pn_data_t* body = pn_message_body(message);
+  body = pn_message_body(message);
   pn_data_enter(body);
   pn_data_put_string(body, pn_bytes(MSG_SIZE, data));
   pn_data_exit(body);
@@ -93,6 +95,7 @@ static pn_bytes_t encode_message(app_data_t* app) {
   }
   /* app->message_buffer is the total buffer space available. */
   /* mbuf wil point at just the portion used by the encoded message */
+  {
   pn_rwbytes_t mbuf = pn_rwbytes(app->message_buffer.size, app->message_buffer.start);
   int status = 0;
   while ((status = pn_message_encode(message, mbuf.start, &mbuf.size)) == PN_OVERFLOW)
{
@@ -106,6 +109,7 @@ static pn_bytes_t encode_message(app_data_t* app) {
   }
   pn_message_free(message);
   return pn_bytes(mbuf.size, mbuf.start);
+  }
 }
 
 /* Returns true to continue, false if finished */
@@ -114,14 +118,16 @@ static bool handle(app_data_t* app, pn_event_t* event) {
 
    case PN_CONNECTION_INIT: {
      pn_connection_t* c = pn_event_connection(event);
+     pn_session_t* s = pn_session(pn_event_connection(event));
      pn_connection_set_container(c, app->container_id);
      pn_connection_open(c);
-     pn_session_t* s = pn_session(pn_event_connection(event));
      pn_session_open(s);
+     {
      pn_link_t* l = pn_sender(s, "my_sender");
      pn_terminus_set_address(pn_link_target(l), app->amqp_address);
      pn_link_open(l);
      break;
+     }
    }
 
    case PN_LINK_FLOW: {
@@ -129,9 +135,9 @@ static bool handle(app_data_t* app, pn_event_t* event) {
      pn_link_t *sender = pn_event_link(event);
      while (app->in_progress || (pn_link_credit(sender) > 0 && app->sent
< app->message_count)) {
         if (!app->in_progress) {
+          pn_bytes_t msgbuf = encode_message(app);
           // Use sent counter as unique delivery tag.
           pn_delivery(sender, pn_dtag((const char *)&app->sent, sizeof(app->sent)));
-          pn_bytes_t msgbuf = encode_message(app);
           pn_link_send(sender, msgbuf.start, msgbuf.size - HOLDBACK); // Send some part of
message
           app->in_progress = true;
           // Return from this link flow event and abort the message on next,
@@ -193,7 +199,8 @@ void run(app_data_t *app) {
   /* Loop and handle events */
   do {
     pn_event_batch_t *events = pn_proactor_wait(app->proactor);
-    for (pn_event_t *e = pn_event_batch_next(events); e; e = pn_event_batch_next(events))
{
+    pn_event_t* e;
+    for (e = pn_event_batch_next(events); e; e = pn_event_batch_next(events)) {
       if (!handle(app, e)) {
         return;
       }
@@ -204,6 +211,8 @@ void run(app_data_t *app) {
 
 int main(int argc, char **argv) {
   struct app_data_t app = {0};
+  char addr[PN_MAX_ADDR];
+
   app.container_id = argv[0];   /* Should be unique */
   app.host = (argc > 1) ? argv[1] : "";
   app.port = (argc > 2) ? argv[2] : "amqp";
@@ -211,7 +220,6 @@ int main(int argc, char **argv) {
   app.message_count = (argc > 4) ? atoi(argv[4]) : 10;
 
   app.proactor = pn_proactor();
-  char addr[PN_MAX_ADDR];
   pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
   pn_proactor_connect(app.proactor, pn_connection(), addr);
   run(&app);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e862258/examples/c/send.c
----------------------------------------------------------------------
diff --git a/examples/c/send.c b/examples/c/send.c
index c1a6244..9817164 100644
--- a/examples/c/send.c
+++ b/examples/c/send.c
@@ -58,8 +58,8 @@ static void check_condition(pn_event_t *e, pn_condition_t *cond) {
 static pn_bytes_t encode_message(app_data_t* app) {
   /* Construct a message with the map { "sequence": app.sent } */
   pn_message_t* message = pn_message();
-  pn_data_put_int(pn_message_id(message), app->sent); /* Set the message_id also */
   pn_data_t* body = pn_message_body(message);
+  pn_data_put_int(pn_message_id(message), app->sent); /* Set the message_id also */
   pn_data_put_map(body);
   pn_data_enter(body);
   pn_data_put_string(body, pn_bytes(sizeof("sequence")-1, "sequence"));
@@ -73,6 +73,7 @@ static pn_bytes_t encode_message(app_data_t* app) {
   }
   /* app->message_buffer is the total buffer space available. */
   /* mbuf wil point at just the portion used by the encoded message */
+  {
   pn_rwbytes_t mbuf = pn_rwbytes(app->message_buffer.size, app->message_buffer.start);
   int status = 0;
   while ((status = pn_message_encode(message, mbuf.start, &mbuf.size)) == PN_OVERFLOW)
{
@@ -86,6 +87,7 @@ static pn_bytes_t encode_message(app_data_t* app) {
   }
   pn_message_free(message);
   return pn_bytes(mbuf.size, mbuf.start);
+  }
 }
 
 /* Returns true to continue, false if finished */
@@ -94,14 +96,16 @@ static bool handle(app_data_t* app, pn_event_t* event) {
 
    case PN_CONNECTION_INIT: {
      pn_connection_t* c = pn_event_connection(event);
+     pn_session_t* s = pn_session(pn_event_connection(event));
      pn_connection_set_container(c, app->container_id);
      pn_connection_open(c);
-     pn_session_t* s = pn_session(pn_event_connection(event));
      pn_session_open(s);
+     {
      pn_link_t* l = pn_sender(s, "my_sender");
      pn_terminus_set_address(pn_link_target(l), app->amqp_address);
      pn_link_open(l);
      break;
+     }
    }
 
    case PN_LINK_FLOW: {
@@ -111,8 +115,10 @@ static bool handle(app_data_t* app, pn_event_t* event) {
        ++app->sent;
        // Use sent counter as unique delivery tag.
        pn_delivery(sender, pn_dtag((const char *)&app->sent, sizeof(app->sent)));
+       {
        pn_bytes_t msgbuf = encode_message(app);
        pn_link_send(sender, msgbuf.start, msgbuf.size);
+       }
        pn_link_advance(sender);
      }
      break;
@@ -167,7 +173,8 @@ void run(app_data_t *app) {
   /* Loop and handle events */
   do {
     pn_event_batch_t *events = pn_proactor_wait(app->proactor);
-    for (pn_event_t *e = pn_event_batch_next(events); e; e = pn_event_batch_next(events))
{
+    pn_event_t *e;
+    for (e = pn_event_batch_next(events); e; e = pn_event_batch_next(events)) {
       if (!handle(app, e)) {
         return;
       }
@@ -178,6 +185,8 @@ void run(app_data_t *app) {
 
 int main(int argc, char **argv) {
   struct app_data_t app = {0};
+  char addr[PN_MAX_ADDR];
+
   app.container_id = argv[0];   /* Should be unique */
   app.host = (argc > 1) ? argv[1] : "";
   app.port = (argc > 2) ? argv[2] : "amqp";
@@ -185,7 +194,6 @@ int main(int argc, char **argv) {
   app.message_count = (argc > 4) ? atoi(argv[4]) : 10;
 
   app.proactor = pn_proactor();
-  char addr[PN_MAX_ADDR];
   pn_proactor_addr(addr, sizeof(addr), app.host, app.port);
   pn_proactor_connect(app.proactor, pn_connection(), addr);
   run(&app);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/9e862258/examples/c/thread.h
----------------------------------------------------------------------
diff --git a/examples/c/thread.h b/examples/c/thread.h
index d96104a..e675ed7 100644
--- a/examples/c/thread.h
+++ b/examples/c/thread.h
@@ -38,12 +38,10 @@ static unsigned __stdcall pthread_run(void *thr0) {
 }
 
 static int pthread_create(pthread_t *t, void *unused, void *(*f)(void *), void *arg) {
-  t->handle = 0;
   t->func = f;
   t->arg = arg;
-  HANDLE th = (HANDLE) _beginthreadex(0, 0, &pthread_run, t, 0, 0);
-  if (th) {
-    t->handle = th;
+  t->handle =  (HANDLE) _beginthreadex(0, 0, &pthread_run, t, 0, 0);
+  if (t->handle) {
     return 0;
   }
   return -1;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message