Re: [PATCH] cpumask 5/10 rewrite cpumask.h - single bitmap based implementation

From: William Lee Irwin III
Date: Fri Jun 04 2004 - 22:31:14 EST


On Fri, Jun 04, 2004 at 07:51:31PM -0700, William Lee Irwin III wrote:
> ... and as someone pointed out:
> - if (!realloc(cpus, 2*upper))
> + if (!(cpus = realloc(cpus, 2*upper)))

--- nr_cpus.c.orig4 2004-06-04 20:25:36.000000000 -0700
+++ nr_cpus.c 2004-06-04 20:26:08.000000000 -0700
@@ -17,20 +17,24 @@

static int detect_nr_cpus(void)
{
- unsigned long *cpus = malloc(sizeof(long));
+ unsigned long *tmp, *cpus = malloc(sizeof(long));
size_t upper, middle, lower = sizeof(long);
int ret = -ENOMEM;

if (!cpus)
return -ENOMEM;
for (upper = lower; getaffinity(0, upper, cpus) < 0; upper *= 2) {
- if (!(cpus = realloc(cpus, 2*upper)))
+ if (!(tmp = realloc(cpus, 2*upper)))
goto out;
+ else
+ cpus = tmp;
}
while (lower < upper - 1) {
middle = (lower + upper)/2;
- if (!(cpus = realloc(cpus, middle)))
+ if (!(tmp = realloc(cpus, middle)))
goto out;
+ else
+ cpus = tmp;
if (getaffinity(0, middle, cpus) < 0)
lower = middle;
else
-
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/