=== modified file 'src/svg/itos.cpp' --- src/svg/itos.cpp 2008-01-31 19:06:59 +0000 +++ src/svg/itos.cpp 2012-03-31 16:16:33 +0000 @@ -18,7 +18,7 @@ #include // for string #include -using namespace std; +using std::string; string itos(int n) { === modified file 'src/svg/svg-color.cpp' --- src/svg/svg-color.cpp 2012-02-13 09:27:56 +0000 +++ src/svg/svg-color.cpp 2012-04-01 17:54:21 +0000 @@ -24,6 +24,8 @@ #include // g_assert #include +#include + #include "strneq.h" #include "preferences.h" #include "svg-color.h" @@ -39,11 +41,12 @@ #include "cms-system.h" using std::sprintf; +using std::string; using Inkscape::CMSSystem; struct SPSVGColor { unsigned long rgb; - char const *name; + const string name; }; /* @@ -199,7 +202,7 @@ { 0x9ACD32, "yellowgreen" } }; -static GHashTable *sp_svg_create_color_hash(); +static std::map sp_svg_create_color_hash(); guint32 sp_svg_read_color(gchar const *str, guint32 const dfl) @@ -210,7 +213,7 @@ static guint32 internal_sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def) { - static GHashTable *colors = NULL; + static std::map colors; guint32 val = 0; if (str == NULL) return def; @@ -309,7 +312,7 @@ return val; } else { gint i; - if (!colors) { + if (colors.size() == 0) { colors = sp_svg_create_color_hash(); } gchar c[32]; @@ -323,10 +326,9 @@ } c[31] = '\0'; - gpointer const rgb_ptr = g_hash_table_lookup(colors, c); - if (rgb_ptr) { - val = *(static_cast(rgb_ptr)); - } else { + if ((val = colors[string(c)])) + ; + else { return def; } if (end_ptr) { @@ -443,17 +445,14 @@ } } -static GHashTable * +static std::map sp_svg_create_color_hash() { - GHashTable *colors = g_hash_table_new(g_str_hash, g_str_equal); + std::map colors; for (unsigned i = 0 ; i < G_N_ELEMENTS(sp_svg_color_named) ; i++) { - g_hash_table_insert(colors, - (gpointer)(sp_svg_color_named[i].name), - (gpointer)(&sp_svg_color_named[i].rgb)); + colors[sp_svg_color_named[i].name] = sp_svg_color_named[i].rgb; } - return colors; }