Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
EMACMemoryManager.cpp
00001 /* Copyright (c) 2018 ARM Limited 00002 * 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 */ 00015 00016 #include "EMACMemoryManager.h" 00017 00018 void EMACMemoryManager::copy_to_buf(emac_mem_buf_t *to_buf, const void *ptr, uint32_t len) 00019 { 00020 while (to_buf && len) { 00021 void *copy_to_ptr = get_ptr(to_buf); 00022 uint32_t copy_to_len = get_len(to_buf); 00023 00024 if (copy_to_len > len) { 00025 copy_to_len = len; 00026 len = 0; 00027 } else { 00028 len -= copy_to_len; 00029 } 00030 00031 memcpy(copy_to_ptr, ptr, copy_to_len); 00032 ptr = static_cast<const uint8_t *>(ptr) + copy_to_len; 00033 00034 to_buf = get_next(to_buf); 00035 } 00036 } 00037 00038 uint32_t EMACMemoryManager::copy_from_buf(void *ptr, uint32_t len, const emac_mem_buf_t *from_buf) const 00039 { 00040 uint32_t copied_len = 0; 00041 00042 while (from_buf && len) { 00043 void *copy_from_ptr = get_ptr(from_buf); 00044 uint32_t copy_from_len = get_len(from_buf); 00045 00046 if (copy_from_len > len) { 00047 copy_from_len = len; 00048 len = 0; 00049 } else { 00050 len -= copy_from_len; 00051 } 00052 00053 memcpy(ptr, copy_from_ptr, copy_from_len); 00054 ptr = static_cast<uint8_t *>(ptr) + copy_from_len; 00055 copied_len += copy_from_len; 00056 00057 from_buf = get_next(from_buf); 00058 } 00059 00060 return copied_len; 00061 } 00062
Generated on Tue Jul 12 2022 12:43:54 by
