mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Don't inline "slow" and rarely used functions.
This commit is contained in:
parent
6d885e395c
commit
ac83eaef10
2 changed files with 34 additions and 27 deletions
|
@ -2792,6 +2792,37 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_handlers *handlers, void
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Out of memory\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZEND_API void * __zend_malloc(size_t len)
|
||||||
|
{
|
||||||
|
void *tmp = malloc(len);
|
||||||
|
if (EXPECTED(tmp)) {
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
zend_out_of_memory();
|
||||||
|
}
|
||||||
|
|
||||||
|
ZEND_API void * __zend_calloc(size_t nmemb, size_t len)
|
||||||
|
{
|
||||||
|
void *tmp = _safe_malloc(nmemb, len, 0);
|
||||||
|
memset(tmp, 0, nmemb * len);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZEND_API void * __zend_realloc(void *p, size_t len)
|
||||||
|
{
|
||||||
|
p = realloc(p, len);
|
||||||
|
if (EXPECTED(p)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
zend_out_of_memory();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local variables:
|
* Local variables:
|
||||||
* tab-width: 4
|
* tab-width: 4
|
||||||
|
|
|
@ -187,33 +187,9 @@ ZEND_API void ZEND_FASTCALL _efree_huge(void *, size_t size);
|
||||||
#define estrndup_rel(s, length) _estrndup((s), (length) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
#define estrndup_rel(s, length) _estrndup((s), (length) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||||
#define zend_mem_block_size_rel(ptr) _zend_mem_block_size((ptr) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
#define zend_mem_block_size_rel(ptr) _zend_mem_block_size((ptr) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_CC)
|
||||||
|
|
||||||
zend_always_inline static void * __zend_malloc(size_t len)
|
ZEND_API void * __zend_malloc(size_t len) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE(1);
|
||||||
{
|
ZEND_API void * __zend_calloc(size_t nmemb, size_t len) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE2(1,2);
|
||||||
void *tmp = malloc(len);
|
ZEND_API void * __zend_realloc(void *p, size_t len) ZEND_ATTRIBUTE_ALLOC_SIZE(2);
|
||||||
if (tmp) {
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "Out of memory\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
zend_always_inline static void * __zend_calloc(size_t nmemb, size_t len)
|
|
||||||
{
|
|
||||||
void *tmp = _safe_malloc(nmemb, len, 0);
|
|
||||||
memset(tmp, 0, nmemb * len);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
zend_always_inline static void * __zend_realloc(void *p, size_t len)
|
|
||||||
{
|
|
||||||
p = realloc(p, len);
|
|
||||||
if (p) {
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "Out of memory\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Selective persistent/non persistent allocation macros */
|
/* Selective persistent/non persistent allocation macros */
|
||||||
#define pemalloc(size, persistent) ((persistent)?__zend_malloc(size):emalloc(size))
|
#define pemalloc(size, persistent) ((persistent)?__zend_malloc(size):emalloc(size))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue