NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
Memory.h
1/************************************************************************************
2 * Copyright (C) 2023 *
3 * TETCOS, Bangalore. India *
4 * *
5 * Tetcos owns the intellectual property rights in the Product and its content. *
6 * The copying, redistribution, reselling or publication of any or all of the *
7 * Product or its content without express prior written consent of Tetcos is *
8 * prohibited. Ownership and / or any other right relating to the software and all *
9 * intellectual property rights therein shall remain at all times with Tetcos. *
10 * *
11 * Author: Shashi Kant Suman *
12 * *
13 * ---------------------------------------------------------------------------------*/
14#ifdef _WIN32
15#pragma comment(lib,"MemoryBlock.lib")
16#endif
17#define __STR2__(x) #x
18#define __STR1__(x) __STR2__(x)
19#define __LOC__ __FILE__ "("__STR1__(__LINE__)") : Warning Msg: "
20#ifdef _DEBUG
21#undef _strdup
22#undef calloc
23#undef malloc
24#undef free
25#undef realloc
26#undef _msize
27#endif
28#define _strdup(x) _strdup_dbg1(x,__LINE__,__FILE__)
29#define calloc(c,s) fnpAllocateMemory((size_t)(c),(s))
30#define malloc(s) fnpAllocateMemory(1,s)
31#define free(p) fnpFreeMemory(p)
32#define realloc(p,s) fnpReAllocateMemory(p,s)
33#define _msize(memory) fnmsize(memory)
34# define fnpAllocateMemory(count,size) fnpAllocateMemory_dbg(count,size,__LINE__,__FILE__)
35# define fnpReAllocateMemory(p,size) fnpReAllocateMemory_dbg(p,size,__LINE__,__FILE__)
36# define fnpFreeMemory(p) fnpFreeMemory_dbg(p,sizeof *(p),__LINE__,__FILE__)
37
38
39_declspec(dllexport) void* fnpAllocateMemory_dbg(size_t count, size_t size,int line,const char* file);
40_declspec(dllexport) void* fnpReAllocateMemory_dbg(void* p, size_t size,int line,const char* file);
41_declspec(dllexport) int fnpFreeMemory_dbg(void* p, size_t size, int line, const char* file);
42_declspec(dllexport) char* _strdup_dbg1(const char* str,int nline,const char* file);
43_declspec(dllexport) size_t fnmsize(void* memory);
44_declspec(dllexport) void netsim_enable_memcheck();
45_declspec(dllexport) bool netsim_is_memcheck_enable();
46_declspec(dllexport) bool is_all_ptr_valid();
47_declspec(dllexport) bool is_ptr_valid(void* p);
48