0

I am populating network data buffer for sockets send() call. Initially i know buffer maximumSize, and (after populating it) i know finalSize <= maximumSize. I feel convenient having possibility to shrink such a buffer, making it smaller, leaving data as is.

1) I want use container, storing the size along (like std::vector< char > or std::string)

2) There is no need to memset allocated buffer bytes to zero or any other known value.

I want to satisfy 1 and 2. What container can you advise me and why?

nommyravian
  • 1,316
  • 2
  • 12
  • 30
xakepp35
  • 2,878
  • 7
  • 26
  • 54
  • 2
    [`std::vector` with a neat trick](http://stackoverflow.com/questions/11149665/c-vector-that-doesnt-initialize-its-members) - in the accepted answer. – jrok Aug 23 '13 at 14:29
  • thanks for info, i was not able to find related topics here by myself. – xakepp35 Aug 23 '13 at 14:38
  • In a crunch you could use a `std::unique_ptr(new char[MAX])` and keep track of the actual size. – Kerrek SB Aug 23 '13 at 14:40
  • I dont want my program to "crunch". unique_ptr seems totally unsuitable solution here, as it violates requirement #1 of my post – xakepp35 Aug 23 '13 at 19:33

0 Answers0