From: SourceForge.net <no...@so...> - 2012-04-13 19:29:59
|
Patches item #3511009, was opened at 2012-03-25 05:37 Message generated for change (Comment added) made by wsfulton You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=301645&aid=3511009&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None >Status: Closed >Resolution: Accepted Priority: 3 Private: No Submitted By: T_UNIX () >Assigned to: William Fulton (wsfulton) Summary: "if(x)free(x)"->"free(x)" and "free+malloc" -> "realloc" Initial Comment: This patch optimizes the generated C/C++ code a little bit. It replaces some C/C++ template code with better versions. Namely: if (x) free(x); by free(x); and free(x); $1 = malloc(...); by $1 = realloc(x, ...); ---------------------------------------------------------------------- >Comment By: William Fulton (wsfulton) Date: 2012-04-13 12:29 Message: Applied for swig-2.0.5, thanks. ---------------------------------------------------------------------- Comment By: T_UNIX () Date: 2012-04-13 07:17 Message: Hey guys, sorry for replying so late. I changed the patch according to Vadim's input, but want to explain why I did it different in the first place: 1.) I inverted the input condition, because I was thinking of a function when I wrote it. And when I write functions I usually go for the 'return ASAP' paradigm. Then I realized it isn't a function but didn't change it back. 2.) The cast is imo not necessary, but was there, so I just left it there. ---------------------------------------------------------------------- Comment By: Vadim Zeitlin (vadz) Date: 2012-03-25 08:11 Message: The updated patch looks ok to me although I don't know why: 1. Did the direction of the test for "$input" have to be inverted, AFAICS you could have kept the old "if ($input)" and just add/move free() to the else branch. 2. Is the cast to "char*" for realloc() needed, it takes "void*" so passing any pointer to it should be just fine. William, ok to apply? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=301645&aid=3511009&group_id=1645 |