# HG changeset patch # User Timo Sirainen # Date 1030510463 -10800 # Node ID 83ae914a583a928881137e497975321c508665cc # Parent 8740373ee20e3ca0a34c7295c7282d20b84f4285 added t_strdup_noconst() which can be used instead of (char *) t_strdup(). Removed several castings that removed the const qualifier. diff -r 8740373ee20e -r 83ae914a583a src/auth/auth-digest-md5.c --- a/src/auth/auth-digest-md5.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/auth/auth-digest-md5.c Wed Aug 28 07:54:23 2002 +0300 @@ -465,7 +465,7 @@ failed = FALSE; - copy = (char *) t_strndup(data, size); + copy = t_strdup_noconst(t_strndup(data, size)); while (*copy != '\0') { if (parse_next(©, &key, &value)) { if (!auth_handle_response(auth, key, value, error)) { diff -r 8740373ee20e -r 83ae914a583a src/auth/cookie.c --- a/src/auth/cookie.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/auth/cookie.c Wed Aug 28 07:54:23 2002 +0300 @@ -48,7 +48,8 @@ int i, ret; for (i = 0; i < AUTH_COOKIE_SIZE; i++) { - ret = ((unsigned char *) p1)[i] - ((unsigned char *) p2)[i]; + ret = ((const unsigned char *) p1)[i] - + ((const unsigned char *) p2)[i]; if (ret != 0) return ret; } diff -r 8740373ee20e -r 83ae914a583a src/auth/userinfo-passwd.c --- a/src/auth/userinfo-passwd.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/auth/userinfo-passwd.c Wed Aug 28 07:54:23 2002 +0300 @@ -42,7 +42,7 @@ return FALSE; /* check if the password is valid */ - passdup = (char *) t_strdup(password); + passdup = t_strdup_noconst(password); result = strcmp(crypt(passdup, pw->pw_passwd), pw->pw_passwd) == 0; /* clear the passwords from memory */ diff -r 8740373ee20e -r 83ae914a583a src/auth/userinfo-shadow.c --- a/src/auth/userinfo-shadow.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/auth/userinfo-shadow.c Wed Aug 28 07:54:23 2002 +0300 @@ -32,7 +32,7 @@ return FALSE; /* check if the password is valid */ - passdup = (char *) t_strdup(password); + passdup = t_strdup_noconst(password); result = strcmp(crypt(passdup, spw->sp_pwdp), spw->sp_pwdp) == 0; /* clear the passwords from memory */ diff -r 8740373ee20e -r 83ae914a583a src/imap/cmd-fetch.c --- a/src/imap/cmd-fetch.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/imap/cmd-fetch.c Wed Aug 28 07:54:23 2002 +0300 @@ -35,7 +35,7 @@ body = t_new(MailFetchBodyData, 1); body->peek = peek; - p = (char *) t_strdup(item); + p = t_strdup_noconst(item); /* read section */ body->section = p; diff -r 8740373ee20e -r 83ae914a583a src/imap/commands.c --- a/src/imap/commands.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/imap/commands.c Wed Aug 28 07:54:23 2002 +0300 @@ -6,7 +6,7 @@ ClientCommandFunc client_command_find(const char *name) { /* keep the command uppercased */ - name = str_ucase((char *) t_strdup(name)); + name = str_ucase(t_strdup_noconst(name)); switch (*name) { case 'A': diff -r 8740373ee20e -r 83ae914a583a src/lib/network.c --- a/src/lib/network.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/lib/network.c Wed Aug 28 07:54:23 2002 +0300 @@ -369,7 +369,7 @@ i_assert(data != NULL); i_assert(len <= INT_MAX); - ret = send(fd, (void *) data, len, 0); + ret = send(fd, data, len, 0); if (ret == -1 && (errno == EINTR || errno == EPIPE || errno == EAGAIN)) return 0; diff -r 8740373ee20e -r 83ae914a583a src/lib/strfuncs.c --- a/src/lib/strfuncs.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/lib/strfuncs.c Wed Aug 28 07:54:23 2002 +0300 @@ -510,6 +510,14 @@ STRDUP_CORE(t_malloc(len), str); } +char *t_strdup_noconst(const char *str) +{ + if (str == NULL) + return NULL; + + STRDUP_CORE(t_malloc(len), str); +} + int *p_intarrdup(Pool pool, const int *arr) { if (arr == NULL) @@ -847,7 +855,7 @@ char *const *t_strsplit(const char *data, const char *separators) { - const char **array; + char **array; char *str; int alloc_len, len; diff -r 8740373ee20e -r 83ae914a583a src/lib/strfuncs.h --- a/src/lib/strfuncs.h Wed Aug 28 07:43:06 2002 +0300 +++ b/src/lib/strfuncs.h Wed Aug 28 07:54:23 2002 +0300 @@ -31,6 +31,7 @@ /* same with temporary memory allocations: */ const char *t_strdup(const char *str); +char *t_strdup_noconst(const char *str); const char *t_strdup_empty(const char *str); /* return NULL if str = "" */ const char *t_strdup_until(const char *start, const char *end); /* *end isn't included */ const char *t_strndup(const char *str, unsigned int max_chars); diff -r 8740373ee20e -r 83ae914a583a src/login/client-authenticate.c --- a/src/login/client-authenticate.c Wed Aug 28 07:43:06 2002 +0300 +++ b/src/login/client-authenticate.c Wed Aug 28 07:54:23 2002 +0300 @@ -144,7 +144,7 @@ reply_data[reply_data_size-1] == '\0') { client_auth_abort(client, t_strconcat( "NO Authentication failed: ", - (char *) reply_data, NULL)); + (const char *) reply_data, NULL)); } else { /* default error message */ client_auth_abort(client, NULL);