Messages in this thread | | | Date | Thu, 10 Jul 2014 00:20:07 +0200 | From | Jiri Olsa <> | Subject | Re: [PATCH 3/9] perf, tools: Add support for reading JSON event files v3 |
| |
On Fri, Jun 27, 2014 at 04:15:58PM -0700, Andi Kleen wrote: > From: Andi Kleen <ak@linux.intel.com> > > Add a parser for Intel style JSON event files. This allows > to use an Intel event list directly with perf. The Intel > event lists can be quite large and are too big to store > in unswappable kernel memory. > > The parser code knows how to convert the JSON fields > to perf fields. The conversion code is straight forward. > It knows (very little) Intel specific information, and can be easily > extended to handle fields for other CPUs. > > The parser code is partially shared with an independent parsing > library, which is 2-clause BSD licenced. To avoid any conflicts I marked > those files as BSD licenced too. As part of perf they become GPLv2.
SNIP
> + > +#include <stdio.h> > +#include <stdlib.h> > +#include <errno.h> > +#include <string.h> > +#include <ctype.h> > +#include "jsmn.h" > +#include "json.h" > +#include "jevents.h" > + > +static void addfield(char *map, char **dst, const char *sep, > + const char *a, jsmntok_t *bt) > +{ > + unsigned len = strlen(a) + 1 + strlen(sep); > + int olen = *dst ? strlen(*dst) : 0; > + int blen = bt ? json_len(bt) : 0; > + char *out; > + > + out = realloc(*dst, len + olen + blen); > + if (!out) > + return;
what happens if we fail to realloc?
jirka
| |