diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h index 0e690f4849807f45d05cab443f381ffd63c6d6e9..1bc3666107ca766814aa11e1b6838da30b920a59 100644 --- a/include/qapi/qmp/qstring.h +++ b/include/qapi/qmp/qstring.h @@ -26,6 +26,7 @@ typedef struct QString { QString *qstring_new(void); QString *qstring_from_str(const char *str); QString *qstring_from_substr(const char *str, int start, int end); +size_t qstring_get_length(const QString *qstring); const char *qstring_get_str(const QString *qstring); void qstring_append_int(QString *qstring, int64_t value); void qstring_append(QString *qstring, const char *str); diff --git a/qobject/qstring.c b/qobject/qstring.c index 5f7376c336fec182320c98cba097008e318869c1..607b7a142c697f5382b3418c3730980e2b8da2f0 100644 --- a/qobject/qstring.c +++ b/qobject/qstring.c @@ -31,6 +31,14 @@ QString *qstring_new(void) return qstring_from_str(""); } +/** + * qstring_get_length(): Get the length of a QString + */ +size_t qstring_get_length(const QString *qstring) +{ + return qstring->length; +} + /** * qstring_from_substr(): Create a new QString from a C string substring *