Merge lp:~nicolas-planel/kicad/kicad into lp:kicad/product

Proposed by Nicolas PLANEL
Status: Merged
Merged at revision: 5744
Proposed branch: lp:~nicolas-planel/kicad/kicad
Merge into: lp:kicad/product
Diff against target: 106 lines (+14/-6)
3 files modified
CMakeModules/PerformFeatureChecks.cmake (+3/-0)
utils/idftools/CMakeLists.txt (+3/-0)
utils/idftools/idf2vrml.cpp (+8/-6)
To merge this branch: bzr merge lp:~nicolas-planel/kicad/kicad
Reviewer Review Type Date Requested Status
Wayne Stambaugh Approve
Review via email: mp+261889@code.launchpad.net

Description of the change

5735: Nicolas PLANEL 2015-06-12 Avoid memleak on ColorMap during normal usage
5734: Nicolas PLANEL 2015-06-11 Add missing CXX check : HAVE_STRCASECMP, HAVE_STRNCASECMP on string.h

To post a comment you must log in.
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

Looks good. I will commit this patch. Thank you for your contribution to kicad.

review: Approve
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

You merge request was committed in the product branch r5744.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeModules/PerformFeatureChecks.cmake'
2--- CMakeModules/PerformFeatureChecks.cmake 2015-02-19 01:47:34 +0000
3+++ CMakeModules/PerformFeatureChecks.cmake 2015-06-12 22:41:08 +0000
4@@ -83,6 +83,9 @@
5 check_symbol_exists( strncasecmp "strings.h" HAVE_STRNCASECMP )
6 check_symbol_exists( strtok_r "string.h" HAVE_STRTOKR )
7
8+ check_cxx_symbol_exists( strcasecmp "string.h" HAVE_STRCASECMP )
9+ check_cxx_symbol_exists( strncasecmp "string.h" HAVE_STRNCASECMP )
10+
11 # Some platforms define malloc and free in malloc.h instead of stdlib.h.
12 check_symbol_exists( malloc "stdlib.h" MALLOC_IN_STDLIB_H )
13
14
15=== modified file 'utils/idftools/CMakeLists.txt'
16--- utils/idftools/CMakeLists.txt 2015-03-03 10:50:50 +0000
17+++ utils/idftools/CMakeLists.txt 2015-06-12 22:41:08 +0000
18@@ -2,6 +2,7 @@
19 "${CMAKE_SOURCE_DIR}/lib_dxf"
20 "${CMAKE_SOURCE_DIR}/utils/idftools"
21 ${OPENGL_INCLUDE_DIR}
22+ ${Boost_INCLUDE_DIR}
23 )
24
25 link_directories(
26@@ -17,6 +18,8 @@
27 add_executable( dxf2idf dxf2idfmain.cpp dxf2idf.cpp )
28 add_executable( idf2vrml idf2vrml.cpp )
29
30+add_dependencies( idf2vrml boost )
31+
32 target_link_libraries( dxf2idf lib_dxf idf3 ${wxWidgets_LIBRARIES} )
33
34 target_link_libraries( idf2vrml idf3 ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES} )
35
36=== modified file 'utils/idftools/idf2vrml.cpp'
37--- utils/idftools/idf2vrml.cpp 2014-06-02 10:46:29 +0000
38+++ utils/idftools/idf2vrml.cpp 2015-06-12 22:41:08 +0000
39@@ -49,6 +49,7 @@
40 #include <algorithm>
41 #include <libgen.h>
42 #include <unistd.h>
43+#include <boost/ptr_container/ptr_map.hpp>
44
45 #include <idf_helpers.h>
46 #include <idf_common.h>
47@@ -63,6 +64,7 @@
48 extern int optopt;
49
50 using namespace std;
51+using namespace boost;
52
53 #define CLEANUP do { \
54 setlocale( LC_ALL, "C" ); \
55@@ -122,7 +124,7 @@
56 bool top, double top_z, double bottom_z, int precision, bool compact );
57 inline void TransformPoint( IDF_SEGMENT& seg, double frac, bool bottom,
58 double dX, double dY, double angle );
59-VRML_IDS* GetColor( std::map<std::string, VRML_IDS*>& cmap,
60+VRML_IDS* GetColor( boost::ptr_map<const std::string, VRML_IDS>& cmap,
61 int& index, const std::string& uid );
62
63
64@@ -743,7 +745,7 @@
65 bool bottom;
66 IDF3::IDF_LAYER lyr;
67
68- std::map< std::string, VRML_IDS*> cmap; // map colors by outline UID
69+ boost::ptr_map< const std::string, VRML_IDS> cmap; // map colors by outline UID
70 VRML_IDS* vcp;
71 IDF3_COMP_OUTLINE* pout;
72
73@@ -861,14 +863,14 @@
74 }
75
76
77-VRML_IDS* GetColor( std::map<std::string, VRML_IDS*>& cmap, int& index, const std::string& uid )
78+VRML_IDS* GetColor( boost::ptr_map<const std::string, VRML_IDS>& cmap, int& index, const std::string& uid )
79 {
80 static int refnum = 0;
81
82 if( index < 2 )
83 index = 2; // 0 and 1 are special (BOARD, UID=NOGEOM_NOPART)
84
85- std::map<std::string, VRML_IDS*>::iterator cit = cmap.find( uid );
86+ boost::ptr_map<const std::string, VRML_IDS>::iterator cit = cmap.find( uid );
87
88 if( cit == cmap.end() )
89 {
90@@ -886,7 +888,7 @@
91 if( showObjectMapping )
92 cout << "* " << ostr.str() << " = '" << uid << "'\n";
93
94- cmap.insert( std::pair<std::string, VRML_IDS*>(uid, id) );
95+ cmap.insert( uid, id );
96
97 if( index >= NCOLORS )
98 index = 2;
99@@ -922,7 +924,7 @@
100 bool bottom;
101 int nvcont;
102
103- std::map< std::string, VRML_IDS*> cmap; // map colors by outline UID
104+ boost::ptr_map< const std::string, VRML_IDS> cmap; // map colors by outline UID
105 VRML_IDS* vcp;
106 OTHER_OUTLINE* pout;
107