summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-12-27 02:53:51 -0600
committerAllan McRae <allan@archlinux.org>2013-01-03 12:03:10 +1000
commit2616cb5fdce0c54e829a88318d671dd5032f0aac (patch)
tree76ff842953f677446363b39e4ef4c213ba223715
parent038b1815d0ab1a8c0aab4d6cfc18541df5c6cd33 (diff)
downloadpacman-2616cb5fdce0c54e829a88318d671dd5032f0aac.tar.xz
Use a defined constant in delta.c for num_matches
This allows compiling in both clang and gcc without running into oddities regarding const vs. defined constant values. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/delta.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index 536d6788..2da14961 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -270,6 +270,8 @@ alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(alpm_pkg_t *pkg)
/** @} */
+#define NUM_MATCHES 6
+
/** Parses the string representation of a alpm_delta_t object.
* This function assumes that the string is in the correct format.
* This format is as follows:
@@ -281,9 +283,8 @@ alpm_list_t SYMEXPORT *alpm_pkg_unused_deltas(alpm_pkg_t *pkg)
alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
{
alpm_delta_t *delta;
- const int num_matches = 6;
size_t len;
- regmatch_t pmatch[num_matches];
+ regmatch_t pmatch[NUM_MATCHES];
char filesize[32];
/* this is so we only have to compile the pattern once */
@@ -296,7 +297,7 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
handle->delta_regex_compiled = 1;
}
- if(regexec(&handle->delta_regex, line, num_matches, pmatch, 0) != 0) {
+ if(regexec(&handle->delta_regex, line, NUM_MATCHES, pmatch, 0) != 0) {
/* delta line is invalid, return NULL */
return NULL;
}
@@ -326,6 +327,8 @@ alpm_delta_t *_alpm_delta_parse(alpm_handle_t *handle, const char *line)
return delta;
}
+#undef NUM_MATCHES
+
void _alpm_delta_free(alpm_delta_t *delta)
{
FREE(delta->delta);