Skip to content

Commit bb81cbc

Browse files
committed
bug fix
1 parent c072b1f commit bb81cbc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

main.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
// ATTENTION !!!!!!
2727
// You can modify this to match your computer.
28-
#define MEM_SIZE (1*GB+500*MB)
28+
#define MEM_SIZE (1*GB+50*MB)
2929
#define DATA_N 20000000
3030

3131
#define uint unsigned int
@@ -44,13 +44,14 @@ uint random_uint(uint maxn)
4444

4545
int main()
4646
{
47+
_init();
4748
// -------- clock start ---------
4849
clock_t start, finish;
4950
double total_time;
5051
start = clock();
5152
// -------- clock start ----------
5253
#ifdef _z_memorypool_h_
53-
mem_size_t total_size = 0, cur_size = 0, cnt = 0;
54+
mem_size_t total_size = 0, cur_size = 0;
5455
#else
5556
unsigned long long total_size = 0, cur_size = 0, cnt = 0;
5657
#endif
@@ -70,21 +71,19 @@ int main()
7071
SHOW("Alloc Before: \n");
7172
#endif
7273

73-
total_size = 0; cnt = 0;
74+
total_size = 0;
7475
for (int j = 0; j < DATA_N; ++j)
7576
{
7677
cur_size = random_uint(200);
7778
total_size += cur_size;
78-
if (total_size >= MEM_SIZE) break;
7979
mem[j] = My_Malloc(cur_size);
80-
cnt++;
8180
}
8281

8382
#ifdef _z_memorypool_h_
8483
SHOW("Free Before: \n");
8584
#endif
8685

87-
for (int j = 0; j < cnt; ++j)
86+
for (int j = 0; j < DATA_N; ++j)
8887
My_Free(mem[j]);
8988
// MemoryPool_Clear(mp);
9089

0 commit comments

Comments
 (0)