Discussion:
[DRMAA-WG] DRMAAv2 C binding - Final Draft: Should interface type names get a special ending?
Klauck, Stefan
2012-05-14 17:45:34 UTC
Permalink
Dear all,

there is another issue I would like to discuss.



(Regarding memory management) There are two kind of functions:

- One the one hand, some functions return drmaa structures with according drmaa2_*_free functions for the returned pointer. The application has to manage/free these structures.
Examples:
drmaa2_jinfo drmaa2_j_get_info (const drmaa2_j j);
drmaa2_jtemplate drmaa2_j_get_jt (const drmaa2_j j);


- One the other hand, there are functions returning drmaa interface types (JobSession, ReservationSession, MonitoringSession, Job, JobArray and Reservation).
Examples:
drmaa2_jsession drmaa2_create_jsession (const char * session_name, const char * contact);
drmaa2_j drmaa2_j_wait_terminated (const drmaa2_j j, const time_t timeout);

The interface types have according typedef declarations in the header file:

typedef struct drmaa2_jsession_s * drmaa2_jsession;
typedef struct drmaa2_rsession_s * drmaa2_rsession;
typedef struct drmaa2_msession_s * drmaa2_msession;
typedef struct drmaa2_j_s * drmaa2_j;
typedef struct drmaa2_jarray_s * drmaa2_jarray;
typedef struct drmaa2_r_s * drmaa2_r;

The according structures are managed by drmaa implementations.

The issue to discuss:
Should interface type names therefore get a special ending like '_h' (standing for handle)?

Example
typedef struct drmaa2_jsession_s * drmaa2_jsession_h;

-> Application:
drmaa2_jsession_h js = drmaa2_create_jsession("my_session", NULL);
// "I see that it's an handle and thus I do not need to free it"


Best regards
Stefan Klauck
Daniel Gruber
2012-05-15 06:02:09 UTC
Permalink
sounds resaonable

Daniel
Post by Klauck, Stefan
Dear all,
there is another issue I would like to discuss.
- One the one hand, some functions return drmaa structures with according drmaa2_*_free functions for the returned pointer. The application has to manage/free these structures.
drmaa2_jinfo drmaa2_j_get_info (const drmaa2_j j);
drmaa2_jtemplate drmaa2_j_get_jt (const drmaa2_j j);
- One the other hand, there are functions returning drmaa interface types (JobSession, ReservationSession, MonitoringSession, Job, JobArray and Reservation).
drmaa2_jsession drmaa2_create_jsession (const char * session_name, const char * contact);
drmaa2_j drmaa2_j_wait_terminated (const drmaa2_j j, const time_t timeout);
typedef struct drmaa2_jsession_s * drmaa2_jsession;
typedef struct drmaa2_rsession_s * drmaa2_rsession;
typedef struct drmaa2_msession_s * drmaa2_msession;
typedef struct drmaa2_j_s * drmaa2_j;
typedef struct drmaa2_jarray_s * drmaa2_jarray;
typedef struct drmaa2_r_s * drmaa2_r;
The according structures are managed by drmaa implementations.
Should interface type names therefore get a special ending like '_h' (standing for handle)?
Example
typedef struct drmaa2_jsession_s * drmaa2_jsession_h;
drmaa2_jsession_h js = drmaa2_create_jsession("my_session", NULL);
// "I see that it's an handle and thus I do not need to free it"
Best regards
Stefan Klauck
--
drmaa-wg mailing list
drmaa-wg at ogf.org
https://www.ogf.org/mailman/listinfo/drmaa-wg
Loading...