ansi
February 17th, 2007, 10:17 AM
Hello,
I wrote some own functions (C) which operates with strings, they looks like Std. functions:
_bool mystr_ncpy(myStr* dst, char* src, size_t src_len)
{
.....
}
And I want define the same function's which gives only src && dst as arguments. What version is better:
#define mystr_cpy(dst, src) mystr_cpy(dst, src, strlen(src))
or this:
_bool mystr_cpy(myStr* dst, char* src)
{
return mystr_ncpy(dst, src, strlen(src));
}
Of course, I understand that the version with #define will be processed with pre-processor on compilation study, but second version will spend processor's time on creating new stack (I think). 1st version looks more elegant, but it will be hard-understandable in headers for other developers.
It is in more part a design question I think.
Thanks.
I wrote some own functions (C) which operates with strings, they looks like Std. functions:
_bool mystr_ncpy(myStr* dst, char* src, size_t src_len)
{
.....
}
And I want define the same function's which gives only src && dst as arguments. What version is better:
#define mystr_cpy(dst, src) mystr_cpy(dst, src, strlen(src))
or this:
_bool mystr_cpy(myStr* dst, char* src)
{
return mystr_ncpy(dst, src, strlen(src));
}
Of course, I understand that the version with #define will be processed with pre-processor on compilation study, but second version will spend processor's time on creating new stack (I think). 1st version looks more elegant, but it will be hard-understandable in headers for other developers.
It is in more part a design question I think.
Thanks.