diff options
Diffstat (limited to 'src/diskio.c')
-rw-r--r-- | src/diskio.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/diskio.c b/src/diskio.c index 9addd9b..b175a45 100644 --- a/src/diskio.c +++ b/src/diskio.c | |||
@@ -37,25 +37,25 @@ sub_dir_p (const char *arg, const char *dir) | |||
37 | slash. */ | 37 | slash. */ |
38 | char * | 38 | char * |
39 | concat_dir (const char *base, const char *name, size_t *pbaselen) | 39 | concat_dir (const char *base, const char *name, size_t *pbaselen) |
40 | { | 40 | { |
41 | size_t len = strlen (base); | 41 | size_t len = strlen (base); |
42 | size_t size; | 42 | size_t size; |
43 | char *dir; | 43 | char *dir; |
44 | 44 | ||
45 | while (len > 0 && base[len-1] == '/') | 45 | while (len > 0 && base[len-1] == '/') |
46 | len--; | 46 | len--; |
47 | 47 | ||
48 | size = len + 1 + strlen (name); | 48 | size = len + 1 + strlen (name); |
49 | dir = xmalloc (size + 1); | 49 | dir = grecs_malloc (size + 1); |
50 | memcpy (dir, base, len); | 50 | memcpy (dir, base, len); |
51 | dir[len++] = '/'; | 51 | dir[len++] = '/'; |
52 | strcpy (dir + len, name); | 52 | strcpy (dir + len, name); |
53 | 53 | ||
54 | if (pbaselen) | 54 | if (pbaselen) |
55 | *pbaselen = len; | 55 | *pbaselen = len; |
56 | return dir; | 56 | return dir; |
57 | } | 57 | } |
58 | 58 | ||
59 | /* Create the directory DIR, eventually creating all intermediate directories | 59 | /* Create the directory DIR, eventually creating all intermediate directories |
60 | starting from DIR + BASELEN. */ | 60 | starting from DIR + BASELEN. */ |
61 | int | 61 | int |
@@ -162,25 +162,25 @@ copy_file (const char *file, const char *dst_file) | |||
162 | file, strerror (errno)); | 162 | file, strerror (errno)); |
163 | close (in_fd); | 163 | close (in_fd); |
164 | return 1; | 164 | return 1; |
165 | } | 165 | } |
166 | 166 | ||
167 | buf = NULL; | 167 | buf = NULL; |
168 | fsize = st.st_size; | 168 | fsize = st.st_size; |
169 | 169 | ||
170 | for (bufsize = fsize; bufsize > 0 && (buf = malloc (bufsize)) == NULL; | 170 | for (bufsize = fsize; bufsize > 0 && (buf = malloc (bufsize)) == NULL; |
171 | bufsize /= 2) | 171 | bufsize /= 2) |
172 | ; | 172 | ; |
173 | if (bufsize == 0) | 173 | if (bufsize == 0) |
174 | xalloc_die (); | 174 | grecs_alloc_die (); |
175 | 175 | ||
176 | rc = 0; | 176 | rc = 0; |
177 | while (fsize > 0) | 177 | while (fsize > 0) |
178 | { | 178 | { |
179 | size_t rest; | 179 | size_t rest; |
180 | size_t rdbytes; | 180 | size_t rdbytes; |
181 | 181 | ||
182 | rest = fsize > bufsize ? bufsize : fsize; | 182 | rest = fsize > bufsize ? bufsize : fsize; |
183 | rdbytes = read (in_fd, buf, rest); | 183 | rdbytes = read (in_fd, buf, rest); |
184 | if (rdbytes == -1) | 184 | if (rdbytes == -1) |
185 | { | 185 | { |
186 | logmsg (LOG_ERR, _("unexpected error reading %s: %s"), | 186 | logmsg (LOG_ERR, _("unexpected error reading %s: %s"), |
@@ -483,25 +483,25 @@ archive_single_file (struct file_triplet *trp, const char *file_name, | |||
483 | free (dst_dir); | 483 | free (dst_dir); |
484 | return rc; | 484 | return rc; |
485 | } | 485 | } |
486 | 486 | ||
487 | static char * | 487 | static char * |
488 | make_signame (const char *file_name) | 488 | make_signame (const char *file_name) |
489 | { | 489 | { |
490 | size_t len; | 490 | size_t len; |
491 | 491 | ||
492 | if (((len = strlen (file_name)) > SUF_SIG_LEN | 492 | if (((len = strlen (file_name)) > SUF_SIG_LEN |
493 | && memcmp (file_name + len - SUF_SIG_LEN, SUF_SIG, SUF_SIG_LEN))) | 493 | && memcmp (file_name + len - SUF_SIG_LEN, SUF_SIG, SUF_SIG_LEN))) |
494 | { | 494 | { |
495 | char *signame = xmalloc (len + SUF_SIG_LEN + 1); | 495 | char *signame = grecs_malloc (len + SUF_SIG_LEN + 1); |
496 | strcpy (signame, file_name); | 496 | strcpy (signame, file_name); |
497 | return strcat (signame, SUF_SIG); | 497 | return strcat (signame, SUF_SIG); |
498 | } | 498 | } |
499 | return NULL; | 499 | return NULL; |
500 | } | 500 | } |
501 | 501 | ||
502 | /* Archive the file FILE_NAME, located in DPAIR->dest_dir, and remove the | 502 | /* Archive the file FILE_NAME, located in DPAIR->dest_dir, and remove the |
503 | file. Get user IDs from the triplet TRP. Unless FILE_NAME ends in | 503 | file. Get user IDs from the triplet TRP. Unless FILE_NAME ends in |
504 | ".sig", do the same with FILE_NAME.sig, if such a file exists. | 504 | ".sig", do the same with FILE_NAME.sig, if such a file exists. |
505 | Do nothing if dry_run_mode is set. | 505 | Do nothing if dry_run_mode is set. |
506 | */ | 506 | */ |
507 | int | 507 | int |