Errr....

RED FLAG!

-  char buf[len+1];
-  memcpy(buf, tmpl.data(), len);
+  std::vector<char> buf(len + 1);
+  memcpy(&buf[0], tmpl.data(), len);

Do we know for sure that all implementations of std::vector<char> work
in such a way that memcpy() and other functions with pure C semantics
will always work?

Cheers,
Richard

In message <[email protected]> on Thu, 26 Mar 2009 13:18:09 
-0400, Jack Lloyd <[email protected]> said:

lloyd> On Thu, Mar 26, 2009 at 11:53:10AM +0000, Phil Hannent wrote:
lloyd> > Where it defines:
lloyd> > 
lloyd> > char buf[len+1];
lloyd> > 
lloyd> > If I convert this to:
lloyd> > 
lloyd> > char* buf = new char[len+1];
lloyd> 
lloyd> This will leak memory, though. Using std::vector to hold buf should
lloyd> also work. A patch is attached.
lloyd> 
lloyd> > It works, however the next message I get is:
lloyd> > 
lloyd> > Error  147     error C3416: 'dump' : an explicit specialization may 
not be
lloyd> > explicitly instantiated        
c:\buildbot\monotone-0.43.tar\monotone-0.43\vocab.cc
lloyd> > 190    tester
lloyd> > 
lloyd> > on this line:
lloyd> > 
lloyd> > template void dump(rsa_pub_key const&, string &);
lloyd> 
lloyd> I could not find this function being specialized anywhere in the
lloyd> source, and simply commenting out the specialization seemed to work OK
lloyd> with GCC.
lloyd> 
lloyd> -Jack

-- 
Richard Levitte                         [email protected]
                                        http://richard.levitte.org/

"Life is a tremendous celebration - and I'm invited!"
-- from a friend's blog, translated from Swedish


_______________________________________________
Monotone-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monotone-devel

Reply via email to