Bug 568 - Many functions should take a context pointer and don't.
Summary: Many functions should take a context pointer and don't.
Status: CONFIRMED
Alias: None
Product: libsigrok
Classification: Unclassified
Component: API (show other bugs)
Version: unreleased development snapshot
Hardware: All All
: Normal normal
Target Milestone: ---
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-25 22:01 CET by Martin Ling
Modified: 2015-09-10 14:17 CEST (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Ling 2015-03-25 22:01:06 CET
There are lots of functions in the API which should take a context pointer, if there is to be any point in having a non-global libsigrok context. I think these include:

sr_log_loglevel_{get,set}()
sr_log_callback_{get,set,set_default}()
sr_log_logdomain_{get,set}()
sr_driver_list()
sr_session_load()
sr_session_new()
sr_input_list()
sr_input_find()
sr_output_list()
sr_output_find()
sr_transform_list()
sr_transform_find()

This should turn out to be in line with which functions are wrapped as methods on the Context class in the C++ bindings.
Comment 1 Daniel Elstner 2015-09-10 14:12:00 CEST
In the current code base, the functions sr_driver_list(), sr_session_load() and sr_session_new() already take an sr_context.
Comment 2 Daniel Elstner 2015-09-10 14:17:20 CEST
Wrt the sr_log_*() functions from your list, I don't think it's worth the effort. One would have to convert all calls to sr_err(), sr_warn(), sr_info(), etc. to take a context argument, which would be really painful.

I'm not aware of any other library which does something like this for its logging functions.