diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-05-04 16:56:18 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-05-04 16:56:18 +0000 |
commit | 33bb54a9452f4be53377a185195a63194016241a (patch) | |
tree | 9308829e2105b6e51e0dc5cc0af2295d8d97a0a3 /wiretap/ber.c | |
parent | f65cb5f27bab6310e847f88cd763eb08bff1c93b (diff) |
file_seek() used to be a wrapper around fseek() or gzseek(), both of
which could use lseek() and were thus expensive due to system call
overhead. To avoid making a system call for every packet on a
sequential read, we maintained a data_offset field in the wtap structure
for sequential reads.
It's now a routine that just returns information from the FILE_T data
structure, so it's cheap. Use it, rather than maintaining the data_offset
field.
Readers for some file formats need to maintain file offset themselves;
have them do so in their private data structures.
svn path=/trunk/; revision=42423
Diffstat (limited to 'wiretap/ber.c')
-rw-r--r-- | wiretap/ber.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/wiretap/ber.c b/wiretap/ber.c index df0b1687af..7b85309550 100644 --- a/wiretap/ber.c +++ b/wiretap/ber.c @@ -44,17 +44,20 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { + gint64 offset; guint8 *buf; gint64 file_size; int packet_size; *err = 0; + offset = file_tell(wth->fh); + /* there is only ever one packet */ - if(wth->data_offset) + if (offset != 0) return FALSE; - *data_offset = wth->data_offset; + *data_offset = offset; if ((file_size = wtap_file_size(wth, err)) == -1) return FALSE; @@ -76,8 +79,6 @@ static gboolean ber_read(wtap *wth, int *err, gchar **err_info, gint64 *data_off wtap_file_read_expected_bytes(buf, packet_size, wth->fh, err, err_info); - wth->data_offset += packet_size; - wth->phdr.presence_flags = 0; /* yes, we have no bananas^Wtime stamp */ wth->phdr.caplen = packet_size; |