Click here to Skip to main content
15,886,963 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to free the variable Pin
goldenrose912-Feb-11 6:23
goldenrose912-Feb-11 6:23 
GeneralRe: How to free the variable Pin
Aescleal12-Feb-11 10:07
Aescleal12-Feb-11 10:07 
AnswerRe: How to free the variable PinPopular
Aescleal12-Feb-11 5:17
Aescleal12-Feb-11 5:17 
GeneralRe: How to free the variable [modified] Pin
Niklas L12-Feb-11 6:30
Niklas L12-Feb-11 6:30 
GeneralRe: How to free the variable [modified] Pin
goldenrose912-Feb-11 7:30
goldenrose912-Feb-11 7:30 
GeneralRe: How to free the variable Pin
Niklas L12-Feb-11 8:18
Niklas L12-Feb-11 8:18 
GeneralRe: How to free the variable PinPopular
Aescleal12-Feb-11 10:02
Aescleal12-Feb-11 10:02 
GeneralRe: How to free the variable Pin
Niklas L12-Feb-11 12:56
Niklas L12-Feb-11 12:56 
As far as I know, NRVO would still have to issue a call the constructor of the return value every time the function is called. This constructor will then allocate heap memory for the vectors internal buffer. While NRVO will be reusing the same stack space for the vector object, it would not be able to re-use the memory for the internal buffer over subsequent calls to the function. The following usage of the function would only yield a single memory allocation, vector.reserve() in read_from_file(), no matter how many calls you make.
C++
const size_t wanted_chunk_size = 512;
std::vector<char> buffer;
do
{
    read_from_file(wanted_chunk_size, buffer);
    write_to_somewhere(buffer);
}
while (buffer.size() == wanted_chunk_size);


I might have to brush up on NRVO though. Please correct me if I'm wrong.

I always find your posts interesting to read, so if you have time for an RVO post, that would be appreciated.

GeneralRe: How to free the variable Pin
Stefan_Lang13-Feb-11 21:58
Stefan_Lang13-Feb-11 21:58 
GeneralRe: How to free the variable Pin
Niklas L13-Feb-11 23:28
Niklas L13-Feb-11 23:28 
GeneralRe: How to free the variable Pin
Stefan_Lang14-Feb-11 0:18
Stefan_Lang14-Feb-11 0:18 
GeneralRe: How to free the variable Pin
Aescleal12-Feb-11 10:10
Aescleal12-Feb-11 10:10 
QuestionMessage to response function SetFont() Pin
includeh1012-Feb-11 3:38
includeh1012-Feb-11 3:38 
AnswerRe: Message to response function SetFont() Pin
Code-o-mat12-Feb-11 6:52
Code-o-mat12-Feb-11 6:52 
AnswerRe: Message to response function SetFont() Pin
User 742933813-Feb-11 2:57
professionalUser 742933813-Feb-11 2:57 
AnswerRe: Message to response function SetFont() Pin
Hans Dietrich12-Feb-11 6:53
mentorHans Dietrich12-Feb-11 6:53 
QuestionCEdit Box Error Pin
raju_shiva12-Feb-11 0:40
raju_shiva12-Feb-11 0:40 
AnswerRe: CEdit Box Error Pin
Richard MacCutchan12-Feb-11 2:04
mveRichard MacCutchan12-Feb-11 2:04 
QuestionUsing gdiplus to skew, rotate and resize a matrix (image) Pin
Kiran Satish11-Feb-11 13:43
Kiran Satish11-Feb-11 13:43 
AnswerRe: Using gdiplus to skew, rotate and resize a matrix (image) Pin
Rozis14-Feb-11 10:34
Rozis14-Feb-11 10:34 
QuestionNew Company Pin
VonHagNDaz11-Feb-11 3:27
VonHagNDaz11-Feb-11 3:27 
AnswerRe: New Company Pin
Rajesh R Subramanian11-Feb-11 3:42
professionalRajesh R Subramanian11-Feb-11 3:42 
GeneralRe: New Company Pin
VonHagNDaz11-Feb-11 3:44
VonHagNDaz11-Feb-11 3:44 
QuestionHow to increase buffer size for CEdit Box in VC6 Pin
raju_shiva10-Feb-11 22:53
raju_shiva10-Feb-11 22:53 
AnswerRe: How to increase buffer size for CEdit Box in VC6 PinPopular
Nuri Ismail10-Feb-11 23:16
Nuri Ismail10-Feb-11 23:16 

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.