diff --git a/context.c b/context.c index 601ef2a93..a129ce821 100644 --- a/context.c +++ b/context.c @@ -181,7 +181,7 @@ static ssize_t iio_snprintf_context_xml(char *ptr, ssize_t len, } /* Returns a string containing the XML representation of this context */ -static char * iio_context_create_xml(const struct iio_context *ctx) +char * iio_context_get_xml(const struct iio_context *ctx) { ssize_t len; char *str; @@ -251,11 +251,6 @@ void iio_context_set_pdata(struct iio_context *ctx, struct iio_context_pdata *d) ctx->pdata = d; } -const char * iio_context_get_xml(const struct iio_context *ctx) -{ - return ctx->xml; -} - const char * iio_context_get_name(const struct iio_context *ctx) { return ctx->name; @@ -284,7 +279,6 @@ void iio_context_destroy(struct iio_context *ctx) for (i = 0; i < ctx->nb_devices; i++) free_device(ctx->devices[i]); free(ctx->devices); - free(ctx->xml); free(ctx->description); free(ctx->git_tag); free(ctx->pdata); @@ -340,12 +334,7 @@ int iio_context_init(struct iio_context *ctx) for (i = 0; i < ctx->nb_devices; i++) reorder_channels(ctx->devices[i]); - if (ctx->xml) - return 0; - - ctx->xml = iio_context_create_xml(ctx); - - return iio_err(ctx->xml); + return 0; } unsigned int iio_context_get_version_major(const struct iio_context *ctx) diff --git a/iio-private.h b/iio-private.h index 575b5ac73..f6c3a1c00 100644 --- a/iio-private.h +++ b/iio-private.h @@ -92,8 +92,6 @@ struct iio_context { struct iio_device **devices; unsigned int nb_devices; - char *xml; - char **values; struct iio_attr_list attrlist; diff --git a/include/iio/iio.h b/include/iio/iio.h index 708f71e49..6a353230e 100644 --- a/include/iio/iio.h +++ b/include/iio/iio.h @@ -601,8 +601,9 @@ __api __pure const char * iio_context_get_version_tag(const struct iio_context * /** @brief Obtain a XML representation of the given context * @param ctx A pointer to an iio_context structure - * @return A pointer to a static NULL-terminated string */ -__api __check_ret __pure const char * iio_context_get_xml(const struct iio_context *ctx); + * @return On success, an allocated string. Must be deallocated with free(). + * @return On failure, a pointer-encoded error is returned */ +__api __check_ret char * iio_context_get_xml(const struct iio_context *ctx); /** @brief Get the name of the given context