summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2005-04-26 03:01:27 +0000
committerJason Woodward2005-04-26 03:01:27 +0000
commit40cfdf80577fd3577c5499edcc8747d88802429a (patch)
treead1e84dd6a7ae18094a5702dcef118060251447e
parente5c8e1d89c3c95d3f123e6cb59f421405ae4f8b8 (diff)
downloadslapt-get-40cfdf80577fd3577c5499edcc8747d88802429a.tar.gz
initialized source in sources list [fixing valgrind warning]
-rw-r--r--ChangeLog3
-rw-r--r--src/configuration.c26
2 files changed, 21 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d76646a..afe3214 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
-0.9.9k Apr 21, 2005
+0.9.9k Apr 25, 2005
+ * initialized source in sources list [fixing valgrind warning]
* updated FAQ
0.9.9j Apr 17, 2005
diff --git a/src/configuration.c b/src/configuration.c
index 2b7dc68..b65e614 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -212,6 +212,10 @@ void add_exclude(struct exclude_list *list,const char *e){
void add_source(struct source_list *list,const char *s){
char **realloc_tmp;
+ int source_len = 0;
+
+ if( s == NULL ) return;
+ source_len = strlen(s);
realloc_tmp = realloc(list->url,sizeof *list->url * (list->count + 1) );
@@ -219,24 +223,32 @@ void add_source(struct source_list *list,const char *s){
list->url = realloc_tmp;
- if( s[strlen(s) - 1] != '/' ){
+ if( s[source_len - 1] == '/' ){
+
+ list->url[ list->count ] = strndup(s,source_len);
+ list->url[ list->count ][source_len] = '\0';
+
+ }else{
+
list->url[ list->count ] = slapt_malloc(
- sizeof *list->url[list->count] * (strlen(s) + 2)
+ sizeof *list->url[list->count] * (source_len + 2)
);
+ list->url[list->count][0] = '\0';
+
list->url[list->count] = strncat(
list->url[list->count],
s,
- strlen(s)
+ source_len
);
+
list->url[list->count] = strncat(
list->url[list->count],
"/",
strlen("/")
);
- list->url[list->count][strlen(s) + 1] = '\0';
- }else{
- list->url[ list->count ] = strndup(s,strlen(s));
- list->url[ list->count ][strlen(s)] = '\0';
+
+ list->url[list->count][source_len + 1] = '\0';
+
}
++list->count;