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/aethra.c | |
parent | f65cb5f27bab6310e847f88cd763eb08bff1c93b (diff) | |
download | wireshark-33bb54a9452f4be53377a185195a63194016241a.tar.gz wireshark-33bb54a9452f4be53377a185195a63194016241a.tar.bz2 wireshark-33bb54a9452f4be53377a185195a63194016241a.zip |
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/aethra.c')
-rw-r--r-- | wiretap/aethra.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/wiretap/aethra.c b/wiretap/aethra.c index 44e728c61d..08880823dd 100644 --- a/wiretap/aethra.c +++ b/wiretap/aethra.c @@ -142,7 +142,6 @@ int aethra_open(wtap *wth, int *err, gchar **err_info) return -1; return 0; } - wth->data_offset += sizeof hdr.magic; if (memcmp(hdr.magic, aethra_magic, sizeof aethra_magic) != 0) return 0; @@ -157,7 +156,6 @@ int aethra_open(wtap *wth, int *err, gchar **err_info) return -1; return 0; } - wth->data_offset += sizeof hdr - sizeof hdr.magic; wth->file_type = WTAP_FILE_AETHRA; aethra = (aethra_t *)g_malloc(sizeof(aethra_t)); wth->priv = (void *)aethra; @@ -205,7 +203,7 @@ static gboolean aethra_read(wtap *wth, int *err, gchar **err_info, * of AETHRA_ISDN_LINK_LAPD record or get an end-of-file. */ for (;;) { - *data_offset = wth->data_offset; + *data_offset = file_tell(wth->fh); /* Read record header. */ if (!aethra_read_rec_header(wth->fh, &hdr, &wth->pseudo_header, @@ -220,7 +218,6 @@ static gboolean aethra_read(wtap *wth, int *err, gchar **err_info, rec_size, (unsigned int)(sizeof hdr - sizeof hdr.rec_size)); return FALSE; } - wth->data_offset += sizeof hdr; /* * XXX - if this is big, we might waste memory by @@ -232,7 +229,6 @@ static gboolean aethra_read(wtap *wth, int *err, gchar **err_info, if (!aethra_read_rec_data(wth->fh, buffer_start_ptr(wth->frame_buffer), packet_size, err, err_info)) return FALSE; /* Read error */ - wth->data_offset += packet_size; } #if 0 packet++; |