Wireshark mailing list archives
Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c
From: Dirk Jagdmann <doj () cubic org>
Date: Tue, 06 Aug 2013 15:57:41 -0700
If not, would an lseek() followed by a read() do just as well?
No. lseek() and read() modify the file position/offset. pread() however does *not* modify it. So to emulate pread() you would need something like:
ssize_t my_pread(int fd, void *buf, size_t count, off_t offset)
{
const off_t old_offset = lseek(fd, 0, SEEK_CUR); // missing error handling
lseek(fd, offset, SEEK_SET); // missing error handling
const ssize_t ret = read(fd, buf, count);
lseek(fd, old_offset, SEEK_SET); // missing error handling
return ret;
}
--
---> Dirk Jagdmann
----> http://cubic.org/~doj
-----> http://llg.cubic.org
___________________________________________________________________________
Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives: http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Guy Harris (Aug 06)
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Evan Huus (Aug 06)
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Jakub Zawadzki (Aug 06)
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Evan Huus (Aug 06)
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Evan Huus (Aug 06)
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Jakub Zawadzki (Aug 06)
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Dirk Jagdmann (Aug 06)
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Guy Harris (Aug 06)
- Re: [Wireshark-commits] rev 51169: / /trunk/epan/: app_mem_usage.c Evan Huus (Aug 06)
