[pacman-dev] [PATCH] Rename alpm_get_md5sum to alpm_compute_md5sum and alpm_dep_get_string to alpm_dep_compute_string

Nagy Gabor ngaba at bibl.u-szeged.hu
Tue Aug 26 07:12:19 EDT 2008


From aa4384123d2ca6068945f5f9574764dc5f334e67 Mon Sep 17 00:00:00 2001
From: Nagy Gabor <ngaba at bibl.u-szeged.hu>
Date: Tue, 26 Aug 2008 12:57:08 +0200
Subject: [PATCH] Rename alpm_get_md5sum to alpm_compute_md5sum and alpm_dep_get_string to alpm_dep_compute_string

This patch introduces the following function name convention:
_compute_ in function name: the return value must be freed.
_get_ in function name: the return value must not be freed.

Signed-off-by: Nagy Gabor <ngaba at bibl.u-szeged.hu>
---
 lib/libalpm/add.c      |    6 +++---
 lib/libalpm/alpm.h     |    4 ++--
 lib/libalpm/be_files.c |    2 +-
 lib/libalpm/delta.c    |    4 ++--
 lib/libalpm/deps.c     |    8 ++++----
 lib/libalpm/util.c     |    4 ++--
 src/pacman/package.c   |    4 ++--
 src/pacman/remove.c    |    2 +-
 src/pacman/sync.c      |    2 +-
 src/pacman/upgrade.c   |    2 +-
 src/util/testdb.c      |    2 +-
 11 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 5040589..5098bfe 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -456,8 +456,8 @@ static int extract_single_file(struct archive *archive,
 			return(1);
 		}
 
-		hash_local = alpm_get_md5sum(filename);
-		hash_pkg = alpm_get_md5sum(checkfile);
+		hash_local = alpm_compute_md5sum(filename);
+		hash_pkg = alpm_compute_md5sum(checkfile);
 
 		/* append the new md5 hash to it's respective entry
 		 * in newpkg's backup (it will be the new orginal) */
@@ -618,7 +618,7 @@ static int extract_single_file(struct archive *archive,
 			}
 			_alpm_log(PM_LOG_DEBUG, "appending backup entry for %s\n", filename);
 
-			hash = alpm_get_md5sum(filename);
+			hash = alpm_compute_md5sum(filename);
 			MALLOC(backup, backup_len, RET_ERR(PM_ERR_MEMORY, -1));
 
 			sprintf(backup, "%s\t%s", oldbackup, hash);
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 168b28b..d5e543f 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -437,7 +437,7 @@ const char *alpm_conflict_get_package2(pmconflict_t *conflict);
 pmdepmod_t alpm_dep_get_mod(const pmdepend_t *dep);
 const char *alpm_dep_get_name(const pmdepend_t *dep);
 const char *alpm_dep_get_version(const pmdepend_t *dep);
-char *alpm_dep_get_string(const pmdepend_t *dep);
+char *alpm_dep_compute_string(const pmdepend_t *dep);
 
 /*
  * File conflicts
@@ -458,7 +458,7 @@ const char *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict);
  */
 
 /* checksums */
-char *alpm_get_md5sum(const char *name);
+char *alpm_compute_md5sum(const char *name);
 
 /*
  * Errors
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index f5d4e82..f895bc4 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -805,7 +805,7 @@ int _alpm_db_write(pmdb_t *db, pmpkg_t *info, pmdbinfrq_t inforeq)
 		if(info->depends) {
 			fputs("%DEPENDS%\n", fp);
 			for(lp = info->depends; lp; lp = lp->next) {
-				char *depstring = alpm_dep_get_string(lp->data);
+				char *depstring = alpm_dep_compute_string(lp->data);
 				fprintf(fp, "%s\n", depstring);
 				free(depstring);
 			}
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index 22d9beb..78ba1c4 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -93,7 +93,7 @@ static alpm_list_t *delta_graph_init(alpm_list_t *deltas)
 
 		/* determine whether the delta file already exists */
 		fpath = _alpm_filecache_find(vdelta->delta);
-		md5sum = alpm_get_md5sum(fpath);
+		md5sum = alpm_compute_md5sum(fpath);
 		if(fpath && md5sum && strcmp(md5sum, vdelta->delta_md5) == 0) {
 			vdelta->download_size = 0;
 		}
@@ -102,7 +102,7 @@ static alpm_list_t *delta_graph_init(alpm_list_t *deltas)
 
 		/* determine whether a base 'from' file exists */
 		fpath = _alpm_filecache_find(vdelta->from);
-		md5sum = alpm_get_md5sum(fpath);
+		md5sum = alpm_compute_md5sum(fpath);
 		if(fpath && md5sum && strcmp(md5sum, vdelta->from_md5) == 0) {
 			v->weight = vdelta->download_size;
 		}
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 96c971a..940f12c 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -269,7 +269,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
 			if(!_alpm_find_dep_satisfier(upgrade, depend) &&
 			   !_alpm_find_dep_satisfier(dblist, depend)) {
 				/* Unsatisfied dependency in the upgrade list */
-				char *missdepstring = alpm_dep_get_string(depend);
+				char *missdepstring = alpm_dep_compute_string(depend);
 				_alpm_log(PM_LOG_DEBUG, "checkdeps: missing dependency '%s' for package '%s'\n",
 						missdepstring, alpm_pkg_get_name(tp));
 				free(missdepstring);
@@ -293,7 +293,7 @@ alpm_list_t SYMEXPORT *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
 				if(causingpkg &&
 				   !_alpm_find_dep_satisfier(upgrade, depend) &&
 				   !_alpm_find_dep_satisfier(dblist, depend)) {
-					char *missdepstring = alpm_dep_get_string(depend);
+					char *missdepstring = alpm_dep_compute_string(depend);
 					_alpm_log(PM_LOG_DEBUG, "checkdeps: transaction would break '%s' dependency of '%s'\n",
 							missdepstring, alpm_pkg_get_name(lp));
 					free(missdepstring);
@@ -581,7 +581,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, alpm_list_t *list,
 			pmpkg_t *spkg = _alpm_resolvedep(missdep, dbs_sync, list, tpkg);
 			if(!spkg) {
 				pm_errno = PM_ERR_UNSATISFIED_DEPS;
-				char *missdepstring = alpm_dep_get_string(missdep);
+				char *missdepstring = alpm_dep_compute_string(missdep);
 				_alpm_log(PM_LOG_ERROR, _("cannot resolve \"%s\", a dependency of \"%s\"\n"),
 			                               missdepstring, tpkg->name);
 				free(missdepstring);
@@ -685,7 +685,7 @@ const char SYMEXPORT *alpm_dep_get_version(const pmdepend_t *dep)
  * @param dep the depend to turn into a string
  * @return a string-formatted dependency with operator if necessary
  */
-char SYMEXPORT *alpm_dep_get_string(const pmdepend_t *dep)
+char SYMEXPORT *alpm_dep_compute_string(const pmdepend_t *dep)
 {
 	char *name, *opr, *ver, *str = NULL;
 	size_t len;
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index b26c970..2255607 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -538,7 +538,7 @@ int _alpm_lstat(const char *path, struct stat *buf)
  * @return the checksum on success, NULL on error
  * @addtogroup alpm_misc
  */
-char SYMEXPORT *alpm_get_md5sum(const char *filename)
+char SYMEXPORT *alpm_compute_md5sum(const char *filename)
 {
 	unsigned char output[16];
 	char *md5sum;
@@ -572,7 +572,7 @@ int _alpm_test_md5sum(const char *filepath, const char *md5sum)
 	char *md5sum2;
 	int ret;
 
-	md5sum2 = alpm_get_md5sum(filepath);
+	md5sum2 = alpm_compute_md5sum(filepath);
 
 	if(md5sum == NULL || md5sum2 == NULL) {
 		ret = -1;
diff --git a/src/pacman/package.c b/src/pacman/package.c
index fddce94..ed81484 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -79,7 +79,7 @@ void dump_pkg_full(pmpkg_t *pkg, int level)
 	/* turn depends list into a text list */
 	for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) {
 		pmdepend_t *dep = (pmdepend_t*)alpm_list_getdata(i);
-		depstrings = alpm_list_add(depstrings, alpm_dep_get_string(dep));
+		depstrings = alpm_list_add(depstrings, alpm_dep_compute_string(dep));
 	}
 
 	if(level>0) {
@@ -174,7 +174,7 @@ void dump_pkg_backups(pmpkg_t *pkg)
 			snprintf(path, PATH_MAX-1, "%s%s", root, str);
 			/* if we find the file, calculate checksums, otherwise it is missing */
 			if(access(path, R_OK) == 0) {
-				char *md5sum = alpm_get_md5sum(path);
+				char *md5sum = alpm_compute_md5sum(path);
 
 				if(md5sum == NULL) {
 					pm_fprintf(stderr, PM_LOG_ERROR,
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index 841a08b..11bc157 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -107,7 +107,7 @@ int pacman_remove(alpm_list_t *targets)
 				for(i = data; i; i = alpm_list_next(i)) {
 					pmdepmissing_t *miss = alpm_list_getdata(i);
 					pmdepend_t *dep = alpm_miss_get_dep(miss);
-					char *depstring = alpm_dep_get_string(dep);
+					char *depstring = alpm_dep_compute_string(dep);
 					printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss),
 							depstring);
 					free(depstring);
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 63397aa..aacdb51 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -639,7 +639,7 @@ static int sync_trans(alpm_list_t *targets)
 				for(i = data; i; i = alpm_list_next(i)) {
 					pmdepmissing_t *miss = alpm_list_getdata(i);
 					pmdepend_t *dep = alpm_miss_get_dep(miss);
-					char *depstring = alpm_dep_get_string(dep);
+					char *depstring = alpm_dep_compute_string(dep);
 					printf(_(":: %s: requires %s\n"), alpm_miss_get_target(miss),
 							depstring);
 					free(depstring);
diff --git a/src/pacman/upgrade.c b/src/pacman/upgrade.c
index c54b3ed..2c99688 100644
--- a/src/pacman/upgrade.c
+++ b/src/pacman/upgrade.c
@@ -90,7 +90,7 @@ int pacman_upgrade(alpm_list_t *targets)
 				for(i = data; i; i = alpm_list_next(i)) {
 					pmdepmissing_t *miss = alpm_list_getdata(i);
 					pmdepend_t *dep = alpm_miss_get_dep(miss);
-					char *depstring = alpm_dep_get_string(dep);
+					char *depstring = alpm_dep_compute_string(dep);
 
 					/* TODO indicate if the error was a virtual package or not:
 					 *		:: %s: requires %s, provided by %s
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 69e3519..e4d6c42 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -140,7 +140,7 @@ int main(int argc, char **argv)
 	for(i = data; i; i = alpm_list_next(i)) {
 		pmdepmissing_t *miss = alpm_list_getdata(i);
 		pmdepend_t *dep = alpm_miss_get_dep(miss);
-		char *depstring = alpm_dep_get_string(dep);
+		char *depstring = alpm_dep_compute_string(dep);
 		printf("missing dependency for %s : %s\n", alpm_miss_get_target(miss),
 				depstring);
 		free(depstring);
-- 
1.6.0





More information about the pacman-dev mailing list