Replace uses of strdup with xstrdup.

Like xmalloc and xrealloc xstrdup dies with a useful message if
the native strdup() implementation returns NULL rather than a
valid pointer.

I just tried to use xstrdup in new code and found it to be missing.
However I expected it to be present as xmalloc and xrealloc are
already commonly used throughout the code.

[jc: removed the part that deals with last_XXX, which I am
 finding more and more dubious these days.]

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Shawn Pearce
2006-09-02 00:16:31 -04:00
committed by Junio C Hamano
parent ad1ed5ee89
commit 9befac470b
34 changed files with 84 additions and 76 deletions

View File

@ -1032,7 +1032,7 @@ imap_open_store( imap_server_conf_t *srvc )
* getpass() returns a pointer to a static buffer. make a copy
* for long term storage.
*/
srvc->pass = strdup( arg );
srvc->pass = xstrdup( arg );
}
if (CAP(NOLOGIN)) {
fprintf( stderr, "Skipping account %s@%s, server forbids LOGIN\n", srvc->user, srvc->host );
@ -1288,7 +1288,7 @@ git_imap_config(const char *key, const char *val)
key += sizeof imap_key - 1;
if (!strcmp( "folder", key )) {
imap_folder = strdup( val );
imap_folder = xstrdup( val );
} else if (!strcmp( "host", key )) {
{
if (!strncmp( "imap:", val, 5 ))
@ -1298,16 +1298,16 @@ git_imap_config(const char *key, const char *val)
}
if (!strncmp( "//", val, 2 ))
val += 2;
server.host = strdup( val );
server.host = xstrdup( val );
}
else if (!strcmp( "user", key ))
server.user = strdup( val );
server.user = xstrdup( val );
else if (!strcmp( "pass", key ))
server.pass = strdup( val );
server.pass = xstrdup( val );
else if (!strcmp( "port", key ))
server.port = git_config_int( key, val );
else if (!strcmp( "tunnel", key ))
server.tunnel = strdup( val );
server.tunnel = xstrdup( val );
return 0;
}