Line data Source code
1 : /**
2 : * Copyright Notice:
3 : * Copyright 2021-2022 DMTF. All rights reserved.
4 : * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
5 : **/
6 :
7 : #include "library/debuglib.h"
8 : #include "hal/library/memlib.h"
9 :
10 246195 : void libspdm_copy_mem(void *dst_buf, size_t dst_len,
11 : const void *src_buf, size_t src_len)
12 : {
13 : volatile uint8_t* dst;
14 : const volatile uint8_t* src;
15 :
16 246195 : dst = (volatile uint8_t*) dst_buf;
17 246195 : src = (const volatile uint8_t*) src_buf;
18 :
19 246195 : if ((dst == NULL) || (src == NULL)) {
20 0 : LIBSPDM_ASSERT(0);
21 : }
22 246195 : if (((src < dst) && ((src + src_len) > dst)) || ((dst < src) && ((dst + src_len) > src))) {
23 0 : LIBSPDM_ASSERT(0);
24 : }
25 246195 : if (src_len > dst_len) {
26 0 : LIBSPDM_ASSERT(0);
27 : }
28 :
29 7044562 : while (src_len-- != 0) {
30 6798367 : *(dst++) = *(src++);
31 : }
32 246195 : }
|