diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2025-08-24 22:45:47 +0200 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2025-08-24 22:45:47 +0200 |
commit | a0316f63985074956d217f78f9bca26543473867 (patch) | |
tree | e4679292f8f89c328ecc8d5fc00ff7fba3e0fd11 /lout | |
parent | f3e50968d86cd3f54f6d274a5abe72094cafd19d (diff) |
Object::toString() free responsibility to caller
It already was the caller responsibility, but it was documented as not
being so, with a todo comment. Until other implementation is provided,
this was leaking memory. No need to keep the const.
Diffstat (limited to 'lout')
-rw-r--r-- | lout/object.cc | 6 | ||||
-rw-r--r-- | lout/object.hh | 22 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lout/object.cc b/lout/object.cc index 5c2ee433..5745e03d 100644 --- a/lout/object.cc +++ b/lout/object.cc @@ -2,6 +2,7 @@ * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org> + * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,12 +77,11 @@ Object *Object::clone() * \brief Use object::Object::intoStringBuffer to return a textual * representation of the object. * - * The caller does not have to free the memory, object::Object is responsible + * The caller must free the memory, object::Object is not responsible * for this. */ -const char *Object::toString() +char *Object::toString() { - /** \todo garbage! */ misc::StringBuffer sb; intoStringBuffer(&sb); char *s = dStrdup(sb.getChars()); diff --git a/lout/object.hh b/lout/object.hh index 9cacff77..c9fa0458 100644 --- a/lout/object.hh +++ b/lout/object.hh @@ -1,3 +1,23 @@ +/* + * Dillo Widget + * + * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org> + * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #ifndef __LOUT_OBJECT_HH__ #define __LOUT_OBJECT_HH__ @@ -29,7 +49,7 @@ public: virtual int hashValue(); virtual Object *clone(); virtual void intoStringBuffer(misc::StringBuffer *sb); - const char *toString(); + char *toString(); virtual size_t sizeOf(); }; |