[splint-discuss] incomplete deallocation
Greg White
pcguy11 at live.com
Mon Nov 10 17:31:30 PST 2008
> Date: Mon, 10 Nov 2008 07:04:21 -0800
> From: Michael.Wojcik at microfocus.com
> To: splint-discuss at cs.virginia.edu
> Subject: Re: [splint-discuss] incomplete deallocation
> A better way to initialize dynamically-allocated structures is with
> structure copy:
>
> static const nk_hdr nk_hdr0 = {0};
> ...
> n = malloc(sizeof *n);
> *n = nk_hdr0;
OK I made the changes you suggested but splint is now giving me the
following message:
Initializer block for nk_hdr0 has 1 field, but nk_hdr has 5 fields: 0
Initializer does not set every field in the structure. (Use -fullinitblock
to inhibit warning)
Code:
static const nk_hdr nk_hdr0 = {0};
nk_hdr *n = NULL;
n = (nk_hdr*) malloc(sizeof(*n));
if (n == NULL) {
printf("can't allocate memory for n\n");
return -1;
}
*n = nk_hdr0;
Did I do something wrong?
Thanks,
_________________________________________________________________
Stay up to date on your PC, the Web, and your mobile phone with Windows Live
http://clk.atdmt.com/MRT/go/119462413/direct/01/
More information about the splint-discuss
mailing list