cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: curl-7.10.1: segmentation fault following new URL

From: jonatan <jonatan_at_wineasy.se>
Date: Mon, 28 Oct 2002 19:18:03 +0100

I believe the following would be better since the length is calculated
at compile-time as opposed to run-time. This is more efficient.

#define strlen2(s) (sizeof((s))-1)
#define strnequal2(s1, s2) strnequal((s1),(s2),strlen2((s1)))

For the same reason strlen2() (or whatever it's called) should also
replace strlen() when the string is fixed.

> P.S. Is something like
>
> #define strnequal2(s1, s2) strnequal((s1),(s2),strlen(s1))
>
> portable enough (and worth the hassle to change it) ?
> If it was used instead of strnequal(), it could save some of the
> developers' work (and frustration), since they wouldn't have to count
> characters (not to mention the possible errors). It seems to be used
> in a lot of source lines.
>
> $ grep 'strnequal("' */*.c # select lines with a constant first
> argument
> lib/cookie.c: if(strnequal("Set-Cookie:", line, 11)) {
> lib/formdata.c: !strnequal("text/", file->contenttype, 5)) {
> lib/transfer.c: if (strnequal("Content-Length:", k->p, 15) &&
> lib/transfer.c: else if (strnequal("Content-Type:", k->p,
> 13)) {
> lib/transfer.c: else if (strnequal("Content-Encoding:", k->p,
> 17) &&
> lib/transfer.c: if (strnequal("identity", start, 8))
> lib/transfer.c: else if (strnequal("deflate", start, 7))
> lib/transfer.c: else if (strnequal("gzip", start, 4)
> lib/transfer.c: || strnequal("x-gzip", start, 6))
> lib/transfer.c: else if (strnequal("compress", start, 8)
> lib/transfer.c: || strnequal("x-compress", start,
> 10))
> lib/transfer.c: else if (strnequal("Content-Range:", k->p,
> 14)) {
> lib/transfer.c: strnequal("Set-Cookie:", k->p, 11)) {
> lib/transfer.c: else if(strnequal("Last-Modified:", k->p,
> lib/transfer.c: strnequal("Location:", k->p, 9)) {
> src/main.c: if(curl_strnequal("type=", ptr, 5)) {
> src/main.c: else if(curl_strnequal("filename=", ptr, 9)) {
> src/main.c: (!strnequal("--", argv[1], 2) && (argv[1][0] == '-'))
> &&

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2002-10-28