Klauck, Stefan
2012-05-14 17:45:34 UTC
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
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