]> granicus.if.org Git - php/commitdiff
Backporting memory_get_usage() from HEAD.
authorAndrey Hristov <andrey@php.net>
Thu, 6 Feb 2003 14:34:07 +0000 (14:34 +0000)
committerAndrey Hristov <andrey@php.net>
Thu, 6 Feb 2003 14:34:07 +0000 (14:34 +0000)
As far as the code is small there won't be any problems.

ext/standard/basic_functions.c
ext/standard/php_var.h
ext/standard/var.c

index a6d0040b36e18a8095f0ef3e57adae533e821bfa..ee97d0b87a770a429b2fe2a1041e40fba64e8f3a 100644 (file)
@@ -545,6 +545,9 @@ function_entry basic_functions[] = {
        PHP_FE(call_user_method_array,  second_arg_force_ref)
        PHP_FE(serialize,                                                                                                               NULL)                                                                                                                   
        PHP_FE(unserialize,                                                                                                             NULL)
+#if MEMORY_LIMIT
+       PHP_FE(memory_get_usage,                                                                                                        NULL)
+#endif
 
        PHP_FE(var_dump,                                                                                                                NULL)
        PHP_FE(var_export,                                                                                                              NULL)
index 796e1a19e338d748e51456c16d8d784f5598c0d1..0a195816aa42020be949bbe4279b9ccc490ccfde 100644 (file)
@@ -28,6 +28,9 @@ PHP_FUNCTION(var_export);
 PHP_FUNCTION(debug_zval_dump);
 PHP_FUNCTION(serialize);
 PHP_FUNCTION(unserialize);
+#if MEMORY_LIMIT
+PHP_FUNCTION(memory_get_usage);
+#endif
 
 void php_var_dump(zval **struc, int level TSRMLS_DC);
 void php_var_export(zval **struc, int level TSRMLS_DC);
index b7aa15c54c9fad8c29dfbaa7b97e755eed7b1737..1ab4fbc052a277c9bd823325b3ee0a46bfed35d6 100644 (file)
@@ -679,6 +679,15 @@ PHP_FUNCTION(unserialize)
 
 /* }}} */
 
+#if MEMORY_LIMIT
+/* {{{ proto int memory_get_usage()
+    Returns the allocated by PHP memory */
+PHP_FUNCTION(memory_get_usage) {
+       RETURN_LONG(AG(allocated_memory));
+}
+/* }}} */
+#endif
+
 /*
  * Local variables:
  * tab-width: 4