INGOR
Loading...
Searching...
No Matches
ytLib.h
1/*
2 ytLib.{h,c} : YT Lib common routines
3 Copyright (C) 2016-2021, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 See LICENSE.txt for details of the licensing agreement.
7*/
8
9#ifndef __YTLIB_H
10#define __YTLIB_H
11
12#include <stdio.h>
13
22extern FILE * ytLib_ERR;
23
24void ytLib_init();
25const char * ytLib_version();
26void * ytLib_malloc_regist(size_t size, const char * file, int line);
27void * ytLib_realloc_regist(void * ptr, size_t size, const char * file, int line);
28void ytLib_free_regist(void * ptr, const char * file, int line);
29void ytLib_registMemoryTable(void * ptr, size_t size, const char * file, int line, int type);
30void ytLib_removeMemoryTable(void * ptr, const char * file, int line, int type);
31
32void * ytLib_mallocBase(size_t size, const char * file, int line, const char * func, int code, int location);
33void * ytLib_reallocBase(void * ptr, size_t size, const char * file, int line, const char * func, int code, int location);
34
35#ifdef YTLIB_MEMCHECK
36
37#define malloc(x) ytLib_malloc_regist(x, __FILE__, __LINE__)
38#define realloc(x,y) ytLib_realloc_regist(x, y, __FILE__, __LINE__)
39#define free(x) ytLib_free_regist(x, __FILE__, __LINE__)
40#else
41#define malloc(x) ytLib_mallocBase(x,__FILE__,__LINE__,__func__,999999,0)
42#define realloc(x,y) ytLib_reallocBase(x,y,__FILE__,__LINE__,__func__,999999,0)
43#endif
44
45#define ytLib_malloc(x,y,z) ytLib_mallocBase(x,__FILE__,__LINE__,__func__,y,z)
46#define ytLib_realloc(x,y,z,a) ytLib_reallocBase(x,y,__FILE__,__LINE__,__func__,z,a)
47
48void ytLib_showMemoryTable(FILE * fp);
50
51void ytLib_assertBase(int value, char * file, int line);
52#define ytLib_assert(x) ytLib_assertBase(x, __FILE__, __LINE__)
53
54#endif /* __YTLIB_H */
size_t ytLib_getAllocMemory()
Returns the total size of allocated memory.
Definition ytLib.c:206
const char * ytLib_version()
Returns the ytLib Git version.
Definition ytLib.c:27
void ytLib_init()
Initializes the YT Lib library.
Definition ytLib.c:21
FILE * ytLib_ERR
File pointer for error output.
Definition ytLib.c:16
void ytLib_showMemoryTable(FILE *fp)
Prints the ytLib memory table.
Definition ytLib.c:177