diff options
| author | Ryo Nakamura <upa@haeena.net> | 2024-01-11 21:23:33 +0900 |
|---|---|---|
| committer | Ryo Nakamura <upa@haeena.net> | 2024-01-18 12:59:49 +0900 |
| commit | bba53fab03d49e1330ca1292ed18e84bd5f5b1ef (patch) | |
| tree | 0e234c4dbf3452cef4ba84c5b0659d33172c67ce /src/path.h | |
| parent | 5cbf3ad6480adb6615a9a80b59d4a9d1ade62431 (diff) | |
don't allocate char[PATH_MAX] for each file
This commit makes struct path allocation use strndup().
It reduices the memory footprint for struct path per file (issue #8).
Diffstat (limited to 'src/path.h')
| -rw-r--r-- | src/path.h | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -14,11 +14,11 @@ struct path { struct list_head list; /* mscp->path_list */ - char path[PATH_MAX]; /* file path */ - size_t size; /* size of file on this path */ - mode_t mode; /* permission */ + char *path; /* file path */ + size_t size; /* size of file on this path */ + mode_t mode; /* permission */ - char dst_path[PATH_MAX]; /* copy dst path */ + char *dst_path; /* copy dst path */ int state; lock lock; @@ -93,6 +93,9 @@ struct path_resolve_args { int walk_src_path(sftp_session src_sftp, const char *src_path, struct list_head *path_list, struct path_resolve_args *a); +/* free struct path */ +void free_path(struct path *p); + /* copy a chunk. either src_sftp or dst_sftp is not null, and another is null */ int copy_chunk(FILE *msg_fp, struct chunk *c, sftp_session src_sftp, sftp_session dst_sftp, |
