Author: Stan Eisenstat
Subject: Re: [Cs223] malloc() in Qsort.c
Date: Tuesday, 31 Mar 2020, 15:47:46
> Message Posted By: Unknown > > May we use malloc() in Qsort.c in the context of > Deque *S1 = malloc(sizeof(Deque)); > OR > char **item = malloc(sizeof(char*)); ? No, nor do you need to. As you can see in Hwk4/example.c, Deque variables are defined as Deque queue; and their addresses are passed to Deque functions as in destroyD (&queue) All storage allocation involving Deques is done within Deque.c. And there is no reason to malloc() storage for a single char*. Conjecture: gcc complains when you pass queue instead of &queue to a Deque function and you are trying to avoid the error message. --Stan-PREV INDEX NEXT