Lines Matching refs:ptr

313 	void              *ptr;  member
460 void *ptr = VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap_fixed() local
462 if (ptr == NULL) { in zend_mm_mmap_fixed()
472 ZEND_ASSERT(ptr == addr); in zend_mm_mmap_fixed()
473 return ptr; in zend_mm_mmap_fixed()
480 …void *ptr = mmap(addr, size, PROT_READ | PROT_WRITE, flags /*| MAP_POPULATE | MAP_HUGETLB*/, ZEND_… in zend_mm_mmap_fixed()
482 if (ptr == MAP_FAILED) { in zend_mm_mmap_fixed()
487 } else if (ptr != addr) { in zend_mm_mmap_fixed()
488 zend_mm_munmap(ptr, size); in zend_mm_mmap_fixed()
491 return ptr; in zend_mm_mmap_fixed()
499 void *ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); in zend_mm_mmap() local
501 if (ptr == NULL) { in zend_mm_mmap()
507 return ptr; in zend_mm_mmap()
509 void *ptr; in zend_mm_mmap()
513 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0); in zend_mm_mmap()
514 if (ptr != MAP_FAILED) { in zend_mm_mmap()
515 return ptr; in zend_mm_mmap()
520 ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, ZEND_MM_FD, 0); in zend_mm_mmap()
522 if (ptr == MAP_FAILED) { in zend_mm_mmap()
528 return ptr; in zend_mm_mmap()
696 void *ptr = zend_mm_mmap(size); local
698 if (ptr == NULL) {
700 } else if (ZEND_MM_ALIGNED_OFFSET(ptr, alignment) == 0) {
703 madvise(ptr, size, MADV_HUGEPAGE);
706 return ptr;
711 zend_mm_munmap(ptr, size);
712 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
714 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
718 zend_mm_munmap(ptr, size + alignment - REAL_PAGE_SIZE);
719 ptr = zend_mm_mmap_fixed((void*)((char*)ptr + offset), size);
720 if (ptr == NULL) { // fix GH-9650, fixed addr range is not free
721 ptr = zend_mm_mmap(size + alignment - REAL_PAGE_SIZE);
722 if (ptr == NULL) {
725 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
727 ptr = (void*)((char*)ptr + alignment - offset);
730 return ptr;
732 offset = ZEND_MM_ALIGNED_OFFSET(ptr, alignment);
735 zend_mm_munmap(ptr, offset);
736 ptr = (char*)ptr + offset;
740 zend_mm_munmap((char*)ptr + size, alignment - REAL_PAGE_SIZE);
744 madvise(ptr, size, MADV_HUGEPAGE);
748 return ptr;
756 void *ptr = heap->storage->handlers.chunk_alloc(heap->storage, size, alignment); local
757 …ZEND_ASSERT(((zend_uintptr_t)((char*)ptr + (alignment-1)) & (alignment-1)) == (zend_uintptr_t)ptr);
758 return ptr;
807 void *ptr = mremap(addr, old_size, new_size, 0); local
808 if (ptr == MAP_FAILED) {
812 ZEND_ASSERT(ptr == addr);
842 static size_t zend_mm_get_huge_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
844 static void zend_mm_free_huge(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
847 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s…
849 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1069 …void *ptr = zend_mm_alloc_pages(heap, pages_count, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORI… local
1071 …void *ptr = zend_mm_alloc_pages(heap, pages_count ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELA… local
1081 return ptr;
1300 static zend_always_inline void zend_mm_free_small(zend_mm_heap *heap, void *ptr, int bin_num) argument
1310 …zend_mm_debug_info *dbg = (zend_mm_debug_info*)((char*)ptr + bin_data_size[bin_num] - ZEND_MM_ALIG…
1315 p = (zend_mm_free_slot*)ptr;
1325 static zend_always_inline zend_mm_debug_info *zend_mm_get_debug_info(zend_mm_heap *heap, void *ptr) argument
1327 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1333 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1339 …return (zend_mm_debug_info*)((char*)ptr + bin_data_size[bin_num] - ZEND_MM_ALIGNED_SIZE(sizeof(zen…
1343 …return (zend_mm_debug_info*)((char*)ptr + ZEND_MM_PAGE_SIZE * pages_count - ZEND_MM_ALIGNED_SIZE(s…
1350 void *ptr; local
1364ptr = zend_mm_alloc_small(heap, ZEND_MM_SMALL_SIZE_TO_BIN(size) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_…
1366 dbg = zend_mm_get_debug_info(heap, ptr);
1373 return ptr;
1375 ptr = zend_mm_alloc_large(heap, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1377 dbg = zend_mm_get_debug_info(heap, ptr);
1384 return ptr;
1393 static zend_always_inline void zend_mm_free_heap(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZE…
1395 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1398 if (ptr != NULL) {
1399 zend_mm_free_huge(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1402 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1408 zend_mm_free_small(heap, ptr, ZEND_MM_SRUN_BIN_NUM(info));
1418 static size_t zend_mm_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
1420 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1423 …return zend_mm_get_huge_block_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1427 zend_mm_debug_info *dbg = zend_mm_get_debug_info(heap, ptr);
1433 chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1446 static zend_never_inline void *zend_mm_realloc_slow(zend_mm_heap *heap, void *ptr, size_t size, siz… argument
1455 memcpy(ret, ptr, copy_size);
1456 zend_mm_free_heap(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1464 static zend_never_inline void *zend_mm_realloc_huge(zend_mm_heap *heap, void *ptr, size_t size, siz… argument
1472 …old_size = zend_mm_get_huge_block_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1492 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1494 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1496 return ptr;
1499 if (zend_mm_chunk_truncate(heap, ptr, old_size, new_size)) {
1507 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1509 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1511 return ptr;
1529 if (zend_mm_chunk_extend(heap, ptr, old_size, new_size)) {
1539 …zend_mm_change_huge_block_size(heap, ptr, new_size, real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LI…
1541 …zend_mm_change_huge_block_size(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_REL…
1543 return ptr;
1548 …return zend_mm_realloc_slow(heap, ptr, size, MIN(old_size, copy_size) ZEND_FILE_LINE_RELAY_CC ZEND…
1551 static zend_always_inline void *zend_mm_realloc_heap(zend_mm_heap *heap, void *ptr, size_t size, bo… argument
1561 page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
1563 if (EXPECTED(ptr == NULL)) {
1566 …return zend_mm_realloc_huge(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
1569 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
1592 memcpy(ret, ptr, copy_size);
1593 zend_mm_free_small(heap, ptr, old_bin_num);
1596 ret = ptr;
1607 memcpy(ret, ptr, copy_size);
1608 zend_mm_free_small(heap, ptr, old_bin_num);
1636 dbg = zend_mm_get_debug_info(heap, ptr);
1643 return ptr;
1656 dbg = zend_mm_get_debug_info(heap, ptr);
1663 return ptr;
1683 dbg = zend_mm_get_debug_info(heap, ptr);
1690 return ptr;
1701 …return zend_mm_realloc_slow(heap, ptr, size, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG…
1709 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_size ZEND… argument
1711 static void zend_mm_add_huge_block(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC ZEN…
1715 list->ptr = ptr;
1728 static size_t zend_mm_del_huge_block(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE…
1733 if (list->ptr == ptr) {
1752 static size_t zend_mm_get_huge_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
1756 if (list->ptr == ptr) {
1766 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size, size_t dbg_s… argument
1768 static void zend_mm_change_huge_block_size(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LIN…
1773 if (list->ptr == ptr) {
1800 void *ptr; local
1820 ptr = zend_mm_chunk_alloc(heap, new_size, ZEND_MM_CHUNK_SIZE);
1821 if (UNEXPECTED(ptr == NULL)) {
1824 (ptr = zend_mm_chunk_alloc(heap, new_size, ZEND_MM_CHUNK_SIZE)) != NULL) {
1838 …zend_mm_add_huge_block(heap, ptr, new_size, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY…
1840 zend_mm_add_huge_block(heap, ptr, new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1858 return ptr;
1861 static void zend_mm_free_huge(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
1865 ZEND_MM_CHECK(ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE) == 0, "zend_mm_heap corrupted");
1866 size = zend_mm_del_huge_block(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
1867 zend_mm_chunk_free(heap, ptr, size);
2116 zend_mm_chunk_free(heap, p->ptr, p->size);
2142 leak.addr = list->ptr;
2158 zend_mm_chunk_free(heap, q->ptr, q->size);
2284 zend_mm_chunk_free(heap, q->ptr, q->size);
2365 ZEND_API void ZEND_FASTCALL _zend_mm_free(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC ZEND_FILE…
2367 zend_mm_free_heap(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2370 void* ZEND_FASTCALL _zend_mm_realloc(zend_mm_heap *heap, void *ptr, size_t size ZEND_FILE_LINE_DC Z… argument
2372 …return zend_mm_realloc_heap(heap, ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_R…
2375 void* ZEND_FASTCALL _zend_mm_realloc2(zend_mm_heap *heap, void *ptr, size_t size, size_t copy_size … argument
2377 …return zend_mm_realloc_heap(heap, ptr, size, 1, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_O…
2380 ZEND_API size_t ZEND_FASTCALL _zend_mm_block_size(zend_mm_heap *heap, void *ptr ZEND_FILE_LINE_DC Z…
2382 return zend_mm_size(heap, ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2411 ZEND_API bool is_zend_ptr(const void *ptr) argument
2416 zend_ulong h = ((uintptr_t) ptr) >> ZEND_MM_ALIGNMENT_LOG2;
2430 if (ptr >= (void*)chunk
2431 && ptr < (void*)((char*)chunk + ZEND_MM_CHUNK_SIZE)) {
2442 if (ptr >= (void*)block
2443 && ptr < (void*)((char*)block + block->size)) {
2463 static ZEND_COLD void ZEND_FASTCALL _efree_custom(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_D…
2466 AG(mm_heap)->custom_heap.debug._free(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2468 AG(mm_heap)->custom_heap.std._free(ptr);
2472 static ZEND_COLD void* ZEND_FASTCALL _realloc_custom(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_… argument
2475 …return AG(mm_heap)->custom_heap.debug._realloc(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_OR…
2477 return AG(mm_heap)->custom_heap.std._realloc(ptr, size);
2491 # define ZEND_MM_CUSTOM_DEALLOCATOR(ptr) do { \ argument
2493 _efree_custom(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); \
2499 # define ZEND_MM_CUSTOM_DEALLOCATOR(ptr) argument
2524 ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
2525 ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
2527 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE); \
2528 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
2533 zend_mm_free_small(AG(mm_heap), ptr, _num); \
2538 ZEND_API void ZEND_FASTCALL _efree_ ## _size(void *ptr) { \
2539 ZEND_MM_CUSTOM_DEALLOCATOR(ptr); \
2541 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE); \
2543 zend_mm_free_small(AG(mm_heap), ptr, _num); \
2550 ZEND_API void ZEND_FASTCALL _efree_large(void *ptr, size_t size)
2552 ZEND_MM_CUSTOM_DEALLOCATOR(ptr);
2554 size_t page_offset = ZEND_MM_ALIGNED_OFFSET(ptr, ZEND_MM_CHUNK_SIZE);
2555 zend_mm_chunk *chunk = (zend_mm_chunk*)ZEND_MM_ALIGNED_BASE(ptr, ZEND_MM_CHUNK_SIZE);
2566 ZEND_API void ZEND_FASTCALL _efree_huge(void *ptr, size_t size) argument
2569 ZEND_MM_CUSTOM_DEALLOCATOR(ptr);
2570 zend_mm_free_huge(AG(mm_heap), ptr);
2584 ZEND_API void ZEND_FASTCALL _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
2588 _efree_custom(ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2592 zend_mm_free_heap(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2595 ZEND_API void* ZEND_FASTCALL _erealloc(void *ptr, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG… argument
2599 return _realloc_custom(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2602 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 0, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE…
2605 ZEND_API void* ZEND_FASTCALL _erealloc2(void *ptr, size_t size, size_t copy_size ZEND_FILE_LINE_DC … argument
2609 return _realloc_custom(ptr, size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2612 …return zend_mm_realloc_heap(AG(mm_heap), ptr, size, 1, copy_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE…
2615 ZEND_API size_t ZEND_FASTCALL _zend_mem_block_size(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_…
2622 return zend_mm_size(AG(mm_heap), ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
2635 ZEND_API void* ZEND_FASTCALL _safe_erealloc(void *ptr, size_t nmemb, size_t size, size_t offset ZEN… argument
2637 …return _erealloc(ptr, zend_safe_address_guarded(nmemb, size, offset) ZEND_FILE_LINE_RELAY_CC ZEND_…
2640 ZEND_API void* ZEND_FASTCALL _safe_realloc(void *ptr, size_t nmemb, size_t size, size_t offset) argument
2642 return perealloc(ptr, zend_safe_address_guarded(nmemb, size, offset), 1);
2765 static zend_always_inline void tracked_add(zend_mm_heap *heap, void *ptr, size_t size) { argument
2767 zend_ulong h = ((uintptr_t) ptr) >> ZEND_MM_ALIGNMENT_LOG2;
2768 ZEND_ASSERT((void *) (uintptr_t) (h << ZEND_MM_ALIGNMENT_LOG2) == ptr);
2773 static zend_always_inline zval *tracked_get_size_zv(zend_mm_heap *heap, void *ptr) { argument
2774 zend_ulong h = ((uintptr_t) ptr) >> ZEND_MM_ALIGNMENT_LOG2;
2799 void *ptr = __zend_malloc(size); local
2800 tracked_add(heap, ptr, size);
2802 return ptr;
2805 static void tracked_free(void *ptr) { argument
2806 if (!ptr) {
2811 zval *size_zv = tracked_get_size_zv(heap, ptr);
2814 free(ptr);
2817 static void *tracked_realloc(void *ptr, size_t new_size) { argument
2821 if (ptr) {
2822 old_size_zv = tracked_get_size_zv(heap, ptr);
2835 ptr = __zend_realloc(ptr, new_size);
2836 tracked_add(heap, ptr, new_size);
2838 return ptr;
2845 void *ptr = (void *) (uintptr_t) (h << ZEND_MM_ALIGNMENT_LOG2); local
2846 free(ptr);