diff options
author | Dave Reisner <dreisner@archlinux.org> | 2012-05-28 23:32:11 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-06-26 06:04:31 +0200 |
commit | f556fe8b4a199116b5665bb5f0886e4c2962b077 (patch) | |
tree | da359a1cea95066f32962219e4909adf325c0df4 /lib/libalpm/be_sync.c | |
parent | 74274b5dc347ba70e4abd1f329feb41538f82ff4 (diff) | |
download | pacman-f556fe8b4a199116b5665bb5f0886e4c2962b077.tar.gz pacman-f556fe8b4a199116b5665bb5f0886e4c2962b077.tar.xz |
add line length parameter to _alpm_strip_newline
If known, callers can pass the line size to this function in order to
avoid an strlen call. Otherwise, they simply pass 0 and
_alpm_strip_newline will do the call instead.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_sync.c')
-rw-r--r-- | lib/libalpm/be_sync.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 02f087ad..29ef1900 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -482,7 +482,7 @@ cleanup: #define READ_NEXT() do { \ if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \ line = buf.line; \ - _alpm_strip_newline(line); \ + _alpm_strip_newline(line, buf.real_line_size); \ } while(0) #define READ_AND_STORE(f) do { \ @@ -493,14 +493,14 @@ cleanup: #define READ_AND_STORE_ALL(f) do { \ char *linedup; \ if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \ - if(_alpm_strip_newline(buf.line) == 0) break; \ + if(_alpm_strip_newline(buf.line, buf.real_line_size) == 0) break; \ STRDUP(linedup, buf.line, goto error); \ f = alpm_list_add(f, linedup); \ } while(1) /* note the while(1) and not (0) */ #define READ_AND_SPLITDEP(f) do { \ if(_alpm_archive_fgets(archive, &buf) != ARCHIVE_OK) goto error; \ - if(_alpm_strip_newline(buf.line) == 0) break; \ + if(_alpm_strip_newline(buf.line, buf.real_line_size) == 0) break; \ f = alpm_list_add(f, _alpm_splitdep(line)); \ } while(1) /* note the while(1) and not (0) */ @@ -539,7 +539,7 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive, int ret; while((ret = _alpm_archive_fgets(archive, &buf)) == ARCHIVE_OK) { char *line = buf.line; - if(_alpm_strip_newline(line) == 0) { + if(_alpm_strip_newline(line, buf.real_line_size) == 0) { /* length of stripped line was zero */ continue; } |