Lines Matching refs:ptr
312 void *ptr; member
429 …void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, flags /*| MAP_POPULATE | MAP_HUGETLB*/, ZEND_… in zend_mm_mmap_fixed()
431 if (ptr == MAP_FAILED) { in zend_mm_mmap_fixed()
436 } else if (ptr != addr) { in zend_mm_mmap_fixed()
437 if (munmap(ptr, size) != 0) { in zend_mm_mmap_fixed()
444 return ptr; in zend_mm_mmap_fixed()
452 void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap() local
454 if (ptr == NULL) { in zend_mm_mmap()
460 return ptr; in zend_mm_mmap()
462 void *ptr; in zend_mm_mmap()
466 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0); in zend_mm_mmap()
467 if (ptr != MAP_FAILED) { in zend_mm_mmap()
468 return ptr; in zend_mm_mmap()
473 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, ZEND_MM_FD, 0); in zend_mm_mmap()
475 if (ptr == MAP_FAILED) { in zend_mm_mmap()
481 return ptr; in zend_mm_mmap()
666 void *ptr = zend_mm_mmap(size); local
668 if (ptr == NULL) {
670 } else if (ZEND_MM_ALIGNED_OFFSET(ptr, alignment) == 0) {
673 madvise(ptr, size, MADV_HUGEPAGE);
676 return ptr;
681 zend_mm_munmap(ptr, size);
682 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
684 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
685 zend_mm_munmap(ptr, size + alignment - REAL_PAGE_SIZE);
686 ptr = zend_mm_mmap_fixed((void*)((char*)ptr + (alignment - offset)), size);
687 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
689 zend_mm_munmap(ptr, size);
692 return ptr;
694 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
697 zend_mm_munmap(ptr, offset);
698 ptr = (char*)ptr + offset;
702 zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
706 madvise(ptr, size, MADV_HUGEPAGE);
710 return ptr;
718 void *ptr = heap->storage->handlers.chunk_alloc(heap->storage, size, alignment); local
719 …ZEND_ASSERT(((zend_uintptr_t)((char*)ptr + (alignment-1)) & (alignment-1)) == (zend_uintptr_t)ptr);
720 return ptr;
769 void *ptr = mremap(addr, old_size, new_size, 0); local
770 if (ptr == MAP_FAILED) {
774 ZEND_ASSERT(ptr == addr);
804 static size_t zend_mm_get_huge_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
806 static void zend_mm_free_huge(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
809 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s…
811 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1031 …void *ptr = zend_mm_alloc_pages(heap, pages_count, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORI… local
1033 …void *ptr = zend_mm_alloc_pages(heap, pages_count ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELA… local
1043 return ptr;
1262 static zend_always_inline void zend_mm_free_small(zend_mm_heap *heap, void *ptr, int bin_num) argument
1272 …zend_mm_debug_info *dbg = (zend_mm_debug_info*)((char*)ptr + bin_data_size[bin_num] - ZEND_MM_ALIG…
1277 p = (zend_mm_free_slot*)ptr;
1287 static zend_always_inline zend_mm_debug_info *zend_mm_get_debug_info(zend_mm_heap *heap, void *ptr) argument
1289 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1295 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1301 …return (zend_mm_debug_info*)((char*)ptr + bin_data_size[bin_num] - ZEND_MM_ALIGNED_SIZE(sizeof(zen…
1305 …return (zend_mm_debug_info*)((char*)ptr + ZEND_MM_PAGE_SIZE * pages_count - ZEND_MM_ALIGNED_SIZE(s…
1312 void *ptr; local
1326 …ptr = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_…
1328 dbg = zend_mm_get_debug_info(heap, ptr);
1335 return ptr;
1337 ptr = zend_mm_alloc_large(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1339 dbg = zend_mm_get_debug_info(heap, ptr);
1346 return ptr;
1355 static zend_always_inline void zend_mm_free_heap(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZE…
1357 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1360 if (ptr != NULL) {
1361 zend_mm_free_huge(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1364 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1370 zend_mm_free_small(heap, ptr, ZEND_MM_SRUN_BIN_NUM(info));
1380 static size_t zend_mm_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
1382 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1385 …return zend_mm_get_huge_block_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1389 zend_mm_debug_info *dbg = zend_mm_get_debug_info(heap, ptr);
1395 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1408 static zend_never_inline void *zend_mm_realloc_slow(zend_mm_heap *heap, void *ptr, size_t size, siz… argument
1417 memcpy(ret, ptr, copy_size);
1418 zend_mm_free_heap(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1426 static zend_never_inline void *zend_mm_realloc_huge(zend_mm_heap *heap, void *ptr, size_t size, siz… argument
1434 …old_size = zend_mm_get_huge_block_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1454 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1456 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1458 return ptr;
1461 if (zend_mm_chunk_truncate(heap, ptr, old_size, new_size)) {
1469 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1471 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1473 return ptr;
1491 if (zend_mm_chunk_extend(heap, ptr, old_size, new_size)) {
1501 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1503 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1505 return ptr;
1510 …return zend_mm_realloc_slow(heap, ptr, size, MIN(old_size, copy_size) ZEND_FILE_LINE_RELAY_CC ZEND…
1513 static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, ze… argument
1523 page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1525 if (EXPECTED(ptr == NULL)) {
1528 …return zend_mm_realloc_huge(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
1531 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1554 memcpy(ret, ptr, copy_size);
1555 zend_mm_free_small(heap, ptr, old_bin_num);
1558 ret = ptr;
1569 memcpy(ret, ptr, copy_size);
1570 zend_mm_free_small(heap, ptr, old_bin_num);
1598 dbg = zend_mm_get_debug_info(heap, ptr);
1605 return ptr;
1618 dbg = zend_mm_get_debug_info(heap, ptr);
1625 return ptr;
1645 dbg = zend_mm_get_debug_info(heap, ptr);
1652 return ptr;
1663 …return zend_mm_realloc_slow(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
1671 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_size ZEND… argument
1673 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEN…
1677 list->ptr = ptr;
1690 static size_t zend_mm_del_huge_block(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE…
1695 if (list->ptr == ptr) {
1714 static size_t zend_mm_get_huge_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
1718 if (list->ptr == ptr) {
1728 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s… argument
1730 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1735 if (list->ptr == ptr) {
1762 void *ptr; local
1782 ptr = zend_mm_chunk_alloc(heap, new_size, ZEND_MM_CHUNK_SIZE);
1783 if (UNEXPECTED(ptr == NULL)) {
1786 (ptr = zend_mm_chunk_alloc(heap, new_size, ZEND_MM_CHUNK_SIZE)) != NULL) {
1800 …zend_mm_add_huge_block(heap, ptr, new_size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1802 zend_mm_add_huge_block(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1820 return ptr;
1823 static void zend_mm_free_huge(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
1827 ZEND_MM_CHECK(ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE) == 0, "zend_mm_heap corrupted");
1828 size = zend_mm_del_huge_block(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1829 zend_mm_chunk_free(heap, ptr, size);
2082 zend_mm_chunk_free(heap, p->ptr, p->size);
2108 leak.addr = list->ptr;
2124 zend_mm_chunk_free(heap, q->ptr, q->size);
2250 zend_mm_chunk_free(heap, q->ptr, q->size);
2331 ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
2333 zend_mm_free_heap(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2336 void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC Z… argument
2338 …return zend_mm_realloc_heap(heap, ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_R…
2341 void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size … argument
2343 …return zend_mm_realloc_heap(heap, ptr, size, 1, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_O…
2346 ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC Z…
2348 return zend_mm_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2377 ZEND_API bool is_zend_ptr(const void *ptr) argument
2389 if (ptr >= (void*)chunk
2390 && ptr < (void*)((char*)chunk + ZEND_MM_CHUNK_SIZE)) {
2401 if (ptr >= (void*)block
2402 && ptr < (void*)((char*)block + block->size)) {
2422 static ZEND_COLD void ZEND_FASTCALL _efree_custom(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
2425 AG(mm_heap)->custom_heap.debug._free(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2427 AG(mm_heap)->custom_heap.std._free(ptr);
2431 static ZEND_COLD void* ZEND_FASTCALL _realloc_custom(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_… argument
2434 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2436 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2450 # define ZEND_MM_CUSTOM_DEALLOCATOR(ptr) do { \ argument
2452 _efree_custom(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); \
2458 # define ZEND_MM_CUSTOM_DEALLOCATOR(ptr) argument
2483 ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
2484 ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
2486 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE); \
2487 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
2492 zend_mm_free_small(AG(mm_heap), ptr, _num); \
2497 ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
2498 ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
2500 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
2502 zend_mm_free_small(AG(mm_heap), ptr, _num); \
2509 ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
2511 ZEND_MM_CUSTOM_DEALLOCATOR(ptr);
2513 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
2514 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
2525 ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size) argument
2528 ZEND_MM_CUSTOM_DEALLOCATOR(ptr);
2529 zend_mm_free_huge(AG(mm_heap), ptr);
2543 ZEND_API void ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2547 _efree_custom(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2551 zend_mm_free_heap(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2554 ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG… argument
2558 return _realloc_custom(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2561 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE…
2564 ZEND_API void* ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC … argument
2568 return _realloc_custom(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2571 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 1, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE…
2574 ZEND_API size_t ZEND_FASTCALL _zend_mem_block_size(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_…
2581 return zend_mm_size(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2594 ZEND_API void* ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEN… argument
2596 …return _erealloc(ptr, zend_safe_address_guarded(nmemb, size, offset) ZEND_FILE_LINE_RELAY_CC ZEND_…
2599 ZEND_API void* ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset) argument
2601 return perealloc(ptr, zend_safe_address_guarded(nmemb, size, offset), 1);
2725 static zend_always_inline void tracked_add(zend_mm_heap *heap, void *ptr, size_t size) { argument
2727 zend_ulong h = ((uintptr_t) ptr) >> ZEND_MM_ALIGNMENT_LOG2;
2728 ZEND_ASSERT((void *) (uintptr_t) (h << ZEND_MM_ALIGNMENT_LOG2) == ptr);
2733 static zend_always_inline zval *tracked_get_size_zv(zend_mm_heap *heap, void *ptr) { argument
2734 zend_ulong h = ((uintptr_t) ptr) >> ZEND_MM_ALIGNMENT_LOG2;
2759 void *ptr = __zend_malloc(size); local
2760 tracked_add(heap, ptr, size);
2762 return ptr;
2765 static void tracked_free(void *ptr) { argument
2766 if (!ptr) {
2771 zval *size_zv = tracked_get_size_zv(heap, ptr);
2774 free(ptr);
2777 static void *tracked_realloc(void *ptr, size_t new_size) { argument
2781 if (ptr) {
2782 old_size_zv = tracked_get_size_zv(heap, ptr);
2795 ptr = __zend_realloc(ptr, new_size);
2796 tracked_add(heap, ptr, new_size);
2798 return ptr;
2805 void *ptr = (void *) (uintptr_t) (h << ZEND_MM_ALIGNMENT_LOG2); local
2806 free(ptr);