summaryrefslogtreecommitdiff
path: root/lib/libalpm/db.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-06-05 17:34:33 -0400
committerDan McGee <dan@archlinux.org>2007-06-05 17:34:33 -0400
commitf7912e9dc6be71b177d546da0f8d005e7b4af9e8 (patch)
tree14f9c7be0757de98d2325b3623eac2a45a438a16 /lib/libalpm/db.c
parent4906b76c85bc93c4a86dfa8449d58b55ede30425 (diff)
downloadpacman-f7912e9dc6be71b177d546da0f8d005e7b4af9e8.tar.xz
Const correctness!
Add some 'const' keywords all over the code to make it a bit more strict on what you can and can't do with data. This is especially important when we return pointers to the pacman frontend- ideally this would always be untouchable data. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r--lib/libalpm/db.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index e6c784cc..7536e678 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -258,6 +258,35 @@ int SYMEXPORT alpm_db_update(int force, pmdb_t *db)
return(0);
}
+const char SYMEXPORT *alpm_db_get_name(const pmdb_t *db)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(db != NULL, return(NULL));
+
+ return db->treename;
+}
+
+const char SYMEXPORT *alpm_db_get_url(const pmdb_t *db)
+{
+ char path[PATH_MAX];
+ pmserver_t *s;
+
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(db != NULL, return(NULL));
+
+ s = (pmserver_t*)db->servers->data;
+
+ snprintf(path, PATH_MAX, "%s://%s%s", s->s_url->scheme, s->s_url->host, s->s_url->doc);
+ return strdup(path);
+}
+
+
/** Get a package entry from a package database
* @param db pointer to the package database to get the package from
* @param name of the package
@@ -344,7 +373,7 @@ alpm_list_t SYMEXPORT *alpm_db_getgrpcache(pmdb_t *db)
* @param needles the list of strings to search for
* @return the list of packages on success, NULL on error
*/
-alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, alpm_list_t* needles)
+alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles)
{
ALPM_LOG_FUNC;
@@ -361,7 +390,7 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, alpm_list_t* needles)
alpm_list_t SYMEXPORT *alpm_db_get_upgrades()
{
alpm_list_t *syncpkgs = NULL;
- alpm_list_t *i, *j, *k, *m;
+ const alpm_list_t *i, *j, *k, *m;
ALPM_LOG_FUNC;
@@ -540,9 +569,10 @@ int _alpm_db_cmp(const void *db1, const void *db2)
return(strcmp(((pmdb_t *)db1)->treename, ((pmdb_t *)db2)->treename));
}
-alpm_list_t *_alpm_db_search(pmdb_t *db, alpm_list_t *needles)
+alpm_list_t *_alpm_db_search(pmdb_t *db, const alpm_list_t *needles)
{
- alpm_list_t *i, *j, *k, *ret = NULL;
+ const alpm_list_t *i, *j, *k;
+ alpm_list_t *ret = NULL;
ALPM_LOG_FUNC;
@@ -659,32 +689,4 @@ pmdb_t *_alpm_db_register(const char *treename)
return(db);
}
-const char SYMEXPORT *alpm_db_get_name(pmdb_t *db)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
-
- return db->treename;
-}
-
-const char *alpm_db_get_url(pmdb_t *db)
-{
- char path[PATH_MAX];
- pmserver_t *s;
-
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(db != NULL, return(NULL));
-
- s = (pmserver_t*)db->servers->data;
-
- snprintf(path, PATH_MAX, "%s://%s%s", s->s_url->scheme, s->s_url->host, s->s_url->doc);
- return strdup(path);
-}
-
/* vim: set ts=2 sw=2 noet: */