ted-ross commented on a change in pull request #515: DISPATCH-1348 - Allocate 
qdr_error_t objects only when necessary. Pre…
URL: https://github.com/apache/qpid-dispatch/pull/515#discussion_r289042044
 
 

 ##########
 File path: src/router_core/error.c
 ##########
 @@ -34,19 +34,42 @@ qdr_error_t *qdr_error_from_pn(pn_condition_t *pn)
     if (!pn)
         return 0;
 
-    qdr_error_t *error = new_qdr_error_t();
-    ZERO(error);
+    qdr_error_t *error = 0;
 
     const char *name = pn_condition_get_name(pn);
-    if (name && *name)
+
+    if (name && *name) {
+        if (!error) {
+            error = new_qdr_error_t();
 
 Review comment:
   I think this would be easier to understand if you only called 
new_qdr_error_t() in one place, rather than having to repeatedly check if you 
already created it.  Why not extract the data from the pn_error first, 
determine if a qdr_error is required and if so, create and populate it?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to