Easy c debugging question

Joerg Sonnenberger joerg at britannica.bec.de
Tue Mar 29 18:48:24 PST 2005


On Tue, Mar 29, 2005 at 06:30:49PM -0800, walt wrote:
> 
> 
> On Wed, 30 Mar 2005, Joerg Sonnenberger wrote:
> 
> > On Tue, Mar 29, 2005 at 04:10:35PM -0800, Matthew Dillon wrote:
> > >     Umm.  Try the initialized pointer being passed to
> > >     kinfo_get_sched_cputime().
> 
> > Right, kinfo_get_sched_cputime(&cputime), with cputime being
> > a local variable of type struct kinfo_cputime. That's another mistake :)
> 
> You Big Kids. please take pity on us bonehead Little Kids!  Is the 'mistake'
> in my original c code?  I wouldn't doubt for a second that I made a mistake,
> (I'm quite sure I did) but I can't tell from the above just what my mistake
> was.

You should do:
	struct kinfo_cputime k;
	kinfo_get_sched_cputime(&k);

The function does not allocate the storage.

Joerg





More information about the Users mailing list