-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.cpp
More file actions
54 lines (45 loc) · 839 Bytes
/
Copy pathfunction.cpp
File metadata and controls
54 lines (45 loc) · 839 Bytes
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
53
54
// Last modified: 2013-04-08 21:05:41
/**
* @file: function.cpp
* @author: tongjiancong([email protected])
* @date: 2012-08-27 11:27:15
* @brief:
**/
/* Talk is cheap, show me the code. */
/* Good luck and have fun. */
#include <cstdio>
#include <cstdlib>
#include "function.h"
void checkPointer(void *p, const char *filename, const int line)
{
if (p == NULL)
{
printf("null pointer in file %s, line %d\n", filename, line);
exit(-1);
}
}
void checkResource(void *p, const char *source_name)
{
if (p == NULL)
{
printf("Failed to open `%s`\n", source_name);
exit(-1);
}
}
void freeResource(void *pointer)
{
if (pointer)
{
free(pointer);
pointer = 0;
}
}
void closeResource(FILE *fHandler)
{
if (fHandler)
fclose(fHandler);
}
void testPoint(int line)
{
printf("Arrive here, line %d\n", line);
}