Send a string array to a function by pointer or pointer-to-pointer with mem alloc? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to get a function name as a string in Python?How to find the 'sizeof' (a pointer pointing to an array)?How do function pointers in C work?C pointer to array/array of pointers disambiguationIs an array name a pointer?How to return a string value from a Bash functionTypedef function pointer?type checking across source filesANSI C : test return from calloc API - differ from windows and ibm cicsUnable to access Struct contents properly
How can god fight other gods?
Nose gear failure in single prop aircraft: belly landing or nose-gear up landing?
Why not use the yoke to control yaw, as well as pitch and roll?
AppleTVs create a chatty alternate WiFi network
Why is the change of basis formula counter-intuitive? [See details]
Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?
What does it mean that physics no longer uses mechanical models to describe phenomena?
Is there public access to the Meteor Crater in Arizona?
What does the writing on Poe's helmet say?
Relating to the President and obstruction, were Mueller's conclusions preordained?
What adaptations would allow standard fantasy dwarves to survive in the desert?
Resize vertical bars (absolute-value symbols)
Flight departed from the gate 5 min before scheduled departure time. Refund options
Is there hard evidence that the grant peer review system performs significantly better than random?
The test team as an enemy of development? And how can this be avoided?
Sally's older brother
What would you call this weird metallic apparatus that allows you to lift people?
I got rid of Mac OSX and replaced it with linux but now I can't change it back to OSX or windows
How many time has Arya actually used Needle?
Google .dev domain strangely redirects to https
Mounting TV on a weird wall that has some material between the drywall and stud
How does light 'choose' between wave and particle behaviour?
Why is std::move not [[nodiscard]] in C++20?
Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?
Send a string array to a function by pointer or pointer-to-pointer with mem alloc?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to get a function name as a string in Python?How to find the 'sizeof' (a pointer pointing to an array)?How do function pointers in C work?C pointer to array/array of pointers disambiguationIs an array name a pointer?How to return a string value from a Bash functionTypedef function pointer?type checking across source filesANSI C : test return from calloc API - differ from windows and ibm cicsUnable to access Struct contents properly
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Both of these functions fill the TCHAR sStringA and sStringB. The question is which one is preferred and more efficient in returning a result?
#include <tchar.h>
#include <Windows.h>
void FunctionA(TCHAR *sString1, DWORD dwLen)
_tcscpy_s(sString1, dwLen, L"String1");
return;
void FunctionB(TCHAR **sString2, DWORD dwLen)
*sString2 = (TCHAR*)calloc(dwLen, sizeof(TCHAR));
_tcscpy_s(*sString2, dwLen, L"String2");
return;
int main()
TCHAR *sStringA = (TCHAR*)calloc(100, sizeof(TCHAR));
TCHAR *sStringB = NULL;
FunctionA(sStringA, 100);
FunctionB(&sStringB, 100);
free(sStringA);
free(sStringB);
From my comment below, here is FunctionC:
void FunctionC(TCHAR **sString2, DWORD dwLenOut)
TCHAR sString[] = L"String2";
dwLenOut = (DWORD) _tcslen(sString) + 1;
*sString2 = (TCHAR*)calloc(dwLenOut, sizeof(TCHAR));
_tcscpy_s(*sString2, dwLenOut, sString);
return;
int main()
TCHAR *sStringC = NULL;
DWORD dwLen = 0;
FunctionC(&sStringC, dwLen);
c function pointers pass-by-reference
add a comment |
Both of these functions fill the TCHAR sStringA and sStringB. The question is which one is preferred and more efficient in returning a result?
#include <tchar.h>
#include <Windows.h>
void FunctionA(TCHAR *sString1, DWORD dwLen)
_tcscpy_s(sString1, dwLen, L"String1");
return;
void FunctionB(TCHAR **sString2, DWORD dwLen)
*sString2 = (TCHAR*)calloc(dwLen, sizeof(TCHAR));
_tcscpy_s(*sString2, dwLen, L"String2");
return;
int main()
TCHAR *sStringA = (TCHAR*)calloc(100, sizeof(TCHAR));
TCHAR *sStringB = NULL;
FunctionA(sStringA, 100);
FunctionB(&sStringB, 100);
free(sStringA);
free(sStringB);
From my comment below, here is FunctionC:
void FunctionC(TCHAR **sString2, DWORD dwLenOut)
TCHAR sString[] = L"String2";
dwLenOut = (DWORD) _tcslen(sString) + 1;
*sString2 = (TCHAR*)calloc(dwLenOut, sizeof(TCHAR));
_tcscpy_s(*sString2, dwLenOut, sString);
return;
int main()
TCHAR *sStringC = NULL;
DWORD dwLen = 0;
FunctionC(&sStringC, dwLen);
c function pointers pass-by-reference
2
The big time consumer here is the calloc, not the call FunctionA/B itself.
– Anders
Mar 22 at 12:08
What were your result when you benchmarked and profiled the code?
– Broman
Mar 22 at 12:11
1
Another possibility isTCHAR *FunctionD(DWORD dwLen)
called byTCHAR *sStringD = FunctionD(100)
which does less dereferencing and argument pushing. I could not reliably find any one to be faster than any other, and the difference is minute compared to thecalloc
requirement.
– Weather Vane
Mar 22 at 12:43
add a comment |
Both of these functions fill the TCHAR sStringA and sStringB. The question is which one is preferred and more efficient in returning a result?
#include <tchar.h>
#include <Windows.h>
void FunctionA(TCHAR *sString1, DWORD dwLen)
_tcscpy_s(sString1, dwLen, L"String1");
return;
void FunctionB(TCHAR **sString2, DWORD dwLen)
*sString2 = (TCHAR*)calloc(dwLen, sizeof(TCHAR));
_tcscpy_s(*sString2, dwLen, L"String2");
return;
int main()
TCHAR *sStringA = (TCHAR*)calloc(100, sizeof(TCHAR));
TCHAR *sStringB = NULL;
FunctionA(sStringA, 100);
FunctionB(&sStringB, 100);
free(sStringA);
free(sStringB);
From my comment below, here is FunctionC:
void FunctionC(TCHAR **sString2, DWORD dwLenOut)
TCHAR sString[] = L"String2";
dwLenOut = (DWORD) _tcslen(sString) + 1;
*sString2 = (TCHAR*)calloc(dwLenOut, sizeof(TCHAR));
_tcscpy_s(*sString2, dwLenOut, sString);
return;
int main()
TCHAR *sStringC = NULL;
DWORD dwLen = 0;
FunctionC(&sStringC, dwLen);
c function pointers pass-by-reference
Both of these functions fill the TCHAR sStringA and sStringB. The question is which one is preferred and more efficient in returning a result?
#include <tchar.h>
#include <Windows.h>
void FunctionA(TCHAR *sString1, DWORD dwLen)
_tcscpy_s(sString1, dwLen, L"String1");
return;
void FunctionB(TCHAR **sString2, DWORD dwLen)
*sString2 = (TCHAR*)calloc(dwLen, sizeof(TCHAR));
_tcscpy_s(*sString2, dwLen, L"String2");
return;
int main()
TCHAR *sStringA = (TCHAR*)calloc(100, sizeof(TCHAR));
TCHAR *sStringB = NULL;
FunctionA(sStringA, 100);
FunctionB(&sStringB, 100);
free(sStringA);
free(sStringB);
From my comment below, here is FunctionC:
void FunctionC(TCHAR **sString2, DWORD dwLenOut)
TCHAR sString[] = L"String2";
dwLenOut = (DWORD) _tcslen(sString) + 1;
*sString2 = (TCHAR*)calloc(dwLenOut, sizeof(TCHAR));
_tcscpy_s(*sString2, dwLenOut, sString);
return;
int main()
TCHAR *sStringC = NULL;
DWORD dwLen = 0;
FunctionC(&sStringC, dwLen);
c function pointers pass-by-reference
c function pointers pass-by-reference
edited Mar 22 at 12:30
JeffR
asked Mar 22 at 12:00
JeffRJeffR
150214
150214
2
The big time consumer here is the calloc, not the call FunctionA/B itself.
– Anders
Mar 22 at 12:08
What were your result when you benchmarked and profiled the code?
– Broman
Mar 22 at 12:11
1
Another possibility isTCHAR *FunctionD(DWORD dwLen)
called byTCHAR *sStringD = FunctionD(100)
which does less dereferencing and argument pushing. I could not reliably find any one to be faster than any other, and the difference is minute compared to thecalloc
requirement.
– Weather Vane
Mar 22 at 12:43
add a comment |
2
The big time consumer here is the calloc, not the call FunctionA/B itself.
– Anders
Mar 22 at 12:08
What were your result when you benchmarked and profiled the code?
– Broman
Mar 22 at 12:11
1
Another possibility isTCHAR *FunctionD(DWORD dwLen)
called byTCHAR *sStringD = FunctionD(100)
which does less dereferencing and argument pushing. I could not reliably find any one to be faster than any other, and the difference is minute compared to thecalloc
requirement.
– Weather Vane
Mar 22 at 12:43
2
2
The big time consumer here is the calloc, not the call FunctionA/B itself.
– Anders
Mar 22 at 12:08
The big time consumer here is the calloc, not the call FunctionA/B itself.
– Anders
Mar 22 at 12:08
What were your result when you benchmarked and profiled the code?
– Broman
Mar 22 at 12:11
What were your result when you benchmarked and profiled the code?
– Broman
Mar 22 at 12:11
1
1
Another possibility is
TCHAR *FunctionD(DWORD dwLen)
called by TCHAR *sStringD = FunctionD(100)
which does less dereferencing and argument pushing. I could not reliably find any one to be faster than any other, and the difference is minute compared to the calloc
requirement.– Weather Vane
Mar 22 at 12:43
Another possibility is
TCHAR *FunctionD(DWORD dwLen)
called by TCHAR *sStringD = FunctionD(100)
which does less dereferencing and argument pushing. I could not reliably find any one to be faster than any other, and the difference is minute compared to the calloc
requirement.– Weather Vane
Mar 22 at 12:43
add a comment |
2 Answers
2
active
oldest
votes
It is highly unlikely to be any more costly to pass a pointer to a pointer than it is to pass a pointer to a TCHAR
. The only significant difference between your two alternatives, performance-wise, is that B performs one extra address-of (&
) and one dereference (unary *
) operation, and although that makes B a tiny bit more costly in principle, the difference is unlikely to be noticeable.
Of course, the compiler could optimize the two calls to exactly the same code. It might even optimize away the calloc()
calls, though that's less likely.
Overall, it is unlikely to be worth your time to focus on micro-optimizations of this sort, unless possibly you've determined, by measurement, that the section of code containing them is too slow, and you cannot find an algorithmic improvement, and you've reason to believe that the specific operations you're trying to optimize make a significant contribution to that code's cost.
I just don't want to pass an entire character string to the function. Also, I created FunctionC above, which always has dwLen as 0?
– JeffR
Mar 22 at 12:27
@JeffR, you are not passing a character string -- an array -- to any of the function. You can't -- C has no mechanism by which you could do so. In particular, your call toFunctionA()
passes a pointer.
– John Bollinger
Mar 22 at 13:04
1
@JeffR, as for yourFunctionC
, it does not use the passed-in value of its second parameter, so that value is irrelevant. That function is somewhat more costly because of its_tcslen()
call, but you could rewrite to avoid a need for that, or the compiler might optimize it out. In any case, if that way you manage to allocate less memory then that version makes more efficient use of memory, but there's no reason to expect it to run faster than the others.
– John Bollinger
Mar 22 at 13:10
add a comment |
FunctionA
is slightly is more efficient, because it does less dereferencing.
1
Doesn't your compiler inline them?
– melpomene
Mar 22 at 12:14
Using VS 2017. Options are Default, Disable, Only Inline, Any Suitable. "Default" is the default option.
– JeffR
Mar 22 at 12:19
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55299186%2fsend-a-string-array-to-a-function-by-pointer-or-pointer-to-pointer-with-mem-allo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It is highly unlikely to be any more costly to pass a pointer to a pointer than it is to pass a pointer to a TCHAR
. The only significant difference between your two alternatives, performance-wise, is that B performs one extra address-of (&
) and one dereference (unary *
) operation, and although that makes B a tiny bit more costly in principle, the difference is unlikely to be noticeable.
Of course, the compiler could optimize the two calls to exactly the same code. It might even optimize away the calloc()
calls, though that's less likely.
Overall, it is unlikely to be worth your time to focus on micro-optimizations of this sort, unless possibly you've determined, by measurement, that the section of code containing them is too slow, and you cannot find an algorithmic improvement, and you've reason to believe that the specific operations you're trying to optimize make a significant contribution to that code's cost.
I just don't want to pass an entire character string to the function. Also, I created FunctionC above, which always has dwLen as 0?
– JeffR
Mar 22 at 12:27
@JeffR, you are not passing a character string -- an array -- to any of the function. You can't -- C has no mechanism by which you could do so. In particular, your call toFunctionA()
passes a pointer.
– John Bollinger
Mar 22 at 13:04
1
@JeffR, as for yourFunctionC
, it does not use the passed-in value of its second parameter, so that value is irrelevant. That function is somewhat more costly because of its_tcslen()
call, but you could rewrite to avoid a need for that, or the compiler might optimize it out. In any case, if that way you manage to allocate less memory then that version makes more efficient use of memory, but there's no reason to expect it to run faster than the others.
– John Bollinger
Mar 22 at 13:10
add a comment |
It is highly unlikely to be any more costly to pass a pointer to a pointer than it is to pass a pointer to a TCHAR
. The only significant difference between your two alternatives, performance-wise, is that B performs one extra address-of (&
) and one dereference (unary *
) operation, and although that makes B a tiny bit more costly in principle, the difference is unlikely to be noticeable.
Of course, the compiler could optimize the two calls to exactly the same code. It might even optimize away the calloc()
calls, though that's less likely.
Overall, it is unlikely to be worth your time to focus on micro-optimizations of this sort, unless possibly you've determined, by measurement, that the section of code containing them is too slow, and you cannot find an algorithmic improvement, and you've reason to believe that the specific operations you're trying to optimize make a significant contribution to that code's cost.
I just don't want to pass an entire character string to the function. Also, I created FunctionC above, which always has dwLen as 0?
– JeffR
Mar 22 at 12:27
@JeffR, you are not passing a character string -- an array -- to any of the function. You can't -- C has no mechanism by which you could do so. In particular, your call toFunctionA()
passes a pointer.
– John Bollinger
Mar 22 at 13:04
1
@JeffR, as for yourFunctionC
, it does not use the passed-in value of its second parameter, so that value is irrelevant. That function is somewhat more costly because of its_tcslen()
call, but you could rewrite to avoid a need for that, or the compiler might optimize it out. In any case, if that way you manage to allocate less memory then that version makes more efficient use of memory, but there's no reason to expect it to run faster than the others.
– John Bollinger
Mar 22 at 13:10
add a comment |
It is highly unlikely to be any more costly to pass a pointer to a pointer than it is to pass a pointer to a TCHAR
. The only significant difference between your two alternatives, performance-wise, is that B performs one extra address-of (&
) and one dereference (unary *
) operation, and although that makes B a tiny bit more costly in principle, the difference is unlikely to be noticeable.
Of course, the compiler could optimize the two calls to exactly the same code. It might even optimize away the calloc()
calls, though that's less likely.
Overall, it is unlikely to be worth your time to focus on micro-optimizations of this sort, unless possibly you've determined, by measurement, that the section of code containing them is too slow, and you cannot find an algorithmic improvement, and you've reason to believe that the specific operations you're trying to optimize make a significant contribution to that code's cost.
It is highly unlikely to be any more costly to pass a pointer to a pointer than it is to pass a pointer to a TCHAR
. The only significant difference between your two alternatives, performance-wise, is that B performs one extra address-of (&
) and one dereference (unary *
) operation, and although that makes B a tiny bit more costly in principle, the difference is unlikely to be noticeable.
Of course, the compiler could optimize the two calls to exactly the same code. It might even optimize away the calloc()
calls, though that's less likely.
Overall, it is unlikely to be worth your time to focus on micro-optimizations of this sort, unless possibly you've determined, by measurement, that the section of code containing them is too slow, and you cannot find an algorithmic improvement, and you've reason to believe that the specific operations you're trying to optimize make a significant contribution to that code's cost.
answered Mar 22 at 12:17
John BollingerJohn Bollinger
86.1k74280
86.1k74280
I just don't want to pass an entire character string to the function. Also, I created FunctionC above, which always has dwLen as 0?
– JeffR
Mar 22 at 12:27
@JeffR, you are not passing a character string -- an array -- to any of the function. You can't -- C has no mechanism by which you could do so. In particular, your call toFunctionA()
passes a pointer.
– John Bollinger
Mar 22 at 13:04
1
@JeffR, as for yourFunctionC
, it does not use the passed-in value of its second parameter, so that value is irrelevant. That function is somewhat more costly because of its_tcslen()
call, but you could rewrite to avoid a need for that, or the compiler might optimize it out. In any case, if that way you manage to allocate less memory then that version makes more efficient use of memory, but there's no reason to expect it to run faster than the others.
– John Bollinger
Mar 22 at 13:10
add a comment |
I just don't want to pass an entire character string to the function. Also, I created FunctionC above, which always has dwLen as 0?
– JeffR
Mar 22 at 12:27
@JeffR, you are not passing a character string -- an array -- to any of the function. You can't -- C has no mechanism by which you could do so. In particular, your call toFunctionA()
passes a pointer.
– John Bollinger
Mar 22 at 13:04
1
@JeffR, as for yourFunctionC
, it does not use the passed-in value of its second parameter, so that value is irrelevant. That function is somewhat more costly because of its_tcslen()
call, but you could rewrite to avoid a need for that, or the compiler might optimize it out. In any case, if that way you manage to allocate less memory then that version makes more efficient use of memory, but there's no reason to expect it to run faster than the others.
– John Bollinger
Mar 22 at 13:10
I just don't want to pass an entire character string to the function. Also, I created FunctionC above, which always has dwLen as 0?
– JeffR
Mar 22 at 12:27
I just don't want to pass an entire character string to the function. Also, I created FunctionC above, which always has dwLen as 0?
– JeffR
Mar 22 at 12:27
@JeffR, you are not passing a character string -- an array -- to any of the function. You can't -- C has no mechanism by which you could do so. In particular, your call to
FunctionA()
passes a pointer.– John Bollinger
Mar 22 at 13:04
@JeffR, you are not passing a character string -- an array -- to any of the function. You can't -- C has no mechanism by which you could do so. In particular, your call to
FunctionA()
passes a pointer.– John Bollinger
Mar 22 at 13:04
1
1
@JeffR, as for your
FunctionC
, it does not use the passed-in value of its second parameter, so that value is irrelevant. That function is somewhat more costly because of its _tcslen()
call, but you could rewrite to avoid a need for that, or the compiler might optimize it out. In any case, if that way you manage to allocate less memory then that version makes more efficient use of memory, but there's no reason to expect it to run faster than the others.– John Bollinger
Mar 22 at 13:10
@JeffR, as for your
FunctionC
, it does not use the passed-in value of its second parameter, so that value is irrelevant. That function is somewhat more costly because of its _tcslen()
call, but you could rewrite to avoid a need for that, or the compiler might optimize it out. In any case, if that way you manage to allocate less memory then that version makes more efficient use of memory, but there's no reason to expect it to run faster than the others.– John Bollinger
Mar 22 at 13:10
add a comment |
FunctionA
is slightly is more efficient, because it does less dereferencing.
1
Doesn't your compiler inline them?
– melpomene
Mar 22 at 12:14
Using VS 2017. Options are Default, Disable, Only Inline, Any Suitable. "Default" is the default option.
– JeffR
Mar 22 at 12:19
add a comment |
FunctionA
is slightly is more efficient, because it does less dereferencing.
1
Doesn't your compiler inline them?
– melpomene
Mar 22 at 12:14
Using VS 2017. Options are Default, Disable, Only Inline, Any Suitable. "Default" is the default option.
– JeffR
Mar 22 at 12:19
add a comment |
FunctionA
is slightly is more efficient, because it does less dereferencing.
FunctionA
is slightly is more efficient, because it does less dereferencing.
answered Mar 22 at 12:12
Mikhail VladimirovMikhail Vladimirov
11.4k12631
11.4k12631
1
Doesn't your compiler inline them?
– melpomene
Mar 22 at 12:14
Using VS 2017. Options are Default, Disable, Only Inline, Any Suitable. "Default" is the default option.
– JeffR
Mar 22 at 12:19
add a comment |
1
Doesn't your compiler inline them?
– melpomene
Mar 22 at 12:14
Using VS 2017. Options are Default, Disable, Only Inline, Any Suitable. "Default" is the default option.
– JeffR
Mar 22 at 12:19
1
1
Doesn't your compiler inline them?
– melpomene
Mar 22 at 12:14
Doesn't your compiler inline them?
– melpomene
Mar 22 at 12:14
Using VS 2017. Options are Default, Disable, Only Inline, Any Suitable. "Default" is the default option.
– JeffR
Mar 22 at 12:19
Using VS 2017. Options are Default, Disable, Only Inline, Any Suitable. "Default" is the default option.
– JeffR
Mar 22 at 12:19
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55299186%2fsend-a-string-array-to-a-function-by-pointer-or-pointer-to-pointer-with-mem-allo%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
The big time consumer here is the calloc, not the call FunctionA/B itself.
– Anders
Mar 22 at 12:08
What were your result when you benchmarked and profiled the code?
– Broman
Mar 22 at 12:11
1
Another possibility is
TCHAR *FunctionD(DWORD dwLen)
called byTCHAR *sStringD = FunctionD(100)
which does less dereferencing and argument pushing. I could not reliably find any one to be faster than any other, and the difference is minute compared to thecalloc
requirement.– Weather Vane
Mar 22 at 12:43