From 33bb54a9452f4be53377a185195a63194016241a Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 4 May 2012 16:56:18 +0000 Subject: 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 --- wiretap/aethra.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'wiretap/aethra.c') 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++; -- cgit v1.2.3