Skip to content

Commit

Permalink
Revert "qstring: add qstring_free()"
Browse files Browse the repository at this point in the history
This reverts commit 164c374.

A free function for a reference-counted object is in bad taste.
Fortunately, this one is now also unused.  Drop it.

Signed-off-by: Markus Armbruster <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
Markus Armbruster committed Dec 19, 2020
1 parent eab3a46 commit 88e25b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
1 change: 0 additions & 1 deletion include/qapi/qmp/qstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void qstring_append_int(QString *qstring, int64_t value);
void qstring_append(QString *qstring, const char *str);
void qstring_append_chr(QString *qstring, int c);
bool qstring_is_equal(const QObject *x, const QObject *y);
char *qstring_free(QString *qstring, bool return_str);
void qstring_destroy_obj(QObject *obj);

#endif /* QSTRING_H */
27 changes: 5 additions & 22 deletions qobject/qstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,33 +168,16 @@ bool qstring_is_equal(const QObject *x, const QObject *y)
qobject_to(QString, y)->string);
}

/**
* qstring_free(): Free the memory allocated by a QString object
*
* Return: if @return_str, return the underlying string, to be
* g_free(), otherwise NULL is returned.
*/
char *qstring_free(QString *qstring, bool return_str)
{
char *rv = NULL;

if (return_str) {
rv = qstring->string;
} else {
g_free(qstring->string);
}

g_free(qstring);

return rv;
}

/**
* qstring_destroy_obj(): Free all memory allocated by a QString
* object
*/
void qstring_destroy_obj(QObject *obj)
{
QString *qs;

assert(obj != NULL);
qstring_free(qobject_to(QString, obj), FALSE);
qs = qobject_to(QString, obj);
g_free(qs->string);
g_free(qs);
}

0 comments on commit 88e25b1

Please sign in to comment.