1

Recently at an interview I was asked when is the BOOL *stop value allocated and where is the memory held: in the heap or the stack?

Any ideas?

jscs
  • 63,694
  • 13
  • 151
  • 195
Maddiee
  • 288
  • 2
  • 11
  • If by heap or stack, we mean dynamic or static memory? then it should be dynamic. Just a dynamic variable for the enumerator to know it should stop. I believe, its allocated in the function that calls the enumerations and should be released as soon as the enumeration is complete – Raj Oct 24 '17 at 19:10
  • the memory of `BOOL*` or the actual `BOOL` instance? – luk2302 Oct 24 '17 at 19:11
  • Probably BOOL and not the pointer.. but anyways both should be allocated at the same time isn't it ? – Maddiee Oct 24 '17 at 19:13
  • 2
    Strictly spoken the block does not *return a Boolean value*, it passes a **pointer** to a boolean value as a parameter. – vadian Oct 24 '17 at 19:13
  • Yes, u r correct :D – Maddiee Oct 24 '17 at 19:14

0 Answers0