lkml.org 
[lkml]   [2012]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 07/12] perf kvm: handle realloc failures
Em Mon, Oct 08, 2012 at 02:34:55PM -0600, David Ahern escreveu:
> On 10/8/12 2:19 PM, Arnaldo Carvalho de Melo wrote:
> >>+ prev = event->vcpu;
> >> event->vcpu = realloc(event->vcpu,
> >> event->max_vcpu * sizeof(*event->vcpu));
> >> if (!event->vcpu) {
> >>+ free(prev);
> >> pr_err("Not enough memory\n");

> >Unfamiliar way of doing it, usually we do it like:

> > vcpu = realloc(event->vcpu, event->max_vcpu * sizeof(*event->vcpu));

> > if (!vcpu) {
> > pr_err("Not enough memory\n");
> > return -1;
> > }

> > event->vcpu = vcpu;

> >I.e. we don't trow away the old value of event->vcpu.
>
> right. Command is going to exit on a failure, so leaving the old
> value does not have any impact. I can leave the old if you want it
> for consistency.

I think do it in the familiar way for consistency.

- Arnaldo


\
 
 \ /
  Last update: 2012-10-09 00:01    [W:0.497 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site