24 Oct
2008
24 Oct
'08
6:57 p.m.
How would you implement the string copying in drmaa_init()? One would probably use the following code:
int drmaa_init(..., char *err_diag, size_t err_diag_len) { strncpy(err_diag, SRC, err_diag_len) }
I would not use use strncpy because if the string fits into the buffer, I see no reason to zero-fill the remainder of the buffer; if the string doesn't fit, the implementation should not copy an unterminated string into the buffer. Assuming I wasn't doing any form of error checking, I would use int drmaa_init(..., char *err_diag, size_t err_diag_len) { *err_diag = '\0', strncat( err_diag, SRC, err_diag_len ) }