MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / srd_session_new

Function srd_session_new

libsigrokdecode4DSL/session.c:64–88  ·  view source on GitHub ↗

* Create a decoding session. * * A session holds all decoder instances, their stack relationships and * output callbacks. * * @param sess A pointer which will hold a pointer to a newly * initialized session on return. Must not be NULL. * * @return SRD_OK upon success, a (negative) error code otherwise. * * @since 0.3.0 */

Source from the content-addressed store, hash-verified

62 * @since 0.3.0
63 */
64SRD_API int srd_session_new(struct srd_session **sess)
65{
66 struct srd_session *se = NULL;
67
68 if (!sess)
69 return SRD_ERR_ARG;
70
71 se = malloc(sizeof(struct srd_session));
72 if (se == NULL){
73 srd_err("%s,ERROR:failed to alloc memory.", __func__);
74 return SRD_ERR;
75 }
76 memset(se, 0, sizeof(struct srd_session));
77
78 se->session_id = ++max_session_id;
79
80 /* Keep a list of all sessions, so we can clean up as needed. */
81 sessions = g_slist_append(sessions, se);
82
83 *sess = se;
84
85 //srd_info("Creating session %d.", (*sess)->session_id);
86
87 return SRD_OK;
88}
89
90/**
91 * Start a decoding session.

Callers 1

execute_decode_stackMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected