Lines Matching defs:ptr

141 static void default_junk_alloc(void *ptr, size_t usize) {
142 memset(ptr, junk_alloc_byte, usize);
145 static void default_junk_free(void *ptr, size_t usize) {
146 memset(ptr, junk_free_byte, usize);
149 void (*junk_alloc_callback)(void *ptr, size_t size) = &default_junk_alloc;
150 void (*junk_free_callback)(void *ptr, size_t size) = &default_junk_free;
324 a0idalloc(void *ptr, bool is_internal) {
325 idalloctm(TSDN_NULL, ptr, NULL, NULL, is_internal, true);
334 a0dalloc(void *ptr) {
335 a0idalloc(ptr, true);
367 bootstrap_free(void *ptr) {
368 if (unlikely(ptr == NULL)) {
372 a0idalloc(ptr, false);
2339 /* Getting tcache ptr unconditionally. */
2760 LOG("core.posix_memalign.entry", "mem ptr: %p, alignment: %zu, "
2786 LOG("core.posix_memalign.exit", "result: %d, alloc ptr: %p", ret,
2868 ifree(tsd_t *tsd, void *ptr, tcache_t *tcache, bool slow_path) {
2877 assert(ptr != NULL);
2881 emap_alloc_ctx_lookup(tsd_tsdn(tsd), &arena_emap_global, ptr,
2887 prof_free(tsd, ptr, usize, &alloc_ctx);
2891 idalloctm(tsd_tsdn(tsd), ptr, tcache, &alloc_ctx, false,
2895 junk_free_callback(ptr, usize);
2897 idalloctm(tsd_tsdn(tsd), ptr, tcache, &alloc_ctx, false,
2904 maybe_check_alloc_ctx(tsd_t *tsd, void *ptr, emap_alloc_ctx_t *alloc_ctx) {
2907 emap_alloc_ctx_lookup(tsd_tsdn(tsd), &arena_emap_global, ptr,
2911 /* current_dealloc */ true, ptr,
2927 isfree(tsd_t *tsd, void *ptr, size_t usize, tcache_t *tcache, bool slow_path) {
2936 assert(ptr != NULL);
2944 if (likely(!prof_sample_aligned(ptr))) {
2946 * When the ptr is not page aligned, it was not sampled.
2953 ptr, &alloc_ctx);
2960 /* current_dealloc */ true, ptr,
2971 bool fail = maybe_check_alloc_ctx(tsd, ptr, &alloc_ctx);
2983 prof_free(tsd, ptr, usize, &alloc_ctx);
2986 isdalloct(tsd_tsdn(tsd), ptr, usize, tcache, &alloc_ctx,
2990 junk_free_callback(ptr, usize);
2992 isdalloct(tsd_tsdn(tsd), ptr, usize, tcache, &alloc_ctx,
3000 free_default(void *ptr) {
3001 UTRACE(ptr, 0, 0);
3002 if (likely(ptr != NULL)) {
3018 ifree(tsd, ptr, tcache, /* slow */ false);
3023 uintptr_t args_raw[3] = {(uintptr_t)ptr};
3024 hook_invoke_dalloc(hook_dalloc_free, ptr, args_raw);
3025 ifree(tsd, ptr, tcache, /* slow */ true);
3033 free_fastpath_nonfast_aligned(void *ptr, bool check_prof) {
3043 if (config_debug && cache_bin_nonfast_aligned(ptr)) {
3044 assert(prof_sample_aligned(ptr));
3049 if (prof_sample_aligned(ptr)) {
3057 if (cache_bin_nonfast_aligned(ptr)) {
3069 bool free_fastpath(void *ptr, size_t size, bool size_hint) {
3086 &arena_emap_global, ptr, &alloc_ctx);
3090 free_fastpath_nonfast_aligned(ptr,
3099 * for null ptr.
3102 free_fastpath_nonfast_aligned(ptr,
3135 bool fail = maybe_check_alloc_ctx(tsd, ptr, &alloc_ctx);
3152 if (!cache_bin_dalloc_easy(bin, ptr)) {
3162 je_free(void *ptr) {
3163 LOG("core.free.entry", "ptr: %p", ptr);
3165 if (!free_fastpath(ptr, 0, false)) {
3166 free_default(ptr);
3269 JEMALLOC_EXPORT void (*__free_hook)(void *ptr) = je_free;
3271 JEMALLOC_EXPORT void *(*__realloc_hook)(void *ptr, size_t size) = je_realloc;
3290 void __libc_free(void* ptr) PREALIAS(je_free);
3299 void *__libc_realloc(void* ptr, size_t size) PREALIAS(je_realloc);
3347 void *ptr;
3362 * of the `ptr` undefined behavior, but the objective
3380 dopts.result = &ret.ptr;
3394 LOG("core.smallocx.exit", "result: %p, size: %zu", ret.ptr, ret.size);
3497 do_rallocx(void *ptr, size_t size, int flags, bool is_realloc) {
3505 assert(ptr != NULL);
3523 emap_alloc_ctx_lookup(tsd_tsdn(tsd), &arena_emap_global, ptr,
3527 assert(old_usize == isalloc(tsd_tsdn(tsd), ptr));
3532 hook_ralloc_args_t hook_args = {is_realloc, {(uintptr_t)ptr, size,
3535 p = irallocx_prof(tsd, ptr, old_usize, size, alignment, usize,
3541 p = iralloct(tsd_tsdn(tsd), ptr, old_usize, size, alignment,
3552 UTRACE(ptr, size, p);
3568 UTRACE(ptr, size, 0);
3577 je_rallocx(void *ptr, size_t size, int flags) {
3578 LOG("core.rallocx.entry", "ptr: %p, size: %zu, flags: %d", ptr,
3580 void *ret = do_rallocx(ptr, size, flags, false);
3586 do_realloc_nonnull_zero(void *ptr) {
3597 return do_rallocx(ptr, 1, MALLOCX_TCACHE_NONE, true);
3599 UTRACE(ptr, 0, 0);
3606 uintptr_t args[3] = {(uintptr_t)ptr, 0};
3607 hook_invoke_dalloc(hook_dalloc_realloc, ptr, args);
3608 ifree(tsd, ptr, tcache, true);
3613 safety_check_fail("Called realloc(non-null-ptr, 0) with "
3627 je_realloc(void *ptr, size_t size) {
3628 LOG("core.realloc.entry", "ptr: %p, size: %zu\n", ptr, size);
3630 if (likely(ptr != NULL && size != 0)) {
3631 void *ret = do_rallocx(ptr, size, 0, true);
3634 } else if (ptr != NULL && size == 0) {
3635 void *ret = do_realloc_nonnull_zero(ptr);
3659 uintptr_t args[3] = {(uintptr_t)ptr, size};
3669 ixallocx_helper(tsdn_t *tsdn, void *ptr, size_t old_usize, size_t size,
3673 if (ixalloc(tsdn, ptr, old_usize, size, extra, alignment, zero,
3682 ixallocx_prof_sample(tsdn_t *tsdn, void *ptr, size_t old_usize, size_t size,
3685 if (tctx == NULL || !prof_sample_aligned(ptr)) {
3689 return ixallocx_helper(tsdn, ptr, old_usize, size, extra, alignment,
3694 ixallocx_prof(tsd_t *tsd, void *ptr, size_t old_usize, size_t size,
3701 prof_info_get(tsd, ptr, alloc_ctx, &old_prof_info);
3725 usize = ixallocx_prof_sample(tsd_tsdn(tsd), ptr, old_usize,
3728 usize = ixallocx_helper(tsd_tsdn(tsd), ptr, old_usize, size,
3734 * information associated with the ptr, because (a) the edata_t object
3735 * associated with the ptr still lives and (b) the profiling info
3742 prof_info_get(tsd, ptr, alloc_ctx, &prof_info);
3745 prof_info_get_and_reset_recent(tsd, ptr, alloc_ctx, &prof_info);
3748 prof_realloc(tsd, ptr, size, usize, tctx, prof_active, ptr,
3757 je_xallocx(void *ptr, size_t size, size_t extra, int flags) {
3763 LOG("core.xallocx.entry", "ptr: %p, size: %zu, extra: %zu, "
3764 "flags: %d", ptr, size, extra, flags);
3766 assert(ptr != NULL);
3775 * object associated with the ptr (though the content of the edata_t
3779 &arena_emap_global, ptr);
3782 emap_alloc_ctx_lookup(tsd_tsdn(tsd), &arena_emap_global, ptr,
3786 assert(old_usize == isalloc(tsd_tsdn(tsd), ptr));
3805 usize = ixallocx_prof(tsd, ptr, old_usize, size, extra,
3808 usize = ixallocx_helper(tsd_tsdn(tsd), ptr, old_usize, size,
3816 assert(emap_edata_lookup(tsd_tsdn(tsd), &arena_emap_global, ptr)
3828 void *excess_start = (void *)((uintptr_t)ptr + old_usize);
3833 uintptr_t args[4] = {(uintptr_t)ptr, size, extra, flags};
3834 hook_invoke_expand(hook_expand_xallocx, ptr, old_usize,
3838 UTRACE(ptr, size, ptr);
3847 je_sallocx(const void *ptr, int flags) {
3851 LOG("core.sallocx.entry", "ptr: %p, flags: %d", ptr, flags);
3854 assert(ptr != NULL);
3860 usize = ivsalloc(tsdn, ptr);
3863 usize = isalloc(tsdn, ptr);
3873 je_dallocx(void *ptr, int flags) {
3874 LOG("core.dallocx.entry", "ptr: %p, flags: %d", ptr, flags);
3876 assert(ptr != NULL);
3887 UTRACE(ptr, 0, 0);
3890 ifree(tsd, ptr, tcache, false);
3892 uintptr_t args_raw[3] = {(uintptr_t)ptr, flags};
3893 hook_invoke_dalloc(hook_dalloc_dallocx, ptr, args_raw);
3894 ifree(tsd, ptr, tcache, true);
3912 sdallocx_default(void *ptr, size_t size, int flags) {
3913 assert(ptr != NULL);
3925 UTRACE(ptr, 0, 0);
3928 isfree(tsd, ptr, usize, tcache, false);
3930 uintptr_t args_raw[3] = {(uintptr_t)ptr, size, flags};
3931 hook_invoke_dalloc(hook_dalloc_sdallocx, ptr, args_raw);
3932 isfree(tsd, ptr, usize, tcache, true);
3938 je_sdallocx(void *ptr, size_t size, int flags) {
3939 LOG("core.sdallocx.entry", "ptr: %p, size: %zu, flags: %d", ptr,
3942 if (flags != 0 || !free_fastpath(ptr, size, true)) {
3943 sdallocx_default(ptr, size, flags);
3950 je_sdallocx_noflags(void *ptr, size_t size) {
3951 LOG("core.sdallocx.entry", "ptr: %p, size: %zu, flags: 0", ptr,
3954 if (!free_fastpath(ptr, size, true)) {
3955 sdallocx_default(ptr, size, 0);
4078 je_malloc_usable_size_impl(JEMALLOC_USABLE_SIZE_CONST void *ptr) {
4085 if (unlikely(ptr == NULL)) {
4089 ret = ivsalloc(tsdn, ptr);
4092 ret = isalloc(tsdn, ptr);
4101 je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr) {
4102 LOG("core.malloc_usable_size.entry", "ptr: %p", ptr);
4104 size_t ret = je_malloc_usable_size_impl(ptr);
4112 je_malloc_size(const void *ptr) {
4113 LOG("core.malloc_size.entry", "ptr: %p", ptr);
4115 size_t ret = je_malloc_usable_size_impl(ptr);
4318 je_allocm(void **ptr, size_t *rsize, size_t size, int flags) {
4319 assert(ptr != NULL);
4328 *ptr = p;
4333 je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, int flags) {
4334 assert(ptr != NULL);
4335 assert(*ptr != NULL);
4343 size_t usize = je_xallocx(*ptr, size, extra, flags);
4349 void *p = je_rallocx(*ptr, size+extra, flags);
4351 *ptr = p;
4357 *rsize = isalloc(tsdn_fetch(), *ptr);
4364 je_sallocm(const void *ptr, size_t *rsize, int flags) {
4366 *rsize = je_sallocx(ptr, flags);
4371 je_dallocm(void *ptr, int flags) {
4372 je_dallocx(ptr, flags);