From: Adam Dickmeiss Date: Fri, 16 Dec 2011 11:44:45 +0000 (+0100) Subject: util: Fix leak in uri_encode. Add uri_decode X-Git-Tag: v1.3.19~4 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=3b9de1c22d69590ad7470a27f9091f61bb825d7e;p=metaproxy-moved-to-github.git util: Fix leak in uri_encode. Add uri_decode --- diff --git a/include/metaproxy/util.hpp b/include/metaproxy/util.hpp index 7c9f1ee..3df8654 100644 --- a/include/metaproxy/util.hpp +++ b/include/metaproxy/util.hpp @@ -125,6 +125,7 @@ namespace metaproxy_1 { const char **element_set_name); std::string uri_encode(std::string s); + std::string uri_decode(std::string s); }; class odr : public boost::noncopyable { diff --git a/src/util.cpp b/src/util.cpp index 1f335a1..4265682 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -690,9 +690,21 @@ std::string mp_util::uri_encode(std::string s) char *x = (char *) xmalloc(1 + s.length() * 3); yaz_encode_uri_component(x, s.c_str()); std::string result(x); + xfree(x); return result; } + +std::string mp_util::uri_decode(std::string s) +{ + char *x = (char *) xmalloc(1 + s.length()); + yaz_decode_uri_component(x, s.c_str(), s.length()); + std::string result(x); + xfree(x); + return result; +} + + /* * Local variables: * c-basic-offset: 4