Home
last modified time | relevance | path

Searched refs:ptr (Results 1 – 25 of 70) sorted by relevance

123

/bionic/tests/
Dmalloc_test.cpp62 void *ptr = malloc(100); in TEST() local
63 ASSERT_TRUE(ptr != nullptr); in TEST()
64 ASSERT_LE(100U, malloc_usable_size(ptr)); in TEST()
65 free(ptr); in TEST()
78 char *ptr = (char *)calloc(1, alloc_len); in TEST() local
79 ASSERT_TRUE(ptr != nullptr); in TEST()
80 ASSERT_LE(alloc_len, malloc_usable_size(ptr)); in TEST()
82 ASSERT_EQ(0, ptr[i]); in TEST()
84 free(ptr); in TEST()
115 char *ptr = reinterpret_cast<char*>(memalign(alignment, 100)); in TEST() local
[all …]
Dbionic_allocator_test.cpp66 void* ptr = allocator.alloc(0); in TEST() local
67 ASSERT_TRUE(ptr != nullptr); in TEST()
68 allocator.free(ptr); in TEST()
217 void* ptr; in TEST() local
220 ptr = allocator.memalign(0x100, 0x100); in TEST()
221 ASSERT_TRUE(ptr != nullptr); in TEST()
222 ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr) % 0x100); in TEST()
223 allocator.free(ptr); in TEST()
226 ptr = allocator.alloc(0x200); in TEST()
227 ASSERT_TRUE(ptr != nullptr); in TEST()
[all …]
Dmalloc_iterate_test.cpp40 void* ptr; member
54 void* ptr = malloc(size); in AllocPtr() local
55 ASSERT_TRUE(ptr != nullptr); in AllocPtr()
56 alloc->ptr = ptr; in AllocPtr()
57 alloc->size = malloc_usable_size(ptr); in AllocPtr()
64 free(test_data->allocs[i].ptr); in FreePtrs()
80 uintptr_t ptr = reinterpret_cast<uintptr_t>(test_data->allocs[i].ptr); in SavePointers() local
81 if (ptr >= base && ptr < end) { in SavePointers()
84 uintptr_t max_size = end - ptr; in SavePointers()
132 void* ptr = malloc(size); in AllocateSizes() local
[all …]
Dstring_test.cpp212 Character *ptr, *ptr1, *ptr2; member in StringTestState
240 ptr = ptr1 = ptr2 = nullptr; in ResetPointers()
242 ptr = glob_ptr + alignments[align1_index_]; in ResetPointers()
261 memcpy(state.ptr, state.ptr2, 2 * state.MAX_LEN); in TEST()
267 strcpy(state.ptr + state.MAX_LEN - 1, state.ptr1); in TEST()
270 EXPECT_TRUE(memcmp(state.ptr, state.ptr2, 2 * state.MAX_LEN) == 0); in TEST()
517 memcpy(state.ptr, state.ptr1, state.MAX_LEN); in TEST()
522 memset(state.ptr + state.MAX_LEN, '\1', state.MAX_LEN); in TEST()
523 memcpy(state.ptr + state.MAX_LEN, state.ptr1, pos + 1); in TEST()
524 state.ptr[2 * state.MAX_LEN - 1] = '\0'; in TEST()
[all …]
Dstdlib_test.cpp226 void* ptr; in TEST() local
230 ASSERT_EQ(EINVAL, posix_memalign(&ptr, align, 256)) in TEST()
240 ASSERT_EQ(EINVAL, posix_memalign(&ptr, fail_align, 256)) in TEST()
243 ASSERT_EQ(0, posix_memalign(&ptr, align, 256)) in TEST()
245 ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr) & (align - 1)) in TEST()
246 << "Did not return a valid aligned ptr " << ptr << " expected alignment " << align; in TEST()
247 free(ptr); in TEST()
255 void* ptr; in TEST() local
256 ASSERT_EQ(0, posix_memalign(&ptr, 16, 1)) in TEST()
258 ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(ptr) & 0xf) in TEST()
[all …]
/bionic/libc/malloc_hooks/tests/
Dmalloc_hooks_tests.cpp114 static void* test_realloc_hook(void* ptr, size_t, const void*);
162 void* MallocHooksTest::test_realloc_hook(void* ptr, size_t size, const void* arg) { in test_realloc_hook() argument
165 return orig_realloc_hook_(ptr, size, arg); in test_realloc_hook()
174 void MallocHooksTest::test_free_hook(void* ptr, const void* arg) { in test_free_hook() argument
177 return orig_free_hook_(ptr, arg); in test_free_hook()
191 void* ptr = malloc(1024); in TEST_F() local
192 EXPECT_LE(1024U, malloc_usable_size(ptr)); in TEST_F()
193 free(ptr); in TEST_F()
229 void* ptr = malloc(1024); in TEST_F() local
230 ASSERT_TRUE(ptr != nullptr); in TEST_F()
[all …]
/bionic/libc/bionic/
Dmalloc_tagged_pointers.h72 static inline void* TagPointer(void* ptr) { in TagPointer() argument
74 return reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(ptr) | FixedPointerTag()); in TagPointer()
76 async_safe_fatal("Attempting to tag a pointer (%p) on non-aarch64.", ptr); in TagPointer()
83 static inline void* UntagPointer(const volatile void* ptr) { in UntagPointer() argument
84 return reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(ptr) & ADDRESS_MASK); in UntagPointer()
89 static inline void* MaybeUntagAndCheckPointer(const volatile void* ptr) { in MaybeUntagAndCheckPointer() argument
90 if (__predict_false(ptr == nullptr)) { in MaybeUntagAndCheckPointer()
94 uintptr_t ptr_int = reinterpret_cast<uintptr_t>(ptr); in MaybeUntagAndCheckPointer()
104 async_safe_fatal("Pointer tag for %p was truncated.", ptr); in MaybeUntagAndCheckPointer()
111 static inline void* MaybeTagPointer(void* ptr) { in MaybeTagPointer() argument
[all …]
Dbionic_allocator.cpp164 void BionicSmallObjectAllocator::free(void* ptr) { in free() argument
167 PAGE_START(reinterpret_cast<uintptr_t>(ptr))); in free()
169 if (reinterpret_cast<uintptr_t>(ptr) % block_size_ != 0) { in free()
170 async_safe_fatal("invalid pointer: %p (block_size=%zd)", ptr, block_size_); in free()
173 memset(ptr, 0, block_size_); in free()
175 reinterpret_cast<small_object_block_record*>(ptr); in free()
329 inline page_info* BionicAllocator::get_page_info_unchecked(void* ptr) { in get_page_info_unchecked() argument
330 uintptr_t header_page = PAGE_START(reinterpret_cast<size_t>(ptr) - kPageInfoSize); in get_page_info_unchecked()
334 inline page_info* BionicAllocator::get_page_info(void* ptr) { in get_page_info() argument
335 page_info* info = get_page_info_unchecked(ptr); in get_page_info()
[all …]
Dnew.cpp42 void operator delete(void* ptr) throw() { in operator delete() argument
43 free(ptr); in operator delete()
46 void operator delete[](void* ptr) throw() { in operator delete[]() argument
47 free(ptr); in operator delete[]()
58 void operator delete(void* ptr, const std::nothrow_t&) throw() { in operator delete() argument
59 free(ptr); in operator delete()
62 void operator delete[](void* ptr, const std::nothrow_t&) throw() { in operator delete[]() argument
63 free(ptr); in operator delete[]()
D__cmsg_nxthdr.cpp32 cmsghdr* ptr; in __cmsg_nxthdr() local
33 ptr = reinterpret_cast<cmsghdr*>(reinterpret_cast<char*>(cmsg) + CMSG_ALIGN(cmsg->cmsg_len)); in __cmsg_nxthdr()
34 size_t len = reinterpret_cast<char*>(ptr+1) - reinterpret_cast<char*>(msg->msg_control); in __cmsg_nxthdr()
38 return ptr; in __cmsg_nxthdr()
Dnet_if.cpp146 struct if_nameindex* ptr = array; in if_freenameindex() local
147 while (ptr->if_index != 0 || ptr->if_name != nullptr) { in if_freenameindex()
148 free(ptr->if_name); in if_freenameindex()
149 ++ptr; in if_freenameindex()
/bionic/libc/malloc_debug/tests/
Dmalloc_debug_system_tests.cpp244 void* ptr = aligned_alloc(64, 1152); in AlignedAlloc() local
245 ASSERT_TRUE(ptr != nullptr); in AlignedAlloc()
246 memset(ptr, 0, 1152); in AlignedAlloc()
259 void* ptr = calloc(1, 1123); in Calloc() local
260 ASSERT_TRUE(ptr != nullptr); in Calloc()
261 memset(ptr, 1, 1123); in Calloc()
274 void* ptr = malloc(1123); in Malloc() local
275 ASSERT_TRUE(ptr != nullptr); in Malloc()
276 memset(ptr, 0, 1123); in Malloc()
289 void* ptr = memalign(64, 1123); in Memalign() local
[all …]
/bionic/libc/arch-arm/bionic/
Datomics_arm.c61 __atomic_cmpxchg(int old, int _new, volatile int *ptr) in __atomic_cmpxchg() argument
64 return __sync_val_compare_and_swap(ptr, old, _new) != old; in __atomic_cmpxchg()
68 __atomic_swap(int _new, volatile int *ptr) in __atomic_swap() argument
72 prev = *ptr; in __atomic_swap()
73 } while (__sync_val_compare_and_swap(ptr, prev, _new) != prev); in __atomic_swap()
78 __atomic_dec(volatile int *ptr) in __atomic_dec() argument
80 return __sync_fetch_and_sub (ptr, 1); in __atomic_dec()
84 __atomic_inc(volatile int *ptr) in __atomic_inc() argument
86 return __sync_fetch_and_add (ptr, 1); in __atomic_inc()
/bionic/libc/dns/include/
Dhostent.h67 #define HENT_ARRAY(dst, anum, ptr, len) \ argument
72 dst = (void *)ptr; \
73 ptr += _len; \
77 #define HENT_COPY(dst, src, slen, ptr, len) \ argument
81 memcpy(ptr, src, (size_t)slen); \
82 dst = ptr; \
83 ptr += slen; \
87 #define HENT_SCOPY(dst, src, ptr, len) \ argument
90 HENT_COPY(dst, src, _len, ptr, len); \
/bionic/libc/upstream-openbsd/lib/libc/stdlib/
Drecallocarray.c31 recallocarray(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size) in recallocarray() argument
36 if (ptr == NULL) in recallocarray()
61 memset((char *)ptr + newsize, 0, d); in recallocarray()
62 return ptr; in recallocarray()
71 memcpy(newptr, ptr, oldsize); in recallocarray()
74 memcpy(newptr, ptr, newsize); in recallocarray()
76 explicit_bzero(ptr, oldsize); in recallocarray()
77 free(ptr); in recallocarray()
/bionic/libc/upstream-netbsd/lib/libc/stdlib/
Dreallocarr.c57 reallocarr(void *ptr, size_t number, size_t size) in __weak_alias()
64 memcpy(&optr, ptr, sizeof(ptr)); in __weak_alias()
68 memcpy(ptr, &nptr, sizeof(ptr)); in __weak_alias()
90 memcpy(ptr, &nptr, sizeof(ptr)); in __weak_alias()
/bionic/libc/dns/net/
Dsethostent.c145 char *buf, *ptr; in _hf_gethtbyname2() local
161 if ((ptr = buf = malloc(len = info->buflen)) == NULL) { in _hf_gethtbyname2()
196 HENT_SCOPY(hent.h_name, hp->h_name, ptr, len); in _hf_gethtbyname2()
201 ptr, len); in _hf_gethtbyname2()
203 ptr = (void *)ALIGN(ptr); in _hf_gethtbyname2()
204 if ((size_t)(ptr - buf) >= info->buflen) in _hf_gethtbyname2()
210 HENT_COPY(addr_ptrs[num], hp->h_addr_list[0], hp->h_length, ptr, in _hf_gethtbyname2()
223 ptr = info->buf; in _hf_gethtbyname2()
229 HENT_ARRAY(hp->h_aliases, anum, ptr, len); in _hf_gethtbyname2()
230 HENT_ARRAY(hp->h_addr_list, num, ptr, len); in _hf_gethtbyname2()
[all …]
Dgethnamaddr.c210 #define BOUNDS_CHECK(ptr, count) \ argument
212 if (eom - (ptr) < (count)) \
588 char *ptr = hbuf; in android_read_hostent() local
591 if (ptr + size > hbuf_end) { in android_read_hostent()
594 if (fread(ptr, 1, size, proxy) != size) return NULL; in android_read_hostent()
595 hp->h_name = ptr; in android_read_hostent()
596 ptr += size; in android_read_hostent()
609 if (ptr + size > hbuf_end) { in android_read_hostent()
612 if (fread(ptr, 1, size, proxy) != size) return NULL; in android_read_hostent()
614 *aliases++ = ptr; in android_read_hostent()
[all …]
/bionic/benchmarks/
Dmalloc_benchmark.cpp50 void* ptr = malloc(size); in BM_mallopt_purge() local
51 if (ptr == nullptr) { in BM_mallopt_purge()
54 MakeAllocationResident(ptr, size, pagesize); in BM_mallopt_purge()
55 ptrs.push_back(ptr); in BM_mallopt_purge()
60 for (auto ptr : ptrs) { in BM_mallopt_purge() local
61 free(ptr); in BM_mallopt_purge()
Dutil.cpp36 uintptr_t ptr = reinterpret_cast<uintptr_t>(orig_ptr); in GetAlignedMemory() local
41 ptr += alignment - (ptr & (alignment - 1)); in GetAlignedMemory()
42 ptr |= alignment | or_mask; in GetAlignedMemory()
45 return reinterpret_cast<char*>(ptr); in GetAlignedMemory()
Dstdlib_benchmark.cpp32 void* ptr; in MallocFree() local
33 benchmark::DoNotOptimize(ptr = malloc(nbytes)); in MallocFree()
34 MakeAllocationResident(ptr, nbytes, pagesize); in MallocFree()
35 free(ptr); in MallocFree()
67 void* ptr; in CallocFree() local
68 benchmark::DoNotOptimize(ptr = calloc(1, nbytes)); in CallocFree()
69 MakeAllocationResident(ptr, nbytes, pagesize); in CallocFree()
70 free(ptr); in CallocFree()
/bionic/libc/dns/nameser/
Dns_parse.c82 ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) { in ns_skiprr() argument
83 const u_char *optr = ptr; in ns_skiprr()
88 b = dn_skipname(ptr, eom); in ns_skiprr()
91 ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/; in ns_skiprr()
93 if (ptr + NS_INT32SZ + NS_INT16SZ > eom) in ns_skiprr()
95 ptr += NS_INT32SZ/*TTL*/; in ns_skiprr()
96 NS_GET16(rdlength, ptr); in ns_skiprr()
97 ptr += rdlength/*RData*/; in ns_skiprr()
100 if (ptr > eom) in ns_skiprr()
102 _DIAGASSERT(__type_fit(int, ptr - optr)); in ns_skiprr()
[all …]
/bionic/libc/private/
Dbionic_allocator.h86 void free(void* ptr);
111 void* realloc(void* ptr, size_t size);
112 void free(void* ptr);
116 inline page_info* get_page_info_unchecked(void* ptr);
117 inline page_info* get_page_info(void* ptr);
/bionic/libc/system_properties/
Dcontexts_split.cpp123 static inline int read_spec_entry(char** entry, char** ptr, int* len) { in read_spec_entry() argument
127 while (isspace(**ptr) && **ptr != '\0') (*ptr)++; in read_spec_entry()
129 tmp_buf = *ptr; in read_spec_entry()
132 while (!isspace(**ptr) && **ptr != '\0') { in read_spec_entry()
133 (*ptr)++; in read_spec_entry()
/bionic/libc/malloc_hooks/
Dmalloc_hooks.cpp162 void* ptr = __malloc_hook(size, __builtin_return_address(0)); in hooks_calloc() local
163 if (ptr != nullptr) { in hooks_calloc()
164 memset(ptr, 0, size); in hooks_calloc()
166 return ptr; in hooks_calloc()
189 void* ptr = __memalign_hook(alignment, size, __builtin_return_address(0)); in hooks_aligned_alloc() local
190 if (ptr == nullptr) { in hooks_aligned_alloc()
193 return ptr; in hooks_aligned_alloc()

123