As part of the development team at MumbleTech.com, Janet has written a list manipulation library for C

Question:

As part of the development team at MumbleTech.com, Janet has written a list manipulation library for C that contains, among other things, the code in Figure 3.16.

typedef struct list_node { void* data; struct list_node* next; } list_node; list_node* insert (void* d, list_node* L) { list_node* t = (list_node*) malloc (sizeof (list_node)); t->data = d; t->next = L; %3D return t; list_node* reverse (list_node* L) { list_node* rtn = 0; while (L) { rtn = insert (L->data,

(a) Accustomed to Java, new team member Brad includes the following code in the main loop of his program:

Sadly, after running for a while, Brad’s program always runs out of memory and crashes. Explain what’s going wrong.

(b) After Janet patiently explains the problem to him, Brad gives it another try:

This seems to solve the insufficient memory problem, but where the program used to produce correct results (before running out of memory), now its output is strangely corrupted, and Brad goes back to Janet for advice. What will she tell him this time?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: