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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
ac_buffer.h
00001 /* 00002 * Copyright (c) 2017, ARM Limited, All Rights Reserved 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00006 * not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 /** 00018 * \file ac_buffer.h 00019 * \copyright Copyright (c) ARM Ltd 2013 00020 * \author Donatien Garnier 00021 */ 00022 00023 /** \addtogroup ACore 00024 * @{ 00025 * \name Buffer 00026 * @{ 00027 */ 00028 00029 #ifndef ACORE_BUFFER_H_ 00030 #define ACORE_BUFFER_H_ 00031 00032 #ifdef __cplusplus 00033 extern "C" { 00034 #endif 00035 00036 #include "stdint.h" 00037 #include "stddef.h" 00038 #include "stdbool.h" 00039 00040 typedef struct __ac_buffer { 00041 const uint8_t *data; 00042 size_t size; 00043 struct __ac_buffer *pNext; 00044 } ac_buffer_t; 00045 00046 /** Initialize ac_buffer using underlying byte array, set ac_buffer's length to 0 (empty) 00047 * \param pBuf pointer to ac_buffer_t structure to initialize 00048 * \param data byte array to use 00049 * \param size size of byte array 00050 */ 00051 void ac_buffer_init(ac_buffer_t *pBuf, const uint8_t *data, size_t size); 00052 00053 /** Copy pBufIn to pBuf 00054 * \param pBuf pointer to ac_buffer_t structure to initialize 00055 * \param pBufIn the source buffer 00056 */ 00057 void ac_buffer_dup(ac_buffer_t *pBuf, const ac_buffer_t *pBufIn); 00058 00059 /** Get buffer's underlying byte array 00060 * \param pBuf pointer to ac_buffer_t structure 00061 * \return underlying array 00062 */ 00063 static inline const uint8_t *ac_buffer_data(const ac_buffer_t *pBuf) 00064 { 00065 return pBuf->data; 00066 } 00067 00068 /** Get buffer's size 00069 * \param pBuf pointer to ac_buffer_t structure 00070 * \return buffer's size 00071 */ 00072 static inline size_t ac_buffer_size(const ac_buffer_t *pBuf) 00073 { 00074 return pBuf->size; 00075 } 00076 00077 /** Get next buffer in chain 00078 * \param pBuf pointer to ac_buffer_t structure 00079 * \return pointer to next buffer 00080 */ 00081 static inline ac_buffer_t *ac_buffer_next(const ac_buffer_t *pBuf) 00082 { 00083 return pBuf->pNext; 00084 } 00085 00086 /** Set next buffer in chain 00087 * \param pBuf pointer to ac_buffer_t structure 00088 * \param pNextBuf pointer to next buffer (or NULL to break chain) 00089 */ 00090 static inline void ac_buffer_set_next(ac_buffer_t *pBuf, ac_buffer_t *pNextBuf) 00091 { 00092 pBuf->pNext = (ac_buffer_t *) pNextBuf; 00093 } 00094 00095 /** Append buffer to end of chain 00096 * \param pBuf pointer to ac_buffer_t structure 00097 * \param pAppBuf pointer to buffer to append to chain 00098 */ 00099 void ac_buffer_append(ac_buffer_t *pBuf, ac_buffer_t *pAppBuf); 00100 00101 /** Truncate pBuf to length bytes and save the remaining bytes in pEndBuf 00102 * \param pBuf The buffer to split (will be set to invalid state) 00103 * \param pStartBuf A new buffer at the head of the split 00104 * \param pEndBuf A new buffer at the tail of the split 00105 * \param length How long pStartBuf should be (if longer than pBuf, then pStartBuf will be pBuf) 00106 */ 00107 void ac_buffer_split(ac_buffer_t *pStartBuf, ac_buffer_t *pEndBuf, ac_buffer_t *pBuf, size_t length); 00108 00109 //Debug 00110 void ac_buffer_dump(ac_buffer_t *pBuf); 00111 00112 #ifdef __cplusplus 00113 } 00114 #endif 00115 00116 #endif /* ACORE_BUFFER_H_ */ 00117 00118 /** 00119 * @} 00120 * @} 00121 * */
Generated on Tue Jul 12 2022 13:54:00 by
