diff options
| author | Daniel Stenberg <daniel@haxx.se> | 2004-12-17 10:09:32 +0000 | 
|---|---|---|
| committer | Daniel Stenberg <daniel@haxx.se> | 2004-12-17 10:09:32 +0000 | 
| commit | e3d342df961050ea8b2c20fe9213f3f645360708 (patch) | |
| tree | d66a717279db7f1b52c848bee31e0f1bcee8b989 | |
| parent | ff54a74b4d3398bf32c4f0f64c0f76852918080c (diff) | |
avoid an extra malloc
| -rw-r--r-- | lib/ftp.c | 17 | 
1 files changed, 7 insertions, 10 deletions
@@ -778,19 +778,16 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status)    flen = ftp->file?strlen(ftp->file):0; /* file is "raw" already */    dlen = strlen(path)-flen;    if(dlen) { -    ftp->prevpath = malloc(dlen + 1); -    if(!ftp->prevpath) { -      free(path); -      return CURLE_OUT_OF_MEMORY; -    } -    memcpy(ftp->prevpath, path, dlen); -    ftp->prevpath[dlen]=0; /* terminate */ +    ftp->prevpath = path; +    if(flen) +      /* if 'path' is not the whole string */ +      ftp->prevpath[dlen]=0; /* terminate */      infof(data, "Remembering we are in dir %s\n", ftp->prevpath);    } -  else +  else {      ftp->prevpath = NULL; /* no path */ -  free(path); - +    free(path); +  }    /* free the dir tree and file parts */    freedirs(ftp);  | 
