Skip to content

Commit 7517d23

Browse files
committed
Merge branch 'feature/add-memory-limit' into develop
2 parents 84c0c62 + be3d30c commit 7517d23

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

PHPCtags.class.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -225,32 +225,9 @@ private function render($structs, $options)
225225

226226
public function export($file, $options)
227227
{
228-
// if the memory limit option is set and is valid, adjust memory
229-
if (isset($options['memory'])) {
230-
$memory_limit = trim($options['memory']);
231-
if ($this->isMemoryLimitValid($memory_limit)) {
232-
ini_set('memory_limit', $memory_limit);
233-
}
234-
}
235228
//@todo Check for existence
236229
$this->mFile = $file;
237230
$structs = $this->struct($this->mParser->parse(file_get_contents($this->mFile)), TRUE);
238231
return $this->render($structs, $options);
239232
}
240-
241-
private static function isMemoryLimitValid($memory_limit) {
242-
if ($memory_limit == "-1") {
243-
// no memory limit
244-
return true;
245-
} elseif (is_numeric($memory_limit) && $memory_limit > 0) {
246-
// memory limit provided in bytes
247-
return true;
248-
} elseif (preg_match("/\d+\s*[KMG]/", $memory_limit)) {
249-
// memory limit provided in human readable sizes
250-
// as specified here: http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
251-
return true;
252-
}
253-
254-
return false;
255-
}
256233
}

phpctags

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ if(!isset($options['fields'])) {
5353
$options['fields'] = str_split($options['fields']);
5454
}
5555

56+
// if the memory limit option is set and is valid, adjust memory
57+
if (isset($options['memory'])) {
58+
$memory_limit = trim($options['memory']);
59+
if (isMemoryLimitValid($memory_limit)) {
60+
ini_set('memory_limit', $memory_limit);
61+
}
62+
}
63+
5664
if(isset($options['append'])) {
5765
if ($options['append'] === FALSE || yes_or_no($options['append']) == 'yes') {
5866
$options['a'] = FALSE;
@@ -114,3 +122,19 @@ function yes_or_no($arg) {
114122
return false;
115123
}
116124
}
125+
126+
function isMemoryLimitValid($memory_limit) {
127+
if ($memory_limit == "-1") {
128+
// no memory limit
129+
return true;
130+
} elseif (is_numeric($memory_limit) && $memory_limit > 0) {
131+
// memory limit provided in bytes
132+
return true;
133+
} elseif (preg_match("/\d+\s*[KMG]/", $memory_limit)) {
134+
// memory limit provided in human readable sizes
135+
// as specified here: http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
136+
return true;
137+
}
138+
139+
return false;
140+
}

0 commit comments

Comments
 (0)