Mbed OS Reference
Loading...
Searching...
No Matches
NanostackMemoryManager.h
1/* Copyright (c) 2017 ARM Limited
2 * SPDX-License-Identifier: Apache-2.0
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef NANOSTACK_MEMORY_MANAGER_H
18#define NANOSTACK_MEMORY_MANAGER_H
19
20#include "EMACMemoryManager.h"
21
22extern "C" void mbed_ns_heap_free_hook();
23
25
26 // Allow the hook to call the callback from the superclass
27 friend void mbed_ns_heap_free_hook();
28public:
29
30 virtual ~NanostackMemoryManager() = default;
31
32 emac_mem_buf_t *alloc_heap(uint32_t size, uint32_t align) override;
33
34 emac_mem_buf_t *alloc_pool(uint32_t size, uint32_t align) override;
35
36 uint32_t get_pool_alloc_unit(uint32_t align) const override;
37
38 uint32_t get_pool_size() const override;
39
40 void free(emac_mem_buf_t *buf) override;
41
42 uint32_t get_total_len(const emac_mem_buf_t *buf) const override;
43
44 void copy(emac_mem_buf_t *to_buf, const emac_mem_buf_t *from_buf) override;
45
46 void cat(emac_mem_buf_t *to_buf, emac_mem_buf_t *cat_buf) override;
47
48 emac_mem_buf_t *get_next(const emac_mem_buf_t *buf) const override;
49
50 void *get_ptr(const emac_mem_buf_t *buf) const override;
51
52 uint32_t get_len(const emac_mem_buf_t *buf) const override;
53
54 void set_len(emac_mem_buf_t *buf, uint32_t len) override;
55
56 Lifetime get_lifetime(const net_stack_mem_buf_t *buf) const override;
57};
58
59#endif /* NANOSTACK_MEMORY_MANAGER_H */
void set_len(emac_mem_buf_t *buf, uint32_t len) override
Sets the payload size of the buffer.
uint32_t get_pool_alloc_unit(uint32_t align) const override
Get memory buffer pool allocation unit.
emac_mem_buf_t * get_next(const emac_mem_buf_t *buf) const override
Returns the next buffer.
uint32_t get_pool_size() const override
Get memory buffer pool size.
void * get_ptr(const emac_mem_buf_t *buf) const override
Return pointer to the payload of the buffer.
void free(emac_mem_buf_t *buf) override
Free memory buffer chain.
emac_mem_buf_t * alloc_heap(uint32_t size, uint32_t align) override
Allocates memory buffer from the heap.
Lifetime get_lifetime(const net_stack_mem_buf_t *buf) const override
Gets the lifetime of the buffer.
uint32_t get_total_len(const emac_mem_buf_t *buf) const override
Return total length of a memory buffer chain.
uint32_t get_len(const emac_mem_buf_t *buf) const override
Return payload size of this individual buffer (NOT including any chained buffers)
emac_mem_buf_t * alloc_pool(uint32_t size, uint32_t align) override
Allocates memory buffer chain from a pool.
void copy(emac_mem_buf_t *to_buf, const emac_mem_buf_t *from_buf) override
Copy a memory buffer chain.
void cat(emac_mem_buf_t *to_buf, emac_mem_buf_t *cat_buf) override
Concatenate two memory buffer chains.