Lines Matching refs:size
153 …_segment* zend_mm_mem_mmap_realloc(zend_mm_storage *storage, zend_mm_segment* segment, size_t size) in zend_mm_mem_mmap_realloc() argument
159 ret = (zend_mm_segment*)mremap(segment, segment->size, segment, size, MREMAP_MAYMOVE); in zend_mm_mem_mmap_realloc()
161 ret = (zend_mm_segment*)mremap(segment, segment->size, size, MREMAP_MAYMOVE); in zend_mm_mem_mmap_realloc()
165 ret = storage->handlers->_alloc(storage, size); in zend_mm_mem_mmap_realloc()
167 memcpy(ret, segment, size > segment->size ? segment->size : size); in zend_mm_mem_mmap_realloc()
178 munmap((void*)segment, segment->size); in zend_mm_mem_mmap_free()
185 static zend_mm_segment* zend_mm_mem_mmap_anon_alloc(zend_mm_storage *storage, size_t size) in zend_mm_mem_mmap_anon_alloc() argument
187 …zend_mm_segment *ret = (zend_mm_segment*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MA… in zend_mm_mem_mmap_anon_alloc()
220 static zend_mm_segment* zend_mm_mem_mmap_zero_alloc(zend_mm_storage *storage, size_t size) in zend_mm_mem_mmap_zero_alloc() argument
222 …zend_mm_segment *ret = (zend_mm_segment*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zen… in zend_mm_mem_mmap_zero_alloc()
264 static zend_mm_segment* zend_mm_mem_win32_alloc(zend_mm_storage *storage, size_t size) in zend_mm_mem_win32_alloc() argument
266 return (zend_mm_segment*) HeapAlloc((HANDLE)storage->data, HEAP_NO_SERIALIZE, size); in zend_mm_mem_win32_alloc()
274 …segment* zend_mm_mem_win32_realloc(zend_mm_storage *storage, zend_mm_segment* segment, size_t size) in zend_mm_mem_win32_realloc() argument
276 return (zend_mm_segment*) HeapReAlloc((HANDLE)storage->data, HEAP_NO_SERIALIZE, segment, size); in zend_mm_mem_win32_realloc()
285 static zend_mm_segment* zend_mm_mem_malloc_alloc(zend_mm_storage *storage, size_t size) in zend_mm_mem_malloc_alloc() argument
287 return (zend_mm_segment*)malloc(size); in zend_mm_mem_malloc_alloc()
290 …mm_segment* zend_mm_mem_malloc_realloc(zend_mm_storage *storage, zend_mm_segment *ptr, size_t size) in zend_mm_mem_malloc_realloc() argument
292 return (zend_mm_segment*)realloc(ptr, size); in zend_mm_mem_malloc_realloc()
321 # define ZEND_MM_STORAGE_ALLOC(size) heap->storage->handlers->_alloc(heap->storage, size) argument
322 # define ZEND_MM_STORAGE_REALLOC(ptr, size) heap->storage->handlers->_realloc(heap->storage, ptr,… argument
351 size_t size; member
360 size_t size; member
429 size_t size; member
502 #define ZEND_MM_BLOCK(b, type, size) do { \ argument
503 size_t _size = (size); \
539 #define ZEND_MM_TRUE_SIZE(size) ((size<ZEND_MM_MIN_SIZE)?(ZEND_MM_ALIGNED_MIN_HEADER_SIZE):(ZEND… argument
613 (((char*)(ZEND_MM_DATA_OF(block))) + ((zend_mm_block*)(block))->debug.size)
619 ((zend_mm_block*)(block))->debug.size = (__size); \
632 ((zend_mm_block*)(block))->debug.size = (_size)
661 static void *_zend_mm_alloc_int(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR…
663 static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_F…
725 size_t size; in zend_mm_add_to_free_list() local
730 size = ZEND_MM_FREE_BLOCK_SIZE(mm_block); in zend_mm_add_to_free_list()
731 if (EXPECTED(!ZEND_MM_SMALL_SIZE(size))) { in zend_mm_add_to_free_list()
734 index = ZEND_MM_LARGE_BUCKET_INDEX(size); in zend_mm_add_to_free_list()
745 for (m = size << (ZEND_MM_NUM_BUCKETS - index); ; m <<= 1) { in zend_mm_add_to_free_list()
748 if (ZEND_MM_FREE_BLOCK_SIZE(prev) != size) { in zend_mm_add_to_free_list()
770 index = ZEND_MM_BUCKET_INDEX(size); in zend_mm_add_to_free_list()
923 heap->real_size -= segment->size; in zend_mm_del_segment()
937 size_t size = ZEND_MM_BLOCK_SIZE(mm_block); in zend_mm_free_cache() local
941 heap->cached -= size; in zend_mm_free_cache()
945 size += ZEND_MM_FREE_BLOCK_SIZE(mm_block); in zend_mm_free_cache()
949 size += ZEND_MM_FREE_BLOCK_SIZE(next_block); in zend_mm_free_cache()
952 ZEND_MM_BLOCK(mm_block, ZEND_MM_FREE_BLOCK, size); in zend_mm_free_cache()
973 static void zend_mm_random(unsigned char *buf, size_t size) /* {{{ */ in zend_mm_random() argument
995 BOOL ret = CryptGenRandom(hCryptProv, size, buf); in zend_mm_random()
998 while (i < size && buf[i] != 0) { in zend_mm_random()
1001 if (i == size) { in zend_mm_random()
1011 if (read(fd, buf, size) == size) { in zend_mm_random()
1012 while (i < size && buf[i] != 0) { in zend_mm_random()
1015 if (i == size) { in zend_mm_random()
1024 while (i < size) { in zend_mm_random()
1116 heap->size = 0; in zend_mm_startup_ex()
1248 (char*)q > (char*)segment + segment->size || in zend_mm_find_leaks()
1284 (char*)q > (char*)segment + segment->size || in zend_mm_check_leaks()
1296 leak.size = p->debug.size; in zend_mm_check_leaks()
1434 …put("OK (allocated on %s:%d, %d bytes)\n", p->debug.filename, p->debug.lineno, (int)p->debug.size); in zend_mm_check_ptr()
1568 (char*)q > (char*)segment + segment->size || in zend_mm_check_heap()
1627 size_t size, true_size, min_size, max_size; in zend_mm_shutdown() local
1631 size = 0; in zend_mm_shutdown()
1633 true_size = ZEND_MM_TRUE_SIZE(size); in zend_mm_shutdown()
1635 min_size = size; in zend_mm_shutdown()
1637 size++; in zend_mm_shutdown()
1639 true_size = ZEND_MM_TRUE_SIZE(size); in zend_mm_shutdown()
1643 max_size = size-1; in zend_mm_shutdown()
1647 max_size = size-1; in zend_mm_shutdown()
1650 size++; in zend_mm_shutdown()
1714 heap->real_size = heap->segments_list->size; in zend_mm_shutdown()
1715 heap->real_peak = heap->segments_list->size; in zend_mm_shutdown()
1720 heap->size = 0; in zend_mm_shutdown()
1725 …size_t block_size = heap->segments_list->size - ZEND_MM_ALIGNED_SEGMENT_SIZE - ZEND_MM_ALIGNED_HEA… in zend_mm_shutdown()
1746 size_t size) in zend_mm_safe_error() argument
1778 size); in zend_mm_safe_error()
1789 size); in zend_mm_safe_error()
1876 static void *_zend_mm_alloc_int(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_OR… in _zend_mm_alloc_int()
1879 size_t true_size = ZEND_MM_TRUE_SIZE(size); in _zend_mm_alloc_int()
1895 if (UNEXPECTED(true_size < size)) { in _zend_mm_alloc_int()
1909 ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0); in _zend_mm_alloc_int()
1972 …austed at %s:%d (tried to allocate %lu bytes)", heap->limit, __zend_filename, __zend_lineno, size); in _zend_mm_alloc_int()
1974 …ap, "Allowed memory size of %ld bytes exhausted (tried to allocate %lu bytes)", heap->limit, size); in _zend_mm_alloc_int()
1988 …d) at %s:%d (tried to allocate %lu bytes)", heap->real_size, __zend_filename, __zend_lineno, size); in _zend_mm_alloc_int()
1990 …_error(heap, "Out of memory (allocated %ld) (tried to allocate %lu bytes)", heap->real_size, size); in _zend_mm_alloc_int()
2000 segment->size = segment_size; in _zend_mm_alloc_int()
2043 ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 1); in _zend_mm_alloc_int()
2045 heap->size += true_size; in _zend_mm_alloc_int()
2046 if (heap->peak < heap->size) { in _zend_mm_alloc_int()
2047 heap->peak = heap->size; in _zend_mm_alloc_int()
2060 size_t size; in _zend_mm_free_int() local
2071 size = ZEND_MM_BLOCK_SIZE(mm_block); in _zend_mm_free_int()
2075 memset(ZEND_MM_DATA_OF(mm_block), 0x5a, mm_block->debug.size); in _zend_mm_free_int()
2079 if (EXPECTED(ZEND_MM_SMALL_SIZE(size)) && EXPECTED(heap->cached < ZEND_MM_CACHE_SIZE)) { in _zend_mm_free_int()
2080 size_t index = ZEND_MM_BUCKET_INDEX(size); in _zend_mm_free_int()
2085 heap->cached += size; in _zend_mm_free_int()
2097 heap->size -= size; in _zend_mm_free_int()
2099 next_block = ZEND_MM_BLOCK_AT(mm_block, size); in _zend_mm_free_int()
2102 size += ZEND_MM_FREE_BLOCK_SIZE(next_block); in _zend_mm_free_int()
2107 size += ZEND_MM_FREE_BLOCK_SIZE(mm_block); in _zend_mm_free_int()
2110 ZEND_MM_IS_GUARD_BLOCK(ZEND_MM_BLOCK_AT(mm_block, size))) { in _zend_mm_free_int()
2113 ZEND_MM_BLOCK(mm_block, ZEND_MM_FREE_BLOCK, size); in _zend_mm_free_int()
2119 static void *_zend_mm_realloc_int(zend_mm_heap *heap, void *p, size_t size ZEND_FILE_LINE_DC ZEND_F… in _zend_mm_realloc_int()
2130 return _zend_mm_alloc_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); in _zend_mm_realloc_int()
2136 true_size = ZEND_MM_TRUE_SIZE(size); in _zend_mm_realloc_int()
2140 if (UNEXPECTED(true_size < size)) { in _zend_mm_realloc_int()
2164 heap->size += (true_size - orig_size); in _zend_mm_realloc_int()
2166 ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0); in _zend_mm_realloc_int()
2186 ZEND_MM_SET_DEBUG_INFO(best_fit, size, 1, 0); in _zend_mm_realloc_int()
2191 memcpy(ptr, p, mm_block->debug.size); in _zend_mm_realloc_int()
2246 ZEND_MM_SET_DEBUG_INFO(mm_block, size, 0, 0); in _zend_mm_realloc_int()
2247 heap->size = heap->size + true_size - orig_size; in _zend_mm_realloc_int()
2248 if (heap->peak < heap->size) { in _zend_mm_realloc_int()
2249 heap->peak = heap->size; in _zend_mm_realloc_int()
2276 heap->real_size + segment_size - segment_copy->size > heap->limit) { in _zend_mm_realloc_int()
2285 …austed at %s:%d (tried to allocate %ld bytes)", heap->limit, __zend_filename, __zend_lineno, size); in _zend_mm_realloc_int()
2287 …ap, "Allowed memory size of %ld bytes exhausted (tried to allocate %ld bytes)", heap->limit, size); in _zend_mm_realloc_int()
2300 …d) at %s:%d (tried to allocate %ld bytes)", heap->real_size, __zend_filename, __zend_lineno, size); in _zend_mm_realloc_int()
2302 …_error(heap, "Out of memory (allocated %ld) (tried to allocate %ld bytes)", heap->real_size, size); in _zend_mm_realloc_int()
2306 heap->real_size += segment_size - segment->size; in _zend_mm_realloc_int()
2311 segment->size = segment_size; in _zend_mm_realloc_int()
2344 ZEND_MM_SET_DEBUG_INFO(mm_block, size, 1, 1); in _zend_mm_realloc_int()
2346 heap->size = heap->size + true_size - orig_size; in _zend_mm_realloc_int()
2347 if (heap->peak < heap->size) { in _zend_mm_realloc_int()
2348 heap->peak = heap->size; in _zend_mm_realloc_int()
2355 ptr = _zend_mm_alloc_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); in _zend_mm_realloc_int()
2357 memcpy(ptr, p, mm_block->debug.size); in _zend_mm_realloc_int()
2366 ZEND_API void *_zend_mm_alloc(zend_mm_heap *heap, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG… in _zend_mm_alloc()
2368 return _zend_mm_alloc_int(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); in _zend_mm_alloc()
2376 ZEND_API void *_zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_F… in _zend_mm_realloc()
2378 return _zend_mm_realloc_int(heap, ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); in _zend_mm_realloc()
2391 return mm_block->debug.size; in _zend_mm_block_size()
2418 ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) in _emalloc()
2423 return AG(mm_heap)->_malloc(size); in _emalloc()
2425 return _zend_mm_alloc_int(AG(mm_heap), size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); in _emalloc()
2439 ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC ZEND_FILE_LINE… in _erealloc() argument
2444 return AG(mm_heap)->_realloc(ptr, size); in _erealloc()
2446 …return _zend_mm_realloc_int(AG(mm_heap), ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL… in _erealloc()
2459 static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) in safe_address() argument
2467 "rm"(size), in safe_address()
2471 …(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset); in safe_address()
2479 static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) in safe_address() argument
2495 "rm"(size), in safe_address()
2501 …(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset); in safe_address()
2509 static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) in safe_address() argument
2511 zend_ulong64 res = (zend_ulong64)nmemb * (zend_ulong64)size + (zend_ulong64)offset; in safe_address()
2514 …(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset); in safe_address()
2522 static inline size_t safe_address(size_t nmemb, size_t size, size_t offset) in safe_address() argument
2524 size_t res = nmemb * size + offset; in safe_address()
2525 double _d = (double)nmemb * (double)size + (double)offset; in safe_address()
2529 …(E_ERROR, "Possible integer overflow in memory allocation (%zu * %zu + %zu)", nmemb, size, offset); in safe_address()
2537 ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_L… in _safe_emalloc() argument
2539 return emalloc_rel(safe_address(nmemb, size, offset)); in _safe_emalloc()
2542 ZEND_API void *_safe_malloc(size_t nmemb, size_t size, size_t offset) in _safe_malloc() argument
2544 return pemalloc(safe_address(nmemb, size, offset), 1); in _safe_malloc()
2547 ZEND_API void *_safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC… in _safe_erealloc() argument
2549 return erealloc_rel(ptr, safe_address(nmemb, size, offset)); in _safe_erealloc()
2552 ZEND_API void *_safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset) in _safe_realloc() argument
2554 return perealloc(ptr, safe_address(nmemb, size, offset), 1); in _safe_realloc()
2558 ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) in _ecalloc()
2566 p = _safe_emalloc(nmemb, size, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); in _ecalloc()
2571 memset(p, 0, size * nmemb); in _ecalloc()
2655 size_t usage = AG(mm_heap)->size; in zend_memory_usage()