From: Martin Ling Date: Wed, 25 Mar 2015 01:41:10 +0000 (+0000) Subject: Make sr_session_new() and sr_session_load() require a context. X-Git-Tag: libsigrok-0.4.0~559 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=61e6e2da45373acea5dab93a6ede57aae9901b1b;p=libsigrok.git Make sr_session_new() and sr_session_load() require a context. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index c0827905..c88dc566 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -888,7 +888,7 @@ Session::Session(shared_ptr context) : _context(context), _saving(false) { - check(sr_session_new(&_structure)); + check(sr_session_new(context->structure, &_structure)); _context->_session = this; } diff --git a/include/libsigrok/proto.h b/include/libsigrok/proto.h index c2c09437..2bd25069 100644 --- a/include/libsigrok/proto.h +++ b/include/libsigrok/proto.h @@ -105,8 +105,9 @@ typedef void (*sr_datafeed_callback)(const struct sr_dev_inst *sdi, SR_API struct sr_trigger *sr_session_trigger_get(struct sr_session *session); /* Session setup */ -SR_API int sr_session_load(const char *filename, struct sr_session **session); -SR_API int sr_session_new(struct sr_session **session); +SR_API int sr_session_load(struct sr_context *ctx, const char *filename, + struct sr_session **session); +SR_API int sr_session_new(struct sr_context *ctx, struct sr_session **session); SR_API int sr_session_destroy(struct sr_session *session); SR_API int sr_session_dev_remove_all(struct sr_session *session); SR_API int sr_session_dev_add(struct sr_session *session, diff --git a/src/session.c b/src/session.c index 765a20c4..736b2aa5 100644 --- a/src/session.c +++ b/src/session.c @@ -62,6 +62,7 @@ struct datafeed_callback { /** * Create a new session. * + * @param ctx The context in which to create the new session. * @param new_session This will contain a pointer to the newly created * session if the return value is SR_OK, otherwise the value * is undefined and should not be used. Must not be NULL. @@ -71,7 +72,8 @@ struct datafeed_callback { * * @since 0.4.0 */ -SR_API int sr_session_new(struct sr_session **new_session) +SR_API int sr_session_new(struct sr_context *ctx, + struct sr_session **new_session) { struct sr_session *session; diff --git a/src/session_file.c b/src/session_file.c index 91d4d777..9a1e316e 100644 --- a/src/session_file.c +++ b/src/session_file.c @@ -105,6 +105,7 @@ SR_PRIV int sr_sessionfile_check(const char *filename) /** * Load the session from the specified filename. * + * @param ctx The context in which to load the session. * @param filename The name of the session file to load. * @param session The session to load the file into. * @@ -113,7 +114,8 @@ SR_PRIV int sr_sessionfile_check(const char *filename) * @retval SR_ERR_DATA Malformed session file * @retval SR_ERR This is not a session file */ -SR_API int sr_session_load(const char *filename, struct sr_session **session) +SR_API int sr_session_load(struct sr_context *ctx, const char *filename, + struct sr_session **session) { GKeyFile *kf; GPtrArray *capturefiles; @@ -151,7 +153,7 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session) return SR_ERR; } - if ((ret = sr_session_new(session)) != SR_OK) + if ((ret = sr_session_new(ctx, session)) != SR_OK) return ret; ret = SR_OK;