raise_memory() now uses get_real_size(), duplicate function return_bytes() removed.

Issue discussed in 2202 (http://moodle.org/bugs/bug.php?op=show&bugid=2202).
Also seen as [email protected]/moodle--eduforge--1.3.3--patch-424
This commit is contained in:
martinlanghoff
2004-11-24 03:56:09 +00:00
parent 7a2596f854
commit 55f21d31e2
+2 -30
View File
@@ -3390,10 +3390,10 @@ function raise_memory_limit ($newlimit) {
if ($cur == -1){
return true; // unlimited mem!
}
$cur = return_bytes($cur);
$cur = get_real_size($cur);
}
$new = return_bytes($newlimit);
$new = get_real_size($newlimit);
if ($new > $cur) {
ini_set('memory_limit', $newlimit);
return true;
@@ -3401,34 +3401,6 @@ function raise_memory_limit ($newlimit) {
return false;
}
/**
* Function to transform strings like 5M or 128k into bytes.
* Taken from PHP's documentation (see entry for ini_get())
*
* Return integer (in bytes)
*
* @param value string with the value
*/
function return_bytes($val) {
$val = trim($val);
if (empty($val)) {
return '';
}
$last = $val{strlen($val)-1};
switch($last) {
case 'k':
case 'K':
return (int) $val * 1024;
break;
case 'm':
case 'M':
return (int) $val * 1048576;
break;
default:
return $val;
}
}
function unzip_show_status ($list,$removepath) {
//This function shows the results of the unzip execution
//depending of the value of the $CFG->zip, results will be