[PATCH v3 2/6] Introduce new filtering architecture

Eugene Syromiatnikov esyr at redhat.com
Wed Jul 12 15:46:37 UTC 2017


On Wed, Jul 05, 2017 at 04:47:18PM +0700, Nikolay Marchuk wrote:
> >> +void
> >> +set_filters_qualify_mode(struct filter **filters, unsigned int *nfilters)
> >> +{
> >> +	unsigned int i;
> >> +	for (i = 0; i < *nfilters - 1; ++i) {
> >> +		free_filter(*filters + i);
> >> +	}
> >> +	**filters = (*filters)[*nfilters - 1];
> >> +	*filters = xreallocarray(*filters, 1, sizeof(struct filter));
> > I'm pretty sure realloc() can't be expected to be able to handle re-allocating
> > memory hunk which is provided by pointer not pointing at the beginning
> > of the hunk. IOW, allocators are not expected to work with arbitrary pointers,
> > only with ones that are returned by those allocators.
> But pointer isn't changed between allocations.
Oops, I misread that part, sorry. It probably would be nice then to rewrite
the previous line as "(*filters)[0] = (*filters)[*nfilters - 1]", so even dumb
people like me don't have an option to miscomprehend that.




More information about the Strace-devel mailing list