Browse Source

examples/interface/complex_interface.c: do not pack data when given NULL pointer

Nathalie Furmento 12 years ago
parent
commit
f060b6e137
1 changed files with 6 additions and 3 deletions
  1. 6 3
      examples/interface/complex_interface.c

+ 6 - 3
examples/interface/complex_interface.c

@@ -126,9 +126,12 @@ static int complex_pack_data(starpu_data_handle_t handle, unsigned node, void **
 		starpu_data_get_interface_on_node(handle, node);
 
 	*count = complex_get_size(handle);
-	*ptr = malloc(*count);
-	memcpy(*ptr, complex_interface->real, complex_interface->nx*sizeof(double));
-	memcpy(*ptr+complex_interface->nx*sizeof(double), complex_interface->imaginary, complex_interface->nx*sizeof(double));
+	if (ptr != NULL)
+	{
+		*ptr = malloc(*count);
+		memcpy(*ptr, complex_interface->real, complex_interface->nx*sizeof(double));
+		memcpy(*ptr+complex_interface->nx*sizeof(double), complex_interface->imaginary, complex_interface->nx*sizeof(double));
+	}
 
 	return 0;
 }