Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

##Stack vs heap##

Stack vs heap

I just wanted to comment on one thing. You have two functions, medianSmall() and medianLarge(), which are identical except that first allocates the array on the stack and the second allocates the array on the heap. There's no need for two functions. You should just use the one that allocates from the heap. There's no speed advantage to putting your array on the stack. The heap version is preferable because you don't have stack overflow problems that way.

##Stack vs heap##

I just wanted to comment on one thing. You have two functions, medianSmall() and medianLarge(), which are identical except that first allocates the array on the stack and the second allocates the array on the heap. There's no need for two functions. You should just use the one that allocates from the heap. There's no speed advantage to putting your array on the stack. The heap version is preferable because you don't have stack overflow problems that way.

Stack vs heap

I just wanted to comment on one thing. You have two functions, medianSmall() and medianLarge(), which are identical except that first allocates the array on the stack and the second allocates the array on the heap. There's no need for two functions. You should just use the one that allocates from the heap. There's no speed advantage to putting your array on the stack. The heap version is preferable because you don't have stack overflow problems that way.

Source Link
JS1
  • 28.8k
  • 3
  • 41
  • 83

##Stack vs heap##

I just wanted to comment on one thing. You have two functions, medianSmall() and medianLarge(), which are identical except that first allocates the array on the stack and the second allocates the array on the heap. There's no need for two functions. You should just use the one that allocates from the heap. There's no speed advantage to putting your array on the stack. The heap version is preferable because you don't have stack overflow problems that way.

lang-c

AltStyle によって変換されたページ (->オリジナル) /