Click here to Skip to main content
15,868,016 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Unit tests Pin
Richard Andrew x6415-Jan-23 11:36
professionalRichard Andrew x6415-Jan-23 11:36 
GeneralRe: Unit tests Pin
PIEBALDconsult15-Jan-23 13:37
mvePIEBALDconsult15-Jan-23 13:37 
GeneralRe: Unit tests Pin
englebart15-Jan-23 5:15
professionalenglebart15-Jan-23 5:15 
GeneralRe: Unit tests Pin
PIEBALDconsult15-Jan-23 5:59
mvePIEBALDconsult15-Jan-23 5:59 
GeneralRe: Unit tests Pin
jschell15-Jan-23 8:33
jschell15-Jan-23 8:33 
GeneralRe: Unit tests Pin
Jeremy Falcon15-Jan-23 8:45
professionalJeremy Falcon15-Jan-23 8:45 
GeneralRe: Unit tests Pin
PIEBALDconsult15-Jan-23 10:00
mvePIEBALDconsult15-Jan-23 10:00 
GeneralRe: Unit tests Pin
Jeremy Falcon17-Jan-23 3:46
professionalJeremy Falcon17-Jan-23 3:46 
PIEBALDconsult wrote:
The issue I have with that is when a large buffer is required many times. I'd rather use a static buffer so that repeated calls (if any) don't have to keep allocating large buffers; they can re-use a buffer which has already been allocated for the largest value so far encountered.
Oh, my point wasn't so much about not using a static buffer. There are plenty of use cases where a static buffer on the heap and/or local static variable on the heap make total sense. Just saying what I do in each circumstance.
PIEBALDconsult wrote:
Although my original post involves a scenario in which this function gets called once (or twice, rarely) with small values (short strings), the function might get called millions of times with strings of thousands of characters in the worst-case scenario.
Sure, so in this case the routine wouldn't be pure as you can't guarantee that memory will be allocated initially... especially if it's a large chunk. I mean, we could get pedantic and say the same thing about the stack too, but you get the idea. Usually if the stack is corrupt that program is gonna crash anyway. Smile | :) Not saying don't do it... saying I would test it as a non-pure function.
PIEBALDconsult wrote:
At any rate, I'm not about to change the function just so that it fully qualifies as a pure function; there are bigger fish to fry.
Yeah dude, you completely misread my entire post. Try again.
Jeremy Falcon

Generalworldle358 Pin
jmaida14-Jan-23 10:49
jmaida14-Jan-23 10:49 
GeneralQM + AI = oo Pin
BernardIE531714-Jan-23 3:53
BernardIE531714-Jan-23 3:53 
GeneralRe: QM + AI = oo Pin
Mike Hankey14-Jan-23 5:11
mveMike Hankey14-Jan-23 5:11 
GeneralRe: QM + AI = oo Pin
jmaida14-Jan-23 16:59
jmaida14-Jan-23 16:59 
GeneralRe: QM + AI = oo Pin
BillWoodruff16-Jan-23 20:35
professionalBillWoodruff16-Jan-23 20:35 
GeneralRe: QM + AI = oo Pin
BernardIE531716-Jan-23 20:58
BernardIE531716-Jan-23 20:58 
GeneralIs "New Year; New Me" ... Pin
OriginalGriff14-Jan-23 0:24
mveOriginalGriff14-Jan-23 0:24 
GeneralRe: Is "New Year; New Me" ... Pin
theoldfool14-Jan-23 2:04
professionaltheoldfool14-Jan-23 2:04 
GeneralOi Griff ! Pin
pkfox13-Jan-23 23:38
professionalpkfox13-Jan-23 23:38 
GeneralRe: Oi Griff ! Pin
Richard MacCutchan14-Jan-23 0:14
mveRichard MacCutchan14-Jan-23 0:14 
GeneralRe: Oi Griff ! Pin
pkfox14-Jan-23 0:40
professionalpkfox14-Jan-23 0:40 
GeneralRe: Oi Griff ! Pin
Richard MacCutchan14-Jan-23 0:52
mveRichard MacCutchan14-Jan-23 0:52 
GeneralRe: Oi Griff ! Pin
pkfox14-Jan-23 21:49
professionalpkfox14-Jan-23 21:49 
GeneralRe: Oi Griff ! Pin
Richard MacCutchan14-Jan-23 21:56
mveRichard MacCutchan14-Jan-23 21:56 
GeneralRe: Oi Griff ! Pin
pkfox14-Jan-23 23:59
professionalpkfox14-Jan-23 23:59 
GeneralRe: Oi Griff ! Pin
OriginalGriff14-Jan-23 4:07
mveOriginalGriff14-Jan-23 4:07 
Generalin praise of a gift from CodeProject Pin
BillWoodruff13-Jan-23 18:37
professionalBillWoodruff13-Jan-23 18:37 

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.