Skip to content

Zend headers #14552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Zend/zend_alloc: Return bool instead of zend_result for zend_set_memo…
…ry_limit()
  • Loading branch information
Girgias committed Jun 13, 2024
commit 531a989e7c5cb9f68f65e7e25675b9f0fa4cbfb6
8 changes: 4 additions & 4 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,7 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length)
return p;
}

ZEND_API zend_result zend_set_memory_limit(size_t memory_limit)
ZEND_API bool zend_set_memory_limit(size_t memory_limit)
{
#if ZEND_MM_LIMIT
zend_mm_heap *heap = AG(mm_heap);
Expand All @@ -2896,13 +2896,13 @@ ZEND_API zend_result zend_set_memory_limit(size_t memory_limit)
heap->cached_chunks_count--;
heap->real_size -= ZEND_MM_CHUNK_SIZE;
} while (memory_limit < heap->real_size);
return SUCCESS;
return true;
}
return FAILURE;
return false;
}
AG(mm_heap)->limit = memory_limit;
#endif
return SUCCESS;
return true;
}

ZEND_API bool zend_alloc_in_memory_limit_error_reporting(void)
Expand Down
3 changes: 1 addition & 2 deletions Zend/zend_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#define ZEND_ALLOC_H

#include "zend_portability.h"
#include "zend_types.h" /* For zend_result */
#include "../TSRM/TSRM.h"

#ifndef ZEND_MM_ALIGNMENT
Expand Down Expand Up @@ -214,7 +213,7 @@ ZEND_API ZEND_ATTRIBUTE_MALLOC char * __zend_strdup(const char *s);
#define perealloc2_recoverable_rel(ptr, size, copy_size, persistent) ((persistent)?realloc((ptr), (size)):erealloc2_recoverable_rel((ptr), (size), (copy_size)))
#define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s))

ZEND_API zend_result zend_set_memory_limit(size_t memory_limit);
ZEND_API bool zend_set_memory_limit(size_t memory_limit);
ZEND_API bool zend_alloc_in_memory_limit_error_reporting(void);

ZEND_API void start_memory_manager(void);
Expand Down
2 changes: 1 addition & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static PHP_INI_MH(OnChangeMemoryLimit)
} else {
value = Z_L(1)<<30; /* effectively, no limit */
}
if (zend_set_memory_limit(value) == FAILURE) {
if (!zend_set_memory_limit(value)) {
/* When the memory limit is reset to the original level during deactivation, we may be
* using more memory than the original limit while shutdown is still in progress.
* Ignore a failure for now, and set the memory limit when the memory manager has been
Expand Down
Loading