Re: [PATCH 2/5] annotations: Add position information to various calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



> > +struct srcpos *
> > +srcpos_copy_all(struct srcpos *pos)
> > +{
> > +	struct srcpos *pos_new;
> > +	struct srcfile_state *srcfile_state;
> > +
> > +	if (!pos)
> > +		return NULL;
> > +
> > +	pos_new = srcpos_copy(pos);
> > +
> > +	if (pos_new) {
> > +		/* allocate without free */
> > +		srcfile_state = xmalloc(sizeof(struct srcfile_state));
> > +		memcpy(srcfile_state, pos->file, sizeof(struct srcfile_state));
> > +
> > +		pos_new->file = srcfile_state;
> > +	}
> > +
> > +	return pos_new;
> > +}
>
> I don't really see a reason we'd need both a deep and a shallow copy.
> If you need a deep copy, I'd suggest just changing srcpos_copy() to do
> that.

The deep copy is needed due to the treatment of #includes.  The following
function overwrites the file name information:

void srcpos_set_line(char *f, int l)
{
        current_srcfile->name = f;
        current_srcfile->lineno = l;
}

srcpos_combine doesn't need to use the deep copy, because the result gets
copied again.  Maybe this is not a big issue or there is a better way to
solve this.

julia
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux