aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2005-01-10 20:42:24 +0000
committerJason Woodward2005-01-10 20:42:24 +0000
commita024305995ab453105704d109bdcdafd0e6152b6 (patch)
tree8cd18d8a71b29fbe6088e9fd482b254d965e3da5 /src
parent91d7da28050cada477dd04a5745fafccda6086e8 (diff)
downloadslapt-get-a024305995ab453105704d109bdcdafd0e6152b6.tar.gz
moved needless strlen() calls out of while loops
Diffstat (limited to 'src')
-rw-r--r--src/common.c5
-rw-r--r--src/configuration.c6
-rw-r--r--src/package.c15
3 files changed, 15 insertions, 11 deletions
diff --git a/src/common.c b/src/common.c
index 108c7c1..5de61ed 100644
--- a/src/common.c
+++ b/src/common.c
@@ -109,7 +109,7 @@ void gen_md5_sum_of_file(FILE *f,char *result_sum){
/* recursively create dirs */
void create_dir_structure(const char *dir_name){
char *cwd = NULL;
- int position = 0;
+ int position = 0,len = 0;
cwd = getcwd(NULL,0);
if( cwd == NULL ){
@@ -121,7 +121,8 @@ void create_dir_structure(const char *dir_name){
#endif
}
- while( position < (int) strlen(dir_name) ){
+ len = strlen(dir_name);
+ while( position < len ){
char *pointer = NULL;
char *dir_name_buffer = NULL;
diff --git a/src/configuration.c b/src/configuration.c
index a4a324a..9423233 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -173,7 +173,7 @@ void free_rc_config(rc_config *global_config){
static struct exclude_list *parse_exclude(char *line){
struct exclude_list *list;
- int position = 0;
+ int position = 0, len = 0;
list = malloc( sizeof *list );
if( list == NULL ){
@@ -189,8 +189,8 @@ static struct exclude_list *parse_exclude(char *line){
/* skip ahead past the = */
line = strchr(line,'=') + 1;
-
- while( position < (int) strlen(line) ){
+ len = strlen(line);
+ while( position < len ){
char **realloc_tmp;
char *buffer = NULL;
char *pointer = NULL;
diff --git a/src/package.c b/src/package.c
index 855a317..0666256 100644
--- a/src/package.c
+++ b/src/package.c
@@ -1038,7 +1038,7 @@ struct pkg_list *search_pkg_list(struct pkg_list *available,const char *pattern)
/* lookup dependencies for pkg */
int get_pkg_dependencies(const rc_config *global_config,struct pkg_list *avail_pkgs,struct pkg_list *installed_pkgs,pkg_info_t *pkg,struct pkg_list *deps){
- int position = 0;
+ int position = 0, len = 0;
char *pointer = NULL;
char *buffer = NULL;
@@ -1058,7 +1058,8 @@ int get_pkg_dependencies(const rc_config *global_config,struct pkg_list *avail_p
#endif
/* parse dep line */
- while( position < (int) strlen(pkg->required) ){
+ len = strlen(pkg->required);
+ while( position < len ){
pkg_info_t *tmp_pkg = NULL;
/* either the last or there was only one to begin with */
@@ -1157,7 +1158,7 @@ int get_pkg_dependencies(const rc_config *global_config,struct pkg_list *avail_p
/* lookup conflicts for package */
struct pkg_list *get_pkg_conflicts(struct pkg_list *avail_pkgs,struct pkg_list *installed_pkgs,pkg_info_t *pkg){
struct pkg_list *conflicts;
- int position = 0;
+ int position = 0,len = 0;
char *pointer = NULL;
char *buffer = NULL;
@@ -1173,7 +1174,8 @@ struct pkg_list *get_pkg_conflicts(struct pkg_list *avail_pkgs,struct pkg_list *
return conflicts;
/* parse conflict line */
- while( position < (int) strlen(pkg->conflicts) ){
+ len = strlen(pkg->conflicts);
+ while( position < len ){
pkg_info_t *tmp_pkg = NULL;
/* either the last or there was only one to begin with */
@@ -2100,9 +2102,10 @@ void clean_pkg_dir(const char *dir_name){
/* find dependency from "or" requirement */
static pkg_info_t *find_or_requirement(struct pkg_list *avail_pkgs,struct pkg_list *installed_pkgs,char *required_str){
pkg_info_t *pkg = NULL;
- int position = 0;
+ int position = 0, len = 0;
- while( position < (int)strlen(required_str) ){
+ len = strlen(required_str);
+ while( position < len ){
if( strchr(required_str + position,'|') == NULL ){
char *string = required_str + position;