lkml.org 
[lkml]   [2012]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 31/32] perf, tools: Default to cpu// for events v3
> > +static void str_append(char **s, int *len, const char *a)
> > +{
> > + int olen = *s ? strlen(*s) : 0;
> > + int nlen = olen + strlen(a) + 1;
> > + if (*len < nlen) {
> > + *len = *len * 2;
> > + if (*len < nlen)
> > + *len = nlen;
> > + *s = realloc(*s, *len);
> > + if (!*s)
> > + exit(ENOMEM);
>
> Rather use BUG_ON or event better return -ENOMEM.

Neither makes sense: the callers won't handle it and it's not a bug.
If you're out of memory in user space the only thing you can do is to
exit.

>
> > + if (olen == 0)
> > + **s = 0;
> > + }
> > + strcat(*s, a);
> > +}
>
> Could this one be moved to util/string.c in some generic form?

Ok.

-Andi

--
ak@linux.intel.com -- Speaking for myself only.


\
 
 \ /
  Last update: 2012-11-28 20:41    [W:0.729 / U:0.512 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site