Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-11-01 10:26:45 -0500
committerDan McGee <dan@archlinux.org>2011-11-01 10:26:45 -0500
commita4ce3edf95f148bc6eac16b6edd9bc281c7745af (patch)
treeae7dc55d73ae12a3214c14ccaa4d37084a0e37c2 /lib/libalpm/util.c
parentd5f0395dc13fb305e75a5e78de57e148d87f12d7 (diff)
parentd98ff04cc933253b7221fc170813f7d2365d3289 (diff)
Merge branch 'maint'
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r--lib/libalpm/util.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index af9cf42f..a60062bc 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)) {
@@ -172,7 +170,7 @@ int _alpm_copyfile(const char *src, const char *dest)
cleanup:
fclose(in);
fclose(out);
- FREE(buf);
+ free(buf);
return ret;
}
@@ -286,7 +284,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);
@@ -740,8 +738,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;
@@ -749,7 +745,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);
@@ -758,7 +754,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);
}
@@ -784,7 +780,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);
@@ -797,7 +793,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 {