-
Notifications
You must be signed in to change notification settings - Fork 222
/
Copy pathmyAlloc.hpp
52 lines (40 loc) · 1.16 KB
/
myAlloc.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _EMBEDDED_RPC__MYALLOC_H_
#define _EMBEDDED_RPC__MYALLOC_H_
#if defined(__cplusplus)
#include "erpc_port.h"
////////////////////////////////////////////////////////////////////////////////
// Classes
////////////////////////////////////////////////////////////////////////////////
class MyAlloc
{
public:
static void *my_malloc(size_t allocation_size)
{
allocated_++;
return erpc_malloc(allocation_size);
}
static void my_free(void *block)
{
allocated_--;
erpc_free(block);
}
static int allocated() { return allocated_; }
static void allocated(int allocated) { allocated_ = allocated; }
private:
static int allocated_;
};
////////////////////////////////////////////////////////////////////////////////
// Definitions
////////////////////////////////////////////////////////////////////////////////
#define erpc_malloc(X) ::MyAlloc::my_malloc(X)
#define erpc_free(X) ::MyAlloc::my_free((X))
#endif // __cplusplus
#endif // _EMBEDDED_RPC__MYALLOC_H_