Re: [Libclc-developers] Some of the string functions
Status: Planning
Brought to you by:
augestad
|
From: Hallvard B F. <h.b...@us...> - 2003-03-25 11:30:59
|
Bj=F8rn Augestad writes:
>Hallvard B Furuseth wrote:
>=20
>> char *clc_stpcpy(char *CLC_RESTRICT s1, const char *CLC_RESTRICT s2)
>> {
>> clc_assert_not_null(clc_stpcpy, s1);
>> clc_assert_not_null(clc_stpcpy, s2);
>=20
> A general question: Given the fact that the asserts are for the libclc=20
> *user* only, how about an assert like this one?
>
> clc_assert_arg(clc_stpcpy, s1 !=3D s2);
>
> I just use you code as an example here.
In this case I don't think so, because that condition is incomplete.
The full test is something like !(s1 <=3D s2 && s2 <=3D s1+strlen(s1)), and
I don't like that either because of the slowdown from strlen. Some
people say one should only use the debug version of libclc while testing
code, and in that case assert slowdown may not be important, but there
are people (e.g. FSF, I think) who release code with asserts turned on
so that they can get good error reports from their users.
I've fixed the other asserts like you said.
>> char *clc_stralloc(const char *arg1, ...)
>> {
>> size_t len;
>> const char *arg;
>> char *ret, *end;
>> va_list ap;
>> int bad;
>>=20
>> bad =3D 0;
>> len =3D 1;
>=20
> How about "int bad =3D 0;" on one line instead?
Well, I just wrote it in what I hope will be the libclc style. I like
initializations to be close to the block which uses the values when
possible, which would usually have to be separate statements since there
will usually be asserts between the declarations and the rest of the
code. Doesn't matter since there are no asserts here of course, so I
could have moved the len and bad declarations down and added
initializers. Feel free to do so yourself if you want.
--=20
Hallvard
|