Bugzilla – Bug 929
nms-p2p-nix.cc uses variable length array
Last modified: 2011-08-10 12:39:35 EDT
nms-p2p-nix.cc uses variable length array, which cannot be compiled using some compilers (especially strict standards-compilent compilers like clang). Variable length array is part of C99 but does not comply with C++ standards (not in C++98, rejected for C++0x).
Tried to cc the bug to original author, but the author is not registered on bugzilla.
Created attachment 901 [details] Proposed patch. Proposed patch attached. Quite an ugly way to go about it (making 2D/3D array classes so that the main logic code doesn't have to change, but i can't see an easy way around it) Haven't tested it yet because the test runs too long on my slow computer (even the original code take very long). I don't expect behaviours to have changed, but may have memory leaks due to the new[] operators.
(In reply to comment #2) > Created an attachment (id=901) [details] > Proposed patch. > > Proposed patch attached. Quite an ugly way to go about it (making 2D/3D array > classes so that the main logic code doesn't have to change, but i can't see an > easy way around it) > > Haven't tested it yet because the test runs too long on my slow computer (even > the original code take very long). I don't expect behaviours to have changed, > but may have memory leaks due to the new[] operators. Do you think it would work if you used 2d and 3d std::vectors instead of creating these new classes and messing with dynamic arrays? example: std::vector<std::vector<NodeContainer> > nodes_net0[nCN][3]
(In reply to comment #3) > Do you think it would work if you used 2d and 3d std::vectors instead of > creating these new classes and messing with dynamic arrays? > > example: std::vector<std::vector<NodeContainer> > nodes_net0[nCN][3] Haven't worked with NS3 for a while now (I'm spending time analysing my data) - from memory, I chose not to use vector because the lengths are not fixed. There'll also need to be code to initialise the outside vectors. (I suppose we can use the constructor taking in default variable, but the code calling that constructor will look awful when we're looking at more than a couple of dimensions.)
Created attachment 1006 [details] alternative patch using nested new[]
(In reply to comment #5) > Created attachment 1006 [details] > alternative patch using nested new[] I read patch 2 and was about to suggest doing what you did in patch 1. applied patch 1 as obvious. changeset: a26626a4f5bf