Re: [PATCH 3/8] perf tools: Add formula-* parsing support for events

From: David Ahern
Date: Fri May 03 2013 - 11:08:09 EST


On 5/1/13 9:15 AM, Jiri Olsa wrote:
+static char **formula_add(char **f, char *new)
+{
+ int i;
+#define FORMULAS_CNT 20
+
+ if (!f) {
+ f = zalloc(sizeof(char *) * FORMULAS_CNT + 1);
+ if (!f)
+ return NULL;
+ }
+
+ for (i = 0; f[i] && (i < FORMULAS_CNT); i++);
+
+ if (i == FORMULAS_CNT) {
+ pr_err("Too many formula defined, max = %d\n",
+ FORMULAS_CNT);
+ return NULL;
+ }

Why have an array of arbitrary limit versus a linked list?

David
--
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/