Procházet zdrojové kódy

src/datawizard/malloc.c: starpu_malloc() return -ENOMEM and set pointer to NULL when failing to allocate buffer

Nathalie Furmento před 12 roky
rodič
revize
fbc535854e
2 změnil soubory, kde provedl 5 přidání a 2 odebrání
  1. 4 1
      src/datawizard/malloc.c
  2. 1 1
      tests/datawizard/allocate.c

+ 4 - 1
src/datawizard/malloc.c

@@ -99,8 +99,11 @@ int starpu_malloc(void **A, size_t dim)
 		freed = _starpu_memory_reclaim_generic(0, 0, 2*reclaim);
 		_STARPU_TRACE_END_MEMRECLAIM(0);
 		if (freed < dim)
+		{
 			// We could not reclaim enough memory
-			return 1;
+			*A = NULL;
+			return -ENOMEM;
+		}
 	}
 
 #ifndef STARPU_SIMGRID

+ 1 - 1
tests/datawizard/allocate.c

@@ -60,7 +60,7 @@ int main(int argc, char **argv)
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_malloc");
 
 	ret = starpu_malloc((void **)&buffer3, 1*1024*512);
-	STARPU_CHECK_RETURN_VALUE_IS(ret, 1, "starpu_malloc");
+	STARPU_CHECK_RETURN_VALUE_IS(ret, -ENOMEM, "starpu_malloc");
 
 #ifdef STARPU_DEVEL
 #warning we need to test the reclaim is working by calling starpu_free(buffer2) and re-trying to allocate buffer3