Click here to Skip to main content
15,917,320 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Problem with memory Allocation and deallocation Pin
sudarshan1247-Nov-07 19:53
sudarshan1247-Nov-07 19:53 
GeneralRe: Problem with memory Allocation and deallocation Pin
manish.patel7-Nov-07 20:09
manish.patel7-Nov-07 20:09 
GeneralRe: Problem with memory Allocation and deallocation Pin
toxcct8-Nov-07 2:12
toxcct8-Nov-07 2:12 
AnswerRe: Problem with memory Allocation and deallocation Pin
Cedric Moonen7-Nov-07 20:05
Cedric Moonen7-Nov-07 20:05 
GeneralRe: Problem with memory Allocation and deallocation Pin
manish.patel7-Nov-07 20:15
manish.patel7-Nov-07 20:15 
GeneralRe: Problem with memory Allocation and deallocation Pin
Cedric Moonen7-Nov-07 20:18
Cedric Moonen7-Nov-07 20:18 
GeneralRe: Problem with memory Allocation and deallocation Pin
manish.patel7-Nov-07 21:16
manish.patel7-Nov-07 21:16 
GeneralRe: Problem with memory Allocation and deallocation Pin
Cedric Moonen7-Nov-07 21:23
Cedric Moonen7-Nov-07 21:23 
Ok, but there is a difference between a buffer that you know its size only at runtime and a buffer that can grow Poke tongue | ;-P .

For your problem, I think the best solution is to include the size of each packet just before sending the data. For example, suppose that you need to send 10 bytes from the client to the server, you first send an integer containing the size of the data (10) and then you send the data. On the other side (server), you first wait for an integer (the size of the packet), then you create your buffer of that size (using new) and you store your data in the buffer and process it. Once it is finished, you destroy the buffer.

I think it is the most 'simple' efficient way (using a container class like a std::string will probably add too much overhead).


Cédric Moonen
Software developer

Charting control [v1.2]

GeneralRe: Problem with memory Allocation and deallocation Pin
Nelek7-Nov-07 21:27
protectorNelek7-Nov-07 21:27 
QuestionRe: Problem with memory Allocation and deallocation Pin
Roger Broomfield7-Nov-07 21:26
Roger Broomfield7-Nov-07 21:26 
QuestionRe: Problem with memory Allocation and deallocation Pin
David Crow8-Nov-07 3:37
David Crow8-Nov-07 3:37 
AnswerRe: Problem with memory Allocation and deallocation Pin
Bram van Kampen10-Nov-07 16:02
Bram van Kampen10-Nov-07 16:02 
QuestionDLL_THREAD_ATTACH: Pin
ForNow7-Nov-07 16:34
ForNow7-Nov-07 16:34 
AnswerRe: DLL_THREAD_ATTACH: Pin
Matthew Faithfull7-Nov-07 23:05
Matthew Faithfull7-Nov-07 23:05 
GeneralRe: DLL_THREAD_ATTACH: Pin
ForNow8-Nov-07 1:13
ForNow8-Nov-07 1:13 
GeneralRe: DLL_THREAD_ATTACH: Pin
Matthew Faithfull8-Nov-07 2:05
Matthew Faithfull8-Nov-07 2:05 
GeneralRe: DLL_THREAD_ATTACH: Pin
ForNow8-Nov-07 13:53
ForNow8-Nov-07 13:53 
GeneralRe: DLL_THREAD_ATTACH: Pin
Matthew Faithfull8-Nov-07 22:27
Matthew Faithfull8-Nov-07 22:27 
GeneralRe: DLL_THREAD_ATTACH: Pin
ForNow8-Nov-07 23:16
ForNow8-Nov-07 23:16 
QuestionPerformance & Profiling... Pin
Peter Weyzen7-Nov-07 15:17
Peter Weyzen7-Nov-07 15:17 
AnswerRe: Performance & Profiling... Pin
Nelek7-Nov-07 21:31
protectorNelek7-Nov-07 21:31 
AnswerRe: Performance & Profiling... Pin
Blake Miller16-Nov-07 5:14
Blake Miller16-Nov-07 5:14 
QuestionSimple question about DLLS Pin
bigdenny2007-Nov-07 12:33
bigdenny2007-Nov-07 12:33 
AnswerRe: Simple question about DLLS Pin
Mark Salsbery7-Nov-07 13:27
Mark Salsbery7-Nov-07 13:27 
AnswerRe: Simple question about DLLS Pin
toxcct7-Nov-07 23:15
toxcct7-Nov-07 23:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.