diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /src/libkmip/kmip_memset.c | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libkmip/kmip_memset.c')
-rw-r--r-- | src/libkmip/kmip_memset.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/libkmip/kmip_memset.c b/src/libkmip/kmip_memset.c new file mode 100644 index 000000000..5c59e0876 --- /dev/null +++ b/src/libkmip/kmip_memset.c @@ -0,0 +1,59 @@ +/* Copyright (c) 2018 The Johns Hopkins University/Applied Physics Laboratory +* All Rights Reserved. + * + * This file is dual licensed under the terms of the Apache 2.0 License and + * the BSD 3-Clause License. See the LICENSE file in the root of this + * repository for more information. + */ + +#include "kmip_memset.h" + +#if defined __STDC_LIB_EXT1__ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include <string.h> + +void * +kmip_memset(void *ptr, int value, size_t size) +{ + if(ptr == NULL) + { + return(ptr); + } + + memset_s(ptr, size, value, size); + return(ptr); +} + +#else + +void * +kmip_base_memset(void *ptr, int value, size_t size) +{ + if(ptr != NULL) + { + unsigned char *index = (unsigned char*)ptr; + for(size_t i = 0; i < size; i++) + { + *index++ = (unsigned char)value; + } + } + + return(ptr); +} + +static void * +(* volatile kmip_indirect_memset)(void *, int, size_t) = kmip_base_memset; + +void * +kmip_memset(void *ptr, int value, size_t size) +{ + if(ptr != NULL) + { + kmip_indirect_memset(ptr, value, size); + } + + return(ptr); +} + +#endif |