Discussion:
A3q2
(too old to reply)
kun qian
2011-06-12 21:10:49 UTC
Permalink
from the assignment it says "...Otherwise, push the file name on the
stack, open it, and begin
processing it. ..." I don't see how processOneFIle would not need a
push routine that allocated memory. Am I misunderstanding something?
achow
2011-06-15 04:00:26 UTC
Permalink
Yeah, I must be missing something....if I want the node(s) that
was(were) created in that particular recursive call of processOneFile
to persist, it feels like I would need to create the nodes on the
heap......

Anyone have any ideas?
Post by kun qian
from the assignment it says "...Otherwise, push the file name on the
stack, open it, and begin
processing it. ..." I don't see how processOneFIle would not need a
push routine that allocated memory. Am I misunderstanding something?
achow
2011-06-15 04:01:29 UTC
Permalink
Am I allowed to decide on a predetermined maximum number of includes
(say, a million...?) and create all those nodes with empty fileName in
the main() routine?
Post by achow
Yeah, I must be missing something....if I want the node(s) that
was(were) created in that particular recursive call of processOneFile
to persist, it feels like I would need to create the nodes on the
heap......
Anyone have any ideas?
Post by kun qian
from the assignment it says "...Otherwise, push the file name on the
stack, open it, and begin
processing it. ..." I don't see how processOneFIle would not need a
push routine that allocated memory. Am I misunderstanding something?
Ashif Harji
2011-06-15 04:11:57 UTC
Permalink
No, preallocating the nodes is not allowed.

Let me give you a hint. Say you are in routine fred and you call routine
mary. Do the local variables you declared in fred remain on the stack
while you are in mary?

ashif
Post by achow
Am I allowed to decide on a predetermined maximum number of includes
(say, a million...?) and create all those nodes with empty fileName in
the main() routine?
Post by achow
Yeah, I must be missing something....if I want the node(s) that
was(were) created in that particular recursive call of processOneFile
to persist, it feels like I would need to create the nodes on the
heap......
Anyone have any ideas?
Post by kun qian
from the assignment it says "...Otherwise, push the file name on the
stack, open it, and begin
processing it. ..." I don't see how processOneFIle would not need a
push routine that allocated memory. Am I misunderstanding something?
achow
2011-06-15 07:17:08 UTC
Permalink
Yes, local variables declared in fred remain on the stack while inside
mary.

But while inside mary (which is really just another call of fred), I
am creating new nodes which I would like to persist even after mary is
finished (and even after fred is finished in fact)... I think I'm on
an entirely different train because every which way I attempt to think
about it, I'm always lead to the "heap"
Post by Ashif Harji
No, preallocating the nodes is not allowed.
Let me give you a hint.  Say you are in routine fred and you call routine
mary.  Do the local variables you declared in fred remain on the stack
while you are in mary?
ashif
Post by achow
Am I allowed to decide on a predetermined maximum number of includes
(say, a million...?) and create all those nodes with empty fileName in
the main() routine?
Post by achow
Yeah, I must be missing something....if I want the node(s) that
was(were) created in that particular recursive call of processOneFile
to persist, it feels like I would need to create the nodes on the
heap......
Anyone have any ideas?
Post by kun qian
from the assignment it says "...Otherwise, push the file name on the
stack, open it, and begin
processing it. ..." I don't see how processOneFIle would not need a
push routine that allocated memory. Am I misunderstanding something?
Loading...