Skip to content

Commit a83cc9d

Browse files
Zend/zend_alloc: use bool and make internal variable static (#8230)
* Zend/zend_alloc: make zend_mm_use_huge_pages static This is an internal variable and it should not be exported. * Zend/zend_alloc: convert zend_mm_use_huge_pages to bool * Zend/zend_alloc: convert has_free_pages to bool * Zend/zend_alloc: convert empty to bool
1 parent 3b9af50 commit a83cc9d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Zend/zend_alloc.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
# include "win32/winutil.h"
7070
#endif
7171

72+
#include <stdbool.h>
7273
#include <stdio.h>
7374
#include <stdlib.h>
7475
#include <string.h>
@@ -196,7 +197,7 @@ typedef struct _zend_mm_free_slot zend_mm_free_slot;
196197
typedef struct _zend_mm_chunk zend_mm_chunk;
197198
typedef struct _zend_mm_huge_list zend_mm_huge_list;
198199

199-
int zend_mm_use_huge_pages = 0;
200+
static bool zend_mm_use_huge_pages = false;
200201

201202
/*
202203
* Memory is retrieved from OS by chunks of fixed size 2MB.
@@ -1912,7 +1913,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
19121913
int page_num;
19131914
zend_mm_page_info info;
19141915
uint32_t i, free_counter;
1915-
int has_free_pages;
1916+
bool has_free_pages;
19161917
size_t collected = 0;
19171918

19181919
#if ZEND_MM_CUSTOM
@@ -1922,7 +1923,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
19221923
#endif
19231924

19241925
for (i = 0; i < ZEND_MM_BINS; i++) {
1925-
has_free_pages = 0;
1926+
has_free_pages = false;
19261927
p = heap->free_slot[i];
19271928
while (p != NULL) {
19281929
chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(p, ZEND_MM_CHUNK_SIZE);
@@ -1941,7 +1942,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
19411942
ZEND_ASSERT(ZEND_MM_SRUN_BIN_NUM(info) == i);
19421943
free_counter = ZEND_MM_SRUN_FREE_COUNTER(info) + 1;
19431944
if (free_counter == bin_elements[i]) {
1944-
has_free_pages = 1;
1945+
has_free_pages = true;
19451946
}
19461947
chunk->map[page_num] = ZEND_MM_SRUN_EX(i, free_counter);
19471948
p = p->next_free_slot;
@@ -2025,7 +2026,7 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
20252026

20262027
static zend_long zend_mm_find_leaks_small(zend_mm_chunk *p, uint32_t i, uint32_t j, zend_leak_info *leak)
20272028
{
2028-
int empty = 1;
2029+
bool empty = true;
20292030
zend_long count = 0;
20302031
int bin_num = ZEND_MM_SRUN_BIN_NUM(p->map[i]);
20312032
zend_mm_debug_info *dbg = (zend_mm_debug_info*)((char*)p + ZEND_MM_PAGE_SIZE * i + bin_data_size[bin_num] * (j + 1) - ZEND_MM_ALIGNED_SIZE(sizeof(zend_mm_debug_info)));
@@ -2038,7 +2039,7 @@ static zend_long zend_mm_find_leaks_small(zend_mm_chunk *p, uint32_t i, uint32_t
20382039
dbg->filename = NULL;
20392040
dbg->lineno = 0;
20402041
} else {
2041-
empty = 0;
2042+
empty = false;
20422043
}
20432044
}
20442045
j++;
@@ -2869,7 +2870,7 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals)
28692870

28702871
tmp = getenv("USE_ZEND_ALLOC_HUGE_PAGES");
28712872
if (tmp && ZEND_ATOL(tmp)) {
2872-
zend_mm_use_huge_pages = 1;
2873+
zend_mm_use_huge_pages = true;
28732874
}
28742875
alloc_globals->mm_heap = zend_mm_init();
28752876
}

0 commit comments

Comments
 (0)