Re: [PATCH 3/9] perf, tools: Add support for reading JSON event files v3
From: Jiri Olsa
Date: Wed Jul 09 2014 - 18:20:43 EST
On Fri, Jun 27, 2014 at 04:15:58PM -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/