Make sr_session_new() and sr_session_load() require a context.

This commit is contained in:
Martin Ling 2015-03-25 01:41:10 +00:00 committed by Uwe Hermann
parent c72981ac41
commit 61e6e2da45
4 changed files with 11 additions and 6 deletions

View File

@ -888,7 +888,7 @@ Session::Session(shared_ptr<Context> context) :
_context(context), _context(context),
_saving(false) _saving(false)
{ {
check(sr_session_new(&_structure)); check(sr_session_new(context->structure, &_structure));
_context->_session = this; _context->_session = this;
} }

View File

@ -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); SR_API struct sr_trigger *sr_session_trigger_get(struct sr_session *session);
/* Session setup */ /* Session setup */
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,
SR_API int sr_session_new(struct sr_session **session); 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_destroy(struct sr_session *session);
SR_API int sr_session_dev_remove_all(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, SR_API int sr_session_dev_add(struct sr_session *session,

View File

@ -62,6 +62,7 @@ struct datafeed_callback {
/** /**
* Create a new session. * 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 * @param new_session This will contain a pointer to the newly created
* session if the return value is SR_OK, otherwise the value * session if the return value is SR_OK, otherwise the value
* is undefined and should not be used. Must not be NULL. * is undefined and should not be used. Must not be NULL.
@ -71,7 +72,8 @@ struct datafeed_callback {
* *
* @since 0.4.0 * @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; struct sr_session *session;

View File

@ -105,6 +105,7 @@ SR_PRIV int sr_sessionfile_check(const char *filename)
/** /**
* Load the session from the specified 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 filename The name of the session file to load.
* @param session The session to load the file into. * @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_DATA Malformed session file
* @retval SR_ERR This is not a 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; GKeyFile *kf;
GPtrArray *capturefiles; GPtrArray *capturefiles;
@ -151,7 +153,7 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
return SR_ERR; return SR_ERR;
} }
if ((ret = sr_session_new(session)) != SR_OK) if ((ret = sr_session_new(ctx, session)) != SR_OK)
return ret; return ret;
ret = SR_OK; ret = SR_OK;