Skip to content

Commit aee8697

Browse files
Restyled by clang-format
1 parent 181c6ec commit aee8697

12 files changed

+2203
-2312
lines changed

duma.c

+1,577-1,589
Large diffs are not rendered by default.

example1.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include <stdlib.h>
22

3-
int main()
4-
{
5-
int *pi;
6-
int i;
3+
int main() {
4+
int *pi;
5+
int i;
76
#ifdef DUMA_EXPLICIT_INIT
8-
duma_init();
7+
duma_init();
98
#endif
10-
pi = (int*)malloc(10*sizeof(int));
11-
for(i=0; i<11; ++i)
12-
pi[i] = i; // this line should produce error with i == 10
13-
return 0;
9+
pi = (int *)malloc(10 * sizeof(int));
10+
for (i = 0; i < 11; ++i)
11+
pi[i] = i; // this line should produce error with i == 10
12+
return 0;
1413
}

example2.cpp

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#include <stdlib.h>
22

3-
int main()
4-
{
5-
int *pi;
6-
int i;
3+
int main() {
4+
int *pi;
5+
int i;
76
#ifdef DUMA_EXPLICIT_INIT
8-
duma_init();
7+
duma_init();
98
#endif
10-
pi = (int*)malloc(10*sizeof(int));
11-
for(i=0; i<10; ++i)
12-
pi[i] = i;
13-
return 0;
14-
// pi is not freed
15-
// that should produce a memory leak
16-
// without information on allocation source without including duma.h
9+
pi = (int *)malloc(10 * sizeof(int));
10+
for (i = 0; i < 10; ++i)
11+
pi[i] = i;
12+
return 0;
13+
// pi is not freed
14+
// that should produce a memory leak
15+
// without information on allocation source without including duma.h
1716
}

example3.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
#include <stdlib.h>
21
#include <duma.h>
2+
#include <stdlib.h>
33

4-
int main()
5-
{
6-
int *pi;
7-
int i;
4+
int main() {
5+
int *pi;
6+
int i;
87
#ifdef DUMA_EXPLICIT_INIT
9-
duma_init();
8+
duma_init();
109
#endif
11-
pi = (int*)malloc(10*sizeof(int));
12-
for(i=0; i<10; ++i)
13-
pi[i] = i;
14-
return 0;
15-
// pi is not freed
16-
// that should produce a memory leak
17-
// with information on allocation source - cause duma.h is included
10+
pi = (int *)malloc(10 * sizeof(int));
11+
for (i = 0; i < 10; ++i)
12+
pi[i] = i;
13+
return 0;
14+
// pi is not freed
15+
// that should produce a memory leak
16+
// with information on allocation source - cause duma.h is included
1817
}

example4.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
#include <stdlib.h>
21
#include <duma.h>
2+
#include <stdlib.h>
33

4-
int main()
5-
{
6-
int *pi;
7-
int i;
4+
int main() {
5+
int *pi;
6+
int i;
87
#ifdef DUMA_EXPLICIT_INIT
9-
duma_init();
8+
duma_init();
109
#endif
11-
pi = (int*)malloc(10*sizeof(int));
12-
for(i=0; i<10; ++i)
13-
pi[i] = i;
14-
delete pi; // this line should produce error, cause pi was allocated with malloc()
15-
return 0;
10+
pi = (int *)malloc(10 * sizeof(int));
11+
for (i = 0; i < 10; ++i)
12+
pi[i] = i;
13+
delete pi; // this line should produce error, cause pi was allocated with
14+
// malloc()
15+
return 0;
1616
}

example5.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#include <dumapp.h>
22

3-
int main()
4-
{
5-
int *pi;
6-
int i;
3+
int main() {
4+
int *pi;
5+
int i;
76
#ifdef DUMA_EXPLICIT_INIT
8-
duma_init();
7+
duma_init();
98
#endif
10-
pi = new int[10];
11-
for(i=0; i<10; ++i)
12-
pi[i] = i;
13-
delete []pi;
14-
return 0;
15-
// should run fine
9+
pi = new int[10];
10+
for (i = 0; i < 10; ++i)
11+
pi[i] = i;
12+
delete[] pi;
13+
return 0;
14+
// should run fine
1615
}

example6.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
int main()
2-
{
3-
int *pi;
4-
int i;
1+
int main() {
2+
int *pi;
3+
int i;
54
#ifdef DUMA_EXPLICIT_INIT
6-
duma_init();
5+
duma_init();
76
#endif
8-
pi = new int[10];
9-
for(i=0; i<10; ++i)
10-
pi[i] = i;
11-
delete []pi;
12-
return 0;
13-
// should run fine
7+
pi = new int[10];
8+
for (i = 0; i < 10; ++i)
9+
pi[i] = i;
10+
delete[] pi;
11+
return 0;
12+
// should run fine
1413
}

example7.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
int main()
2-
{
3-
int *pi;
4-
int i;
1+
int main() {
2+
int *pi;
3+
int i;
54
#ifdef DUMA_EXPLICIT_INIT
6-
duma_init();
5+
duma_init();
76
#endif
8-
pi = new int[10];
9-
for(i=0; i<10; ++i)
10-
pi[i] = i;
11-
delete pi; // this line should produce error, cause pi was allocated with new[]()
12-
// unable to report allocation source - without including dumapp.h
13-
return 0;
7+
pi = new int[10];
8+
for (i = 0; i < 10; ++i)
9+
pi[i] = i;
10+
delete pi; // this line should produce error, cause pi was allocated with
11+
// new[]()
12+
// unable to report allocation source - without including dumapp.h
13+
return 0;
1414
}

example8.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#include <dumapp.h>
22

3-
int main()
4-
{
5-
int *pi;
6-
int i;
3+
int main() {
4+
int *pi;
5+
int i;
76
#ifdef DUMA_EXPLICIT_INIT
8-
duma_init();
7+
duma_init();
98
#endif
10-
pi = new int[10];
11-
for(i=0; i<10; ++i)
12-
pi[i] = i;
13-
delete pi; // this line should produce error, cause pi was allocated with new[]()
14-
// allocation source should be reported, cause dumapp.h is included
15-
return 0;
9+
pi = new int[10];
10+
for (i = 0; i < 10; ++i)
11+
pi[i] = i;
12+
delete pi; // this line should produce error, cause pi was allocated with
13+
// new[]()
14+
// allocation source should be reported, cause dumapp.h is included
15+
return 0;
1616
}

0 commit comments

Comments
 (0)