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/mime_file.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/mime_file.c')
-rw-r--r-- | wiretap/mime_file.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/wiretap/mime_file.c b/wiretap/mime_file.c index 90eafcd9c0..f3a4561c09 100644 --- a/wiretap/mime_file.c +++ b/wiretap/mime_file.c @@ -102,7 +102,7 @@ mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) wth->phdr.ts.secs = 0; wth->phdr.ts.nsecs = 0; - *data_offset = wth->data_offset; + *data_offset = file_tell(wth->fh); /* try to read max WTAP_MAX_PACKET_SIZE bytes */ packet_size = file_read(_buf, sizeof(_buf), wth->fh); @@ -123,7 +123,6 @@ mime_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) buf = buffer_start_ptr(wth->frame_buffer); memcpy(buf, _buf, packet_size); - wth->data_offset += packet_size; wth->phdr.caplen = packet_size; wth->phdr.len = packet_size; return TRUE; |