Lines Matching refs:ptr

314 	void              *ptr;  member
461 void *ptr = VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap_fixed() local
463 if (ptr == NULL) { in zend_mm_mmap_fixed()
473 ZEND_ASSERT(ptr == addr); in zend_mm_mmap_fixed()
474 return ptr; in zend_mm_mmap_fixed()
483 …void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, flags /*| MAP_POPULATE | MAP_HUGETLB*/, ZEND_… in zend_mm_mmap_fixed()
485 if (ptr == MAP_FAILED) { in zend_mm_mmap_fixed()
490 } else if (ptr != addr) { in zend_mm_mmap_fixed()
491 zend_mm_munmap(ptr, size); in zend_mm_mmap_fixed()
494 return ptr; in zend_mm_mmap_fixed()
502 void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap() local
504 if (ptr == NULL) { in zend_mm_mmap()
510 return ptr; in zend_mm_mmap()
512 void *ptr; in zend_mm_mmap()
523 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, mflags, fd, 0); in zend_mm_mmap()
524 if (ptr != MAP_FAILED) { in zend_mm_mmap()
525 zend_mmap_set_name(ptr, size, "zend_alloc"); in zend_mm_mmap()
526 return ptr; in zend_mm_mmap()
531 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, ZEND_MM_FD, 0); in zend_mm_mmap()
533 if (ptr == MAP_FAILED) { in zend_mm_mmap()
539 zend_mmap_set_name(ptr, size, "zend_alloc"); in zend_mm_mmap()
540 return ptr; in zend_mm_mmap()
706 static zend_always_inline void zend_mm_hugepage(void* ptr, size_t size) argument
709 (void)madvise(ptr, size, MADV_HUGEPAGE);
712 (void)memcntl(ptr, size, MC_HAT_ADVISE, (char *)&m, 0, 0);
720 void *ptr = zend_mm_mmap(size); local
722 if (ptr == NULL) {
724 } else if (ZEND_MM_ALIGNED_OFFSET(ptr, alignment) == 0) {
726 zend_mm_hugepage(ptr, size);
728 return ptr;
733 zend_mm_munmap(ptr, size);
734 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
736 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
740 zend_mm_munmap(ptr, size + alignment - REAL_PAGE_SIZE);
741 ptr = zend_mm_mmap_fixed((void*)((char*)ptr + offset), size);
742 if (ptr == NULL) { // fix GH-9650, fixed addr range is not free
743 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
744 if (ptr == NULL) {
747 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
749 ptr = (void*)((char*)ptr + alignment - offset);
752 return ptr;
754 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
757 zend_mm_munmap(ptr, offset);
758 ptr = (char*)ptr + offset;
762 zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
765 zend_mm_hugepage(ptr, size);
768 return ptr;
776 void *ptr = heap->storage->handlers.chunk_alloc(heap->storage, size, alignment); local
777 …ZEND_ASSERT(((zend_uintptr_t)((char*)ptr + (alignment-1)) & (alignment-1)) == (zend_uintptr_t)ptr);
778 return ptr;
827 void *ptr = mremap(addr, old_size, new_size, 0); local
828 if (ptr == MAP_FAILED) {
832 ZEND_ASSERT(ptr == addr);
862 static size_t zend_mm_get_huge_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
864 static void zend_mm_free_huge(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
867 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s…
869 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1089 …void *ptr = zend_mm_alloc_pages(heap, pages_count, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORI… local
1091 …void *ptr = zend_mm_alloc_pages(heap, pages_count ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELA… local
1101 return ptr;
1320 static zend_always_inline void zend_mm_free_small(zend_mm_heap *heap, void *ptr, int bin_num) argument
1330 …zend_mm_debug_info *dbg = (zend_mm_debug_info*)((char*)ptr + bin_data_size[bin_num] - ZEND_MM_ALIG…
1335 p = (zend_mm_free_slot*)ptr;
1345 static zend_always_inline zend_mm_debug_info *zend_mm_get_debug_info(zend_mm_heap *heap, void *ptr) argument
1347 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1353 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1359 …return (zend_mm_debug_info*)((char*)ptr + bin_data_size[bin_num] - ZEND_MM_ALIGNED_SIZE(sizeof(zen…
1363 …return (zend_mm_debug_info*)((char*)ptr + ZEND_MM_PAGE_SIZE * pages_count - ZEND_MM_ALIGNED_SIZE(s…
1370 void *ptr; local
1384ptr = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_…
1386 dbg = zend_mm_get_debug_info(heap, ptr);
1393 return ptr;
1395 ptr = zend_mm_alloc_large(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1397 dbg = zend_mm_get_debug_info(heap, ptr);
1404 return ptr;
1413 static zend_always_inline void zend_mm_free_heap(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZE…
1415 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1418 if (ptr != NULL) {
1419 zend_mm_free_huge(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1422 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1428 zend_mm_free_small(heap, ptr, ZEND_MM_SRUN_BIN_NUM(info));
1438 static size_t zend_mm_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
1440 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1443 …return zend_mm_get_huge_block_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1447 zend_mm_debug_info *dbg = zend_mm_get_debug_info(heap, ptr);
1453 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1466 static zend_never_inline void *zend_mm_realloc_slow(zend_mm_heap *heap, void *ptr, size_t size, siz… argument
1475 memcpy(ret, ptr, copy_size);
1476 zend_mm_free_heap(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1484 static zend_never_inline void *zend_mm_realloc_huge(zend_mm_heap *heap, void *ptr, size_t size, siz… argument
1492 …old_size = zend_mm_get_huge_block_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1512 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1514 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1516 return ptr;
1519 if (zend_mm_chunk_truncate(heap, ptr, old_size, new_size)) {
1527 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1529 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1531 return ptr;
1549 if (zend_mm_chunk_extend(heap, ptr, old_size, new_size)) {
1559 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1561 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1563 return ptr;
1568 …return zend_mm_realloc_slow(heap, ptr, size, MIN(old_size, copy_size) ZEND_FILE_LINE_RELAY_CC ZEND…
1571 static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, bo… argument
1581 page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1583 if (EXPECTED(ptr == NULL)) {
1586 …return zend_mm_realloc_huge(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
1589 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1612 memcpy(ret, ptr, copy_size);
1613 zend_mm_free_small(heap, ptr, old_bin_num);
1616 ret = ptr;
1627 memcpy(ret, ptr, copy_size);
1628 zend_mm_free_small(heap, ptr, old_bin_num);
1656 dbg = zend_mm_get_debug_info(heap, ptr);
1663 return ptr;
1676 dbg = zend_mm_get_debug_info(heap, ptr);
1683 return ptr;
1703 dbg = zend_mm_get_debug_info(heap, ptr);
1710 return ptr;
1721 …return zend_mm_realloc_slow(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
1729 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_size ZEND… argument
1731 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEN…
1735 list->ptr = ptr;
1748 static size_t zend_mm_del_huge_block(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE…
1753 if (list->ptr == ptr) {
1772 static size_t zend_mm_get_huge_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
1776 if (list->ptr == ptr) {
1786 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s… argument
1788 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1793 if (list->ptr == ptr) {
1820 void *ptr; local
1840 ptr = zend_mm_chunk_alloc(heap, new_size, ZEND_MM_CHUNK_SIZE);
1841 if (UNEXPECTED(ptr == NULL)) {
1844 (ptr = zend_mm_chunk_alloc(heap, new_size, ZEND_MM_CHUNK_SIZE)) != NULL) {
1858 …zend_mm_add_huge_block(heap, ptr, new_size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1860 zend_mm_add_huge_block(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1878 return ptr;
1881 static void zend_mm_free_huge(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
1885 ZEND_MM_CHECK(ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE) == 0, "zend_mm_heap corrupted");
1886 size = zend_mm_del_huge_block(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1887 zend_mm_chunk_free(heap, ptr, size);
2136 zend_mm_chunk_free(heap, p->ptr, p->size);
2162 leak.addr = list->ptr;
2178 zend_mm_chunk_free(heap, q->ptr, q->size);
2304 zend_mm_chunk_free(heap, q->ptr, q->size);
2385 ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
2387 zend_mm_free_heap(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2390 void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC Z… argument
2392 …return zend_mm_realloc_heap(heap, ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_R…
2395 void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size … argument
2397 …return zend_mm_realloc_heap(heap, ptr, size, 1, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_O…
2400 ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC Z…
2402 return zend_mm_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2431 ZEND_API bool is_zend_ptr(const void *ptr) argument
2436 zend_ulong h = ((uintptr_t) ptr) >> ZEND_MM_ALIGNMENT_LOG2;
2450 if (ptr >= (void*)chunk
2451 && ptr < (void*)((char*)chunk + ZEND_MM_CHUNK_SIZE)) {
2460 if (ptr >= (void*)block
2461 && ptr < (void*)((char*)block + block->size)) {
2481 static ZEND_COLD void ZEND_FASTCALL _efree_custom(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
2484 AG(mm_heap)->custom_heap.debug._free(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2486 AG(mm_heap)->custom_heap.std._free(ptr);
2490 static ZEND_COLD void* ZEND_FASTCALL _realloc_custom(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_… argument
2493 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2495 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2509 # define ZEND_MM_CUSTOM_DEALLOCATOR(ptr) do { \ argument
2511 _efree_custom(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); \
2517 # define ZEND_MM_CUSTOM_DEALLOCATOR(ptr) argument
2542 ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
2543 ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
2545 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE); \
2546 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
2551 zend_mm_free_small(AG(mm_heap), ptr, _num); \
2556 ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
2557 ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
2559 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
2561 zend_mm_free_small(AG(mm_heap), ptr, _num); \
2568 ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
2570 ZEND_MM_CUSTOM_DEALLOCATOR(ptr);
2572 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
2573 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
2584 ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size) argument
2587 ZEND_MM_CUSTOM_DEALLOCATOR(ptr);
2588 zend_mm_free_huge(AG(mm_heap), ptr);
2602 ZEND_API void ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2606 _efree_custom(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2610 zend_mm_free_heap(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2613 ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG… argument
2617 return _realloc_custom(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2620 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE…
2623 ZEND_API void* ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC … argument
2627 return _realloc_custom(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2630 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 1, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE…
2633 ZEND_API size_t ZEND_FASTCALL _zend_mem_block_size(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_…
2640 return zend_mm_size(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2653 ZEND_API void* ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEN… argument
2655 …return _erealloc(ptr, zend_safe_address_guarded(nmemb, size, offset) ZEND_FILE_LINE_RELAY_CC ZEND_…
2658 ZEND_API void* ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset) argument
2660 return perealloc(ptr, zend_safe_address_guarded(nmemb, size, offset), 1);
2798 static zend_always_inline void tracked_add(zend_mm_heap *heap, void *ptr, size_t size) { argument
2800 zend_ulong h = ((uintptr_t) ptr) >> ZEND_MM_ALIGNMENT_LOG2;
2801 ZEND_ASSERT((void *) (uintptr_t) (h << ZEND_MM_ALIGNMENT_LOG2) == ptr);
2806 static zend_always_inline zval *tracked_get_size_zv(zend_mm_heap *heap, void *ptr) { argument
2807 zend_ulong h = ((uintptr_t) ptr) >> ZEND_MM_ALIGNMENT_LOG2;
2832 void *ptr = malloc(size); local
2833 if (!ptr) {
2837 tracked_add(heap, ptr, size);
2839 return ptr;
2842 static void tracked_free(void *ptr) { argument
2843 if (!ptr) {
2848 zval *size_zv = tracked_get_size_zv(heap, ptr);
2851 free(ptr);
2854 static void *tracked_realloc(void *ptr, size_t new_size) { argument
2858 if (ptr) {
2859 old_size_zv = tracked_get_size_zv(heap, ptr);
2872 ptr = __zend_realloc(ptr, new_size);
2873 tracked_add(heap, ptr, new_size);
2875 return ptr;
2882 void *ptr = (void *) (uintptr_t) (h << ZEND_MM_ALIGNMENT_LOG2); local
2883 free(ptr);