[Ns-bugs] [Bug 872] ns3::PcapFileWrapper::Write explodes stack
code at nsnam.ece.gatech.edu
Tue Apr 13 23:48:14 PDT 2010
--- Comment #5 from Mathieu Lacage <mathieu.lacage at sophia.inria.fr> 2010-04-14 02:48:14 EDT ---
Created an attachment (id=830)
use std::ostream in PcapFile and get rid of stack-allocated variables
This patch deals with the problem for me. I chose to go with the std::ostream
path because I was worried that:
- it was not acceptable to have a per-PcapFileWrapper 64k buffer for
temporary storage when there is already a buffer in the underlying FILE *
- I would not be able to get the sharing right if I tried to share the 64k
buffer among PcapFileWrapper instances
A couple of notes:
- I removed support for the "a" open mode because I did not find any user in
our codebase and I felt pain in implementing it correctly. Consequently, I #if
0 the corresponding test.
- I changed a couple of public APIs which took std::string for the open mode
and replaced them with std::ios::openmode
- I know that the proper type is std::ios_base::openmode but
std::ios::openmode was easier to type
- I removed the bool return value used to indicate read/write/init/open
errors to use instead a pair of Fail/Clear functions to mirror the behavior of
the underlying std::iostream. This was easier to implement and it did not
propagate very far in our API so, I felt it was worth it.
- of course, I removed the stack-allocated buffers in PcapFileWrapper::Write*
Feel free to do what you think is right with this patch.
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Ns-bugs