Skip to content

Commit 4f42286

Browse files
authored
Add memprof_version() function (#66)
1 parent 87778a4 commit 4f42286

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

memprof.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,3 +1801,15 @@ PHP_FUNCTION(memprof_enabled_flags)
18011801
add_assoc_bool(return_value, "dump_on_limit", MEMPROF_G(profile_flags).dump_on_limit);
18021802
}
18031803
/* }}} */
1804+
1805+
/* {{{ proto string memprof_version()
1806+
Returns memprof version as a string */
1807+
PHP_FUNCTION(memprof_version)
1808+
{
1809+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) {
1810+
return;
1811+
}
1812+
1813+
RETURN_STRING(PHP_MEMPROF_VERSION);
1814+
}
1815+
/* }}} */

memprof.stub.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
function memprof_enabled(): bool {}
99

10-
/**
11-
* @return array{enabled: bool, native: bool, dump_on_limit: bool}
12-
*/
1310
function memprof_enabled_flags(): array {}
1411

1512
function memprof_enable(): bool {}
@@ -28,4 +25,4 @@ function memprof_dump_callgrind($handle): void {}
2825
*/
2926
function memprof_dump_pprof($handle): void {}
3027

31-
28+
function memprof_version(): string {}

memprof_arginfo.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 2ccb0e0939a9f13919125dd80717932d2737a359 */
2+
* Stub hash: afb43b76aec85442c7267aba0b45bfd00d5c8cf1 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memprof_enabled, 0, 0, _IS_BOOL, 0)
55
ZEND_END_ARG_INFO()
@@ -19,6 +19,9 @@ ZEND_END_ARG_INFO()
1919

2020
#define arginfo_memprof_dump_pprof arginfo_memprof_dump_callgrind
2121

22+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memprof_version, 0, 0, IS_STRING, 0)
23+
ZEND_END_ARG_INFO()
24+
2225

2326
ZEND_FUNCTION(memprof_enabled);
2427
ZEND_FUNCTION(memprof_enabled_flags);
@@ -27,6 +30,7 @@ ZEND_FUNCTION(memprof_disable);
2730
ZEND_FUNCTION(memprof_dump_array);
2831
ZEND_FUNCTION(memprof_dump_callgrind);
2932
ZEND_FUNCTION(memprof_dump_pprof);
33+
ZEND_FUNCTION(memprof_version);
3034

3135

3236
static const zend_function_entry ext_functions[] = {
@@ -37,5 +41,6 @@ static const zend_function_entry ext_functions[] = {
3741
ZEND_FE(memprof_dump_array, arginfo_memprof_dump_array)
3842
ZEND_FE(memprof_dump_callgrind, arginfo_memprof_dump_callgrind)
3943
ZEND_FE(memprof_dump_pprof, arginfo_memprof_dump_pprof)
44+
ZEND_FE(memprof_version, arginfo_memprof_version)
4045
ZEND_FE_END
4146
};

memprof_legacy_arginfo.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 2ccb0e0939a9f13919125dd80717932d2737a359 */
2+
* Stub hash: afb43b76aec85442c7267aba0b45bfd00d5c8cf1 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_memprof_enabled, 0, 0, 0)
55
ZEND_END_ARG_INFO()
@@ -18,6 +18,8 @@ ZEND_END_ARG_INFO()
1818

1919
#define arginfo_memprof_dump_pprof arginfo_memprof_dump_callgrind
2020

21+
#define arginfo_memprof_version arginfo_memprof_enabled
22+
2123

2224
ZEND_FUNCTION(memprof_enabled);
2325
ZEND_FUNCTION(memprof_enabled_flags);
@@ -26,6 +28,7 @@ ZEND_FUNCTION(memprof_disable);
2628
ZEND_FUNCTION(memprof_dump_array);
2729
ZEND_FUNCTION(memprof_dump_callgrind);
2830
ZEND_FUNCTION(memprof_dump_pprof);
31+
ZEND_FUNCTION(memprof_version);
2932

3033

3134
static const zend_function_entry ext_functions[] = {
@@ -36,5 +39,6 @@ static const zend_function_entry ext_functions[] = {
3639
ZEND_FE(memprof_dump_array, arginfo_memprof_dump_array)
3740
ZEND_FE(memprof_dump_callgrind, arginfo_memprof_dump_callgrind)
3841
ZEND_FE(memprof_dump_pprof, arginfo_memprof_dump_pprof)
42+
ZEND_FE(memprof_version, arginfo_memprof_version)
3943
ZEND_FE_END
4044
};

tests/memprof-version.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
--TEST--
2+
memprof_version()
3+
--FILE--
4+
<?php
5+
var_dump(memprof_version());
6+
--EXPECTF--
7+
string(%d) "%d.%d.%s"

0 commit comments

Comments
 (0)