index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-10-27 14:59:24 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-10-27 14:59:24 -0500 |
commit | 3343185473c79d556b29bda30c9c482c7fef5289 (patch) | |
tree | aedd3febc30983236bde017ac7a610bf7ede5516 /lib/libalpm/util.c | |
parent | 1052709921da50ec5203efaa313dbda75625a4e1 (diff) |
-rw-r--r-- | lib/libalpm/util.c | 20 |
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index beefa936..12286c6a 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -129,8 +129,6 @@ int _alpm_makepath_mode(const char *path, mode_t mode) return ret; } -#define CPBUFSIZE 8 * 1024 - int _alpm_copyfile(const char *src, const char *dest) { FILE *in, *out; @@ -148,10 +146,10 @@ int _alpm_copyfile(const char *src, const char *dest) return 1; } - CALLOC(buf, (size_t)CPBUFSIZE, (size_t)1, ret = 1; goto cleanup;); + MALLOC(buf, (size_t)ALPM_BUFFER_SIZE, ret = 1; goto cleanup); /* do the actual file copy */ - while((len = fread(buf, 1, CPBUFSIZE, in))) { + while((len = fread(buf, 1, ALPM_BUFFER_SIZE, in))) { size_t nwritten = 0; nwritten = fwrite(buf, 1, len, out); if((nwritten != len) || ferror(out)) { @@ -174,7 +172,7 @@ int _alpm_copyfile(const char *src, const char *dest) cleanup: fclose(in); fclose(out); - FREE(buf); + free(buf); return ret; } @@ -288,7 +286,7 @@ int _alpm_unpack(alpm_handle_t *handle, const char *archive, const char *prefix, archive_read_support_format_all(_archive); if(archive_read_open_filename(_archive, archive, - ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) { + ALPM_BUFFER_SIZE) != ARCHIVE_OK) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"), archive, archive_error_string(_archive)); RET_ERR(handle, ALPM_ERR_PKG_OPEN, 1); @@ -741,8 +739,6 @@ int _alpm_lstat(const char *path, struct stat *buf) } #ifdef HAVE_LIBSSL -#define BUFFER_SIZE 8192 - static int md5_file(const char *path, unsigned char output[16]) { FILE *f; @@ -750,7 +746,7 @@ static int md5_file(const char *path, unsigned char output[16]) MD5_CTX ctx; unsigned char *buf; - CALLOC(buf, BUFFER_SIZE, sizeof(unsigned char), return 1); + CALLOC(buf, ALPM_BUFFER_SIZE, sizeof(unsigned char), return 1); if((f = fopen(path, "rb")) == NULL) { free(buf); @@ -759,7 +755,7 @@ static int md5_file(const char *path, unsigned char output[16]) MD5_Init(&ctx); - while((n = fread(buf, 1, BUFFER_SIZE, f)) > 0) { + while((n = fread(buf, 1, ALPM_BUFFER_SIZE, f)) > 0) { MD5_Update(&ctx, buf, n); } @@ -785,7 +781,7 @@ static int sha2_file(const char *path, unsigned char output[32], int is224) SHA256_CTX ctx; unsigned char *buf; - CALLOC(buf, BUFFER_SIZE, sizeof(unsigned char), return 1); + CALLOC(buf, ALPM_BUFFER_SIZE, sizeof(unsigned char), return 1); if((f = fopen(path, "rb")) == NULL) { free(buf); @@ -798,7 +794,7 @@ static int sha2_file(const char *path, unsigned char output[32], int is224) SHA256_Init(&ctx); } - while((n = fread(buf, 1, BUFFER_SIZE, f)) > 0) { + while((n = fread(buf, 1, ALPM_BUFFER_SIZE, f)) > 0) { if(is224) { SHA224_Update(&ctx, buf, n); } else { |