| ceed-vector.c (916593bb45df27de2596a307978bc45ad7db29a9) | ceed-vector.c (ad6481ce28fcfada16ee6d8a13bbacd137fe686a) |
|---|---|
| 1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3// 4// SPDX-License-Identifier: BSD-2-Clause 5// 6// This file is part of CEED: http://github.com/ceed 7 8#include <assert.h> --- 875 unchanged lines hidden (view full) --- 884 885 @param[in,out] vec CeedVector to destroy 886 887 @return An error code: 0 - success, otherwise - failure 888 889 @ref User 890**/ 891int CeedVectorDestroy(CeedVector *vec) { | 1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3// 4// SPDX-License-Identifier: BSD-2-Clause 5// 6// This file is part of CEED: http://github.com/ceed 7 8#include <assert.h> --- 875 unchanged lines hidden (view full) --- 884 885 @param[in,out] vec CeedVector to destroy 886 887 @return An error code: 0 - success, otherwise - failure 888 889 @ref User 890**/ 891int CeedVectorDestroy(CeedVector *vec) { |
| 892 if (!*vec || --(*vec)->ref_count > 0) return CEED_ERROR_SUCCESS; 893 | 892 if (!*vec || --(*vec)->ref_count > 0) { 893 *vec = NULL; 894 return CEED_ERROR_SUCCESS; 895 } |
| 894 if (((*vec)->state % 2) == 1) { 895 return CeedError((*vec)->ceed, CEED_ERROR_ACCESS, "Cannot destroy CeedVector, the writable access lock is in use"); 896 } 897 if ((*vec)->num_readers > 0) { 898 // LCOV_EXCL_START 899 return CeedError((*vec)->ceed, CEED_ERROR_ACCESS, "Cannot destroy CeedVector, a process has read access"); 900 // LCOV_EXCL_STOP 901 } 902 903 if ((*vec)->Destroy) CeedCall((*vec)->Destroy(*vec)); 904 905 CeedCall(CeedDestroy(&(*vec)->ceed)); 906 CeedCall(CeedFree(vec)); 907 return CEED_ERROR_SUCCESS; 908} 909 910/// @} | 896 if (((*vec)->state % 2) == 1) { 897 return CeedError((*vec)->ceed, CEED_ERROR_ACCESS, "Cannot destroy CeedVector, the writable access lock is in use"); 898 } 899 if ((*vec)->num_readers > 0) { 900 // LCOV_EXCL_START 901 return CeedError((*vec)->ceed, CEED_ERROR_ACCESS, "Cannot destroy CeedVector, a process has read access"); 902 // LCOV_EXCL_STOP 903 } 904 905 if ((*vec)->Destroy) CeedCall((*vec)->Destroy(*vec)); 906 907 CeedCall(CeedDestroy(&(*vec)->ceed)); 908 CeedCall(CeedFree(vec)); 909 return CEED_ERROR_SUCCESS; 910} 911 912/// @} |