ftp: store dir components as start+len instead of memdup'ing

- Avoids allocating every path segment separately
- Improved directory handling in connection reuse

Closes #18312
This commit is contained in:
Daniel Stenberg 2025-08-18 14:52:13 +02:00
parent 79eb66f2a6
commit b9e3ea4edb
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 99 additions and 80 deletions

View file

@ -120,6 +120,11 @@ struct FTP {
curl_off_t downloadsize;
};
/* one struct entry for each path component (of 'rawpath') */
struct pathcomp {
int start; /* start column */
int len; /* length in bytes */
};
/* ftp_conn is used for struct connection-oriented data in the connectdata
struct */
@ -128,9 +133,9 @@ struct ftp_conn {
char *account;
char *alternative_to_user;
char *entrypath; /* the PWD reply when we logged on */
char *file; /* url-decoded filename (or path) */
const char *file; /* url-decoded filename (or path), points into rawpath */
char *rawpath; /* URL decoded, allocated, version of the path */
char **dirs; /* realloc()ed array for path components */
struct pathcomp *dirs; /* allocated array for path components */
char *newhost; /* the (allocated) IP addr or hostname to connect the data
connection to */
char *prevpath; /* url-decoded conn->path from the previous transfer */