Переглянути джерело

use temporary variable for realloc

Nathalie Furmento 7 роки тому
батько
коміт
b5a08467da
3 змінених файлів з 4 додано та 4 видалено
  1. 1 1
      mpi/src/starpu_mpi_private.h
  2. 2 2
      src/common/barrier.c
  3. 1 1
      src/common/utils.h

+ 1 - 1
mpi/src/starpu_mpi_private.h

@@ -91,7 +91,7 @@ int _starpu_debug_rank;
 
 #define _STARPU_MPI_MALLOC(ptr, size) do { ptr = malloc(size); STARPU_MPI_ASSERT_MSG(ptr != NULL, "Cannot allocate %ld bytes\n", (long) size); } while (0)
 #define _STARPU_MPI_CALLOC(ptr, nmemb, size) do { ptr = calloc(nmemb, size); STARPU_MPI_ASSERT_MSG(ptr != NULL, "Cannot allocate %ld bytes\n", (long) (nmemb*size)); } while (0)
-#define _STARPU_MPI_REALLOC(ptr, size) do { ptr = realloc(ptr, size); STARPU_MPI_ASSERT_MSG(ptr != NULL, "Cannot reallocate %ld bytes\n", (long) size); } while (0)
+#define _STARPU_MPI_REALLOC(ptr, size) do { void *_new_ptr = realloc(ptr, size); STARPU_MPI_ASSERT_MSG(_new_ptr != NULL, "Cannot reallocate %ld bytes\n", (long) size); ptr = _new_ptr; } while (0)
 
 #ifdef STARPU_VERBOSE
 #  define _STARPU_MPI_COMM_DEBUG(ptr, count, datatype, node, tag, utag, comm, way) \

+ 2 - 2
src/common/barrier.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010,2011,2013,2014  CNRS
+ * Copyright (C) 2010,2011,2013,2014,2017  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -54,7 +54,7 @@ int _starpu_barrier_destroy(struct _starpu_barrier *barrier)
 	{
 		ret = _starpu_barrier_test(barrier);
 	}
-	_STARPU_DEBUG("reached_exit %d\n", barrier->reached_exit);
+	_STARPU_DEBUG("reached_exit %u\n", barrier->reached_exit);
 
 	STARPU_PTHREAD_MUTEX_DESTROY(&barrier->mutex);
 	STARPU_PTHREAD_MUTEX_DESTROY(&barrier->mutex_exit);

+ 1 - 1
src/common/utils.h

@@ -118,7 +118,7 @@
 
 #define _STARPU_MALLOC(ptr, size) do { ptr = malloc(size); STARPU_ASSERT_MSG(ptr != NULL, "Cannot allocate %ld bytes\n", (long) size); } while (0)
 #define _STARPU_CALLOC(ptr, nmemb, size) do { ptr = calloc(nmemb, size); STARPU_ASSERT_MSG(ptr != NULL, "Cannot allocate %ld bytes\n", (long) (nmemb*size)); } while (0)
-#define _STARPU_REALLOC(ptr, size) do { ptr = realloc(ptr, size); STARPU_ASSERT_MSG(ptr != NULL, "Cannot reallocate %ld bytes\n", (long) size); } while (0)
+#define _STARPU_REALLOC(ptr, size) do { void *_new_ptr = realloc(ptr, size); STARPU_ASSERT_MSG(_new_ptr != NULL, "Cannot reallocate %ld bytes\n", (long) size); ptr = _new_ptr;} while (0)
 
 #ifdef _MSC_VER
 #define _STARPU_IS_ZERO(a) (a == 0.0)