blob: 940c418cd67e79a801bb74af8f57cbe5c5f6d90e [file] [log] [blame]
Christopher Ferris63860cb2015-11-16 17:30:32 -08001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29// Contains a thin layer that calls whatever real native allocator
30// has been defined. For the libc shared library, this allows the
31// implementation of a debug malloc that can intercept all of the allocation
32// calls and add special debugging code to attempt to catch allocation
33// errors. All of the debugging code is implemented in a separate shared
34// library that is only loaded when the property "libc.debug.malloc.options"
35// is set to a non-zero value. There are two functions exported to
36// allow ddms, or other external users to get information from the debug
37// allocation.
38// get_malloc_leak_info: Returns information about all of the known native
39// allocations that are currently in use.
40// free_malloc_leak_info: Frees the data allocated by the call to
41// get_malloc_leak_info.
42
Colin Cross869691c2016-01-29 12:48:18 -080043#include <pthread.h>
44
Christopher Ferris63860cb2015-11-16 17:30:32 -080045#include <private/bionic_config.h>
46#include <private/bionic_globals.h>
47#include <private/bionic_malloc_dispatch.h>
48
49#include "jemalloc.h"
50#define Malloc(function) je_ ## function
51
52static constexpr MallocDispatch __libc_malloc_default_dispatch
53 __attribute__((unused)) = {
54 Malloc(calloc),
55 Malloc(free),
56 Malloc(mallinfo),
57 Malloc(malloc),
58 Malloc(malloc_usable_size),
59 Malloc(memalign),
60 Malloc(posix_memalign),
61#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
62 Malloc(pvalloc),
63#endif
64 Malloc(realloc),
65#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
66 Malloc(valloc),
67#endif
Colin Cross869691c2016-01-29 12:48:18 -080068 Malloc(iterate),
69 Malloc(malloc_disable),
70 Malloc(malloc_enable),
Christopher Ferrisa1c0d2f2017-05-15 15:50:19 -070071 Malloc(mallopt),
Christopher Ferriscae21a92018-02-05 18:14:55 -080072 Malloc(aligned_alloc),
Christopher Ferris63860cb2015-11-16 17:30:32 -080073 };
74
75// In a VM process, this is set to 1 after fork()ing out of zygote.
76int gMallocLeakZygoteChild = 0;
77
78// =============================================================================
79// Allocation functions
80// =============================================================================
81extern "C" void* calloc(size_t n_elements, size_t elem_size) {
82 auto _calloc = __libc_globals->malloc_dispatch.calloc;
83 if (__predict_false(_calloc != nullptr)) {
84 return _calloc(n_elements, elem_size);
85 }
86 return Malloc(calloc)(n_elements, elem_size);
87}
88
89extern "C" void free(void* mem) {
90 auto _free = __libc_globals->malloc_dispatch.free;
91 if (__predict_false(_free != nullptr)) {
92 _free(mem);
93 } else {
94 Malloc(free)(mem);
95 }
96}
97
98extern "C" struct mallinfo mallinfo() {
99 auto _mallinfo = __libc_globals->malloc_dispatch.mallinfo;
100 if (__predict_false(_mallinfo != nullptr)) {
101 return _mallinfo();
102 }
103 return Malloc(mallinfo)();
104}
105
Christopher Ferrisa1c0d2f2017-05-15 15:50:19 -0700106extern "C" int mallopt(int param, int value) {
107 auto _mallopt = __libc_globals->malloc_dispatch.mallopt;
108 if (__predict_false(_mallopt != nullptr)) {
109 return _mallopt(param, value);
110 }
111 return Malloc(mallopt)(param, value);
112}
113
Christopher Ferris63860cb2015-11-16 17:30:32 -0800114extern "C" void* malloc(size_t bytes) {
115 auto _malloc = __libc_globals->malloc_dispatch.malloc;
116 if (__predict_false(_malloc != nullptr)) {
117 return _malloc(bytes);
118 }
119 return Malloc(malloc)(bytes);
120}
121
122extern "C" size_t malloc_usable_size(const void* mem) {
123 auto _malloc_usable_size = __libc_globals->malloc_dispatch.malloc_usable_size;
124 if (__predict_false(_malloc_usable_size != nullptr)) {
125 return _malloc_usable_size(mem);
126 }
127 return Malloc(malloc_usable_size)(mem);
128}
129
130extern "C" void* memalign(size_t alignment, size_t bytes) {
131 auto _memalign = __libc_globals->malloc_dispatch.memalign;
132 if (__predict_false(_memalign != nullptr)) {
133 return _memalign(alignment, bytes);
134 }
135 return Malloc(memalign)(alignment, bytes);
136}
137
138extern "C" int posix_memalign(void** memptr, size_t alignment, size_t size) {
139 auto _posix_memalign = __libc_globals->malloc_dispatch.posix_memalign;
140 if (__predict_false(_posix_memalign != nullptr)) {
141 return _posix_memalign(memptr, alignment, size);
142 }
143 return Malloc(posix_memalign)(memptr, alignment, size);
144}
145
Christopher Ferriscae21a92018-02-05 18:14:55 -0800146extern "C" void* aligned_alloc(size_t alignment, size_t size) {
147 auto _aligned_alloc = __libc_globals->malloc_dispatch.aligned_alloc;
148 if (__predict_false(_aligned_alloc != nullptr)) {
149 return _aligned_alloc(alignment, size);
150 }
151 return Malloc(aligned_alloc)(alignment, size);
152}
153
Christopher Ferris63860cb2015-11-16 17:30:32 -0800154extern "C" void* realloc(void* old_mem, size_t bytes) {
155 auto _realloc = __libc_globals->malloc_dispatch.realloc;
156 if (__predict_false(_realloc != nullptr)) {
157 return _realloc(old_mem, bytes);
158 }
159 return Malloc(realloc)(old_mem, bytes);
160}
161
162#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
163extern "C" void* pvalloc(size_t bytes) {
164 auto _pvalloc = __libc_globals->malloc_dispatch.pvalloc;
165 if (__predict_false(_pvalloc != nullptr)) {
166 return _pvalloc(bytes);
167 }
168 return Malloc(pvalloc)(bytes);
169}
170
171extern "C" void* valloc(size_t bytes) {
172 auto _valloc = __libc_globals->malloc_dispatch.valloc;
173 if (__predict_false(_valloc != nullptr)) {
174 return _valloc(bytes);
175 }
176 return Malloc(valloc)(bytes);
177}
178#endif
179
180// We implement malloc debugging only in libc.so, so the code below
181// must be excluded if we compile this file for static libc.a
182#if !defined(LIBC_STATIC)
183
184#include <dlfcn.h>
Christopher Ferris63860cb2015-11-16 17:30:32 -0800185#include <stdio.h>
186#include <stdlib.h>
187
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700188#include <async_safe/log.h>
Christopher Ferris63860cb2015-11-16 17:30:32 -0800189#include <sys/system_properties.h>
190
191extern "C" int __cxa_atexit(void (*func)(void *), void *arg, void *dso);
192
193static const char* DEBUG_SHARED_LIB = "libc_malloc_debug.so";
194static const char* DEBUG_MALLOC_PROPERTY_OPTIONS = "libc.debug.malloc.options";
195static const char* DEBUG_MALLOC_PROPERTY_PROGRAM = "libc.debug.malloc.program";
Tamas Berghammerac81fe82016-08-26 15:54:59 +0100196static const char* DEBUG_MALLOC_ENV_OPTIONS = "LIBC_DEBUG_MALLOC_OPTIONS";
Christopher Ferris63860cb2015-11-16 17:30:32 -0800197
198static void* libc_malloc_impl_handle = nullptr;
199
200static void (*g_debug_finalize_func)();
201static void (*g_debug_get_malloc_leak_info_func)(uint8_t**, size_t*, size_t*, size_t*, size_t*);
202static void (*g_debug_free_malloc_leak_info_func)(uint8_t*);
Colin Cross2d4721c2016-02-02 11:57:54 -0800203static ssize_t (*g_debug_malloc_backtrace_func)(void*, uintptr_t*, size_t);
Christopher Ferris63860cb2015-11-16 17:30:32 -0800204
205// =============================================================================
206// Log functions
207// =============================================================================
208#define error_log(format, ...) \
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700209 async_safe_format_log(ANDROID_LOG_ERROR, "libc", (format), ##__VA_ARGS__ )
Christopher Ferris63860cb2015-11-16 17:30:32 -0800210#define info_log(format, ...) \
Christopher Ferris7a3681e2017-04-24 17:48:32 -0700211 async_safe_format_log(ANDROID_LOG_INFO, "libc", (format), ##__VA_ARGS__ )
Christopher Ferris63860cb2015-11-16 17:30:32 -0800212// =============================================================================
213
214// =============================================================================
215// Exported for use by ddms.
216// =============================================================================
217
218// Retrieve native heap information.
219//
220// "*info" is set to a buffer we allocate
221// "*overall_size" is set to the size of the "info" buffer
222// "*info_size" is set to the size of a single entry
223// "*total_memory" is set to the sum of all allocations we're tracking; does
224// not include heap overhead
225// "*backtrace_size" is set to the maximum number of entries in the back trace
226extern "C" void get_malloc_leak_info(uint8_t** info, size_t* overall_size,
227 size_t* info_size, size_t* total_memory, size_t* backtrace_size) {
228 if (g_debug_get_malloc_leak_info_func == nullptr) {
229 return;
230 }
231 g_debug_get_malloc_leak_info_func(info, overall_size, info_size, total_memory, backtrace_size);
232}
233
234extern "C" void free_malloc_leak_info(uint8_t* info) {
235 if (g_debug_free_malloc_leak_info_func == nullptr) {
236 return;
237 }
238 g_debug_free_malloc_leak_info_func(info);
239}
Colin Cross869691c2016-01-29 12:48:18 -0800240
Christopher Ferris63860cb2015-11-16 17:30:32 -0800241// =============================================================================
242
243template<typename FunctionType>
244static bool InitMallocFunction(void* malloc_impl_handler, FunctionType* func, const char* prefix, const char* suffix) {
245 char symbol[128];
246 snprintf(symbol, sizeof(symbol), "%s_%s", prefix, suffix);
247 *func = reinterpret_cast<FunctionType>(dlsym(malloc_impl_handler, symbol));
248 if (*func == nullptr) {
249 error_log("%s: dlsym(\"%s\") failed", getprogname(), symbol);
250 return false;
251 }
252 return true;
253}
254
255static bool InitMalloc(void* malloc_impl_handler, MallocDispatch* table, const char* prefix) {
256 if (!InitMallocFunction<MallocCalloc>(malloc_impl_handler, &table->calloc,
257 prefix, "calloc")) {
258 return false;
259 }
260 if (!InitMallocFunction<MallocFree>(malloc_impl_handler, &table->free,
261 prefix, "free")) {
262 return false;
263 }
264 if (!InitMallocFunction<MallocMallinfo>(malloc_impl_handler, &table->mallinfo,
265 prefix, "mallinfo")) {
266 return false;
267 }
Christopher Ferrisa1c0d2f2017-05-15 15:50:19 -0700268 if (!InitMallocFunction<MallocMallopt>(malloc_impl_handler, &table->mallopt,
269 prefix, "mallopt")) {
270 return false;
271 }
Christopher Ferris63860cb2015-11-16 17:30:32 -0800272 if (!InitMallocFunction<MallocMalloc>(malloc_impl_handler, &table->malloc,
273 prefix, "malloc")) {
274 return false;
275 }
276 if (!InitMallocFunction<MallocMallocUsableSize>(
277 malloc_impl_handler, &table->malloc_usable_size, prefix, "malloc_usable_size")) {
278 return false;
279 }
280 if (!InitMallocFunction<MallocMemalign>(malloc_impl_handler, &table->memalign,
281 prefix, "memalign")) {
282 return false;
283 }
284 if (!InitMallocFunction<MallocPosixMemalign>(malloc_impl_handler, &table->posix_memalign,
285 prefix, "posix_memalign")) {
286 return false;
287 }
Christopher Ferriscae21a92018-02-05 18:14:55 -0800288 if (!InitMallocFunction<MallocAlignedAlloc>(malloc_impl_handler, &table->aligned_alloc,
289 prefix, "aligned_alloc")) {
290 return false;
291 }
Christopher Ferris63860cb2015-11-16 17:30:32 -0800292 if (!InitMallocFunction<MallocRealloc>(malloc_impl_handler, &table->realloc,
293 prefix, "realloc")) {
294 return false;
295 }
Colin Cross869691c2016-01-29 12:48:18 -0800296 if (!InitMallocFunction<MallocIterate>(malloc_impl_handler, &table->iterate,
297 prefix, "iterate")) {
298 return false;
299 }
300 if (!InitMallocFunction<MallocMallocDisable>(malloc_impl_handler, &table->malloc_disable,
301 prefix, "malloc_disable")) {
302 return false;
303 }
304 if (!InitMallocFunction<MallocMallocEnable>(malloc_impl_handler, &table->malloc_enable,
305 prefix, "malloc_enable")) {
306 return false;
307 }
Christopher Ferris63860cb2015-11-16 17:30:32 -0800308#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
309 if (!InitMallocFunction<MallocPvalloc>(malloc_impl_handler, &table->pvalloc,
310 prefix, "pvalloc")) {
311 return false;
312 }
313 if (!InitMallocFunction<MallocValloc>(malloc_impl_handler, &table->valloc,
314 prefix, "valloc")) {
315 return false;
316 }
317#endif
318
319 return true;
320}
321
322static void malloc_fini_impl(void*) {
323 // Our BSD stdio implementation doesn't close the standard streams,
324 // it only flushes them. Other unclosed FILE*s will show up as
325 // malloc leaks, but to avoid the standard streams showing up in
326 // leak reports, close them here.
327 fclose(stdin);
328 fclose(stdout);
329 fclose(stderr);
330
331 g_debug_finalize_func();
332}
333
334// Initializes memory allocation framework once per process.
335static void malloc_init_impl(libc_globals* globals) {
336 char value[PROP_VALUE_MAX];
Christopher Ferris63860cb2015-11-16 17:30:32 -0800337
Tamas Berghammerac81fe82016-08-26 15:54:59 +0100338 // If DEBUG_MALLOC_ENV_OPTIONS is set then it overrides the system properties.
339 const char* options = getenv(DEBUG_MALLOC_ENV_OPTIONS);
340 if (options == nullptr || options[0] == '\0') {
341 if (__system_property_get(DEBUG_MALLOC_PROPERTY_OPTIONS, value) == 0 || value[0] == '\0') {
342 return;
343 }
344 options = value;
Christopher Ferris63860cb2015-11-16 17:30:32 -0800345
Tamas Berghammerac81fe82016-08-26 15:54:59 +0100346 // Check to see if only a specific program should have debug malloc enabled.
347 char program[PROP_VALUE_MAX];
348 if (__system_property_get(DEBUG_MALLOC_PROPERTY_PROGRAM, program) != 0 &&
349 strstr(getprogname(), program) == nullptr) {
350 return;
351 }
Christopher Ferris63860cb2015-11-16 17:30:32 -0800352 }
353
354 // Load the debug malloc shared library.
355 void* malloc_impl_handle = dlopen(DEBUG_SHARED_LIB, RTLD_NOW | RTLD_LOCAL);
356 if (malloc_impl_handle == nullptr) {
357 error_log("%s: Unable to open debug malloc shared library %s: %s",
358 getprogname(), DEBUG_SHARED_LIB, dlerror());
359 return;
360 }
361
362 // Initialize malloc debugging in the loaded module.
Tamas Berghammerac81fe82016-08-26 15:54:59 +0100363 auto init_func = reinterpret_cast<bool (*)(const MallocDispatch*, int*, const char*)>(
Christopher Ferris20f2c1e2016-03-11 12:27:02 -0800364 dlsym(malloc_impl_handle, "debug_initialize"));
Christopher Ferris63860cb2015-11-16 17:30:32 -0800365 if (init_func == nullptr) {
366 error_log("%s: debug_initialize routine not found in %s", getprogname(), DEBUG_SHARED_LIB);
367 dlclose(malloc_impl_handle);
368 return;
369 }
370
371 // Get the syms for the external functions.
Christopher Ferris20f2c1e2016-03-11 12:27:02 -0800372 void* finalize_sym = dlsym(malloc_impl_handle, "debug_finalize");
373 if (finalize_sym == nullptr) {
Christopher Ferris63860cb2015-11-16 17:30:32 -0800374 error_log("%s: debug_finalize routine not found in %s", getprogname(), DEBUG_SHARED_LIB);
375 dlclose(malloc_impl_handle);
376 return;
377 }
Christopher Ferris63860cb2015-11-16 17:30:32 -0800378
Christopher Ferris20f2c1e2016-03-11 12:27:02 -0800379 void* get_leak_info_sym = dlsym(malloc_impl_handle, "debug_get_malloc_leak_info");
380 if (get_leak_info_sym == nullptr) {
Christopher Ferris63860cb2015-11-16 17:30:32 -0800381 error_log("%s: debug_get_malloc_leak_info routine not found in %s", getprogname(),
382 DEBUG_SHARED_LIB);
383 dlclose(malloc_impl_handle);
384 return;
385 }
Christopher Ferris63860cb2015-11-16 17:30:32 -0800386
Christopher Ferris20f2c1e2016-03-11 12:27:02 -0800387 void* free_leak_info_sym = dlsym(malloc_impl_handle, "debug_free_malloc_leak_info");
388 if (free_leak_info_sym == nullptr) {
Christopher Ferris63860cb2015-11-16 17:30:32 -0800389 error_log("%s: debug_free_malloc_leak_info routine not found in %s", getprogname(),
390 DEBUG_SHARED_LIB);
391 dlclose(malloc_impl_handle);
392 return;
393 }
Christopher Ferris63860cb2015-11-16 17:30:32 -0800394
Christopher Ferris20f2c1e2016-03-11 12:27:02 -0800395 void* malloc_backtrace_sym = dlsym(malloc_impl_handle, "debug_malloc_backtrace");
396 if (malloc_backtrace_sym == nullptr) {
Colin Cross2d4721c2016-02-02 11:57:54 -0800397 error_log("%s: debug_malloc_backtrace routine not found in %s", getprogname(),
398 DEBUG_SHARED_LIB);
399 dlclose(malloc_impl_handle);
400 return;
401 }
Colin Cross2d4721c2016-02-02 11:57:54 -0800402
Tamas Berghammerac81fe82016-08-26 15:54:59 +0100403 if (!init_func(&__libc_malloc_default_dispatch, &gMallocLeakZygoteChild, options)) {
Christopher Ferris63860cb2015-11-16 17:30:32 -0800404 dlclose(malloc_impl_handle);
405 return;
406 }
407
408 MallocDispatch malloc_dispatch_table;
409 if (!InitMalloc(malloc_impl_handle, &malloc_dispatch_table, "debug")) {
Christopher Ferris20f2c1e2016-03-11 12:27:02 -0800410 auto finalize_func = reinterpret_cast<void (*)()>(finalize_sym);
411 finalize_func();
Christopher Ferris63860cb2015-11-16 17:30:32 -0800412 dlclose(malloc_impl_handle);
413 return;
414 }
415
Christopher Ferris20f2c1e2016-03-11 12:27:02 -0800416 g_debug_finalize_func = reinterpret_cast<void (*)()>(finalize_sym);
417 g_debug_get_malloc_leak_info_func = reinterpret_cast<void (*)(
418 uint8_t**, size_t*, size_t*, size_t*, size_t*)>(get_leak_info_sym);
419 g_debug_free_malloc_leak_info_func = reinterpret_cast<void (*)(uint8_t*)>(free_leak_info_sym);
420 g_debug_malloc_backtrace_func = reinterpret_cast<ssize_t (*)(
421 void*, uintptr_t*, size_t)>(malloc_backtrace_sym);
422
Christopher Ferris63860cb2015-11-16 17:30:32 -0800423 globals->malloc_dispatch = malloc_dispatch_table;
424 libc_malloc_impl_handle = malloc_impl_handle;
425
426 info_log("%s: malloc debug enabled", getprogname());
427
428 // Use atexit to trigger the cleanup function. This avoids a problem
429 // where another atexit function is used to cleanup allocated memory,
430 // but the finalize function was already called. This particular error
431 // seems to be triggered by a zygote spawned process calling exit.
432 int ret_value = __cxa_atexit(malloc_fini_impl, nullptr, nullptr);
433 if (ret_value != 0) {
434 error_log("failed to set atexit cleanup function: %d", ret_value);
435 }
436}
437
438// Initializes memory allocation framework.
439// This routine is called from __libc_init routines in libc_init_dynamic.cpp.
440__LIBC_HIDDEN__ void __libc_init_malloc(libc_globals* globals) {
441 malloc_init_impl(globals);
442}
443#endif // !LIBC_STATIC
Colin Cross869691c2016-01-29 12:48:18 -0800444
445// =============================================================================
446// Exported for use by libmemunreachable.
447// =============================================================================
448
449// Calls callback for every allocation in the anonymous heap mapping
450// [base, base+size). Must be called between malloc_disable and malloc_enable.
451extern "C" int malloc_iterate(uintptr_t base, size_t size,
452 void (*callback)(uintptr_t base, size_t size, void* arg), void* arg) {
453 auto _iterate = __libc_globals->malloc_dispatch.iterate;
454 if (__predict_false(_iterate != nullptr)) {
455 return _iterate(base, size, callback, arg);
456 }
457 return Malloc(iterate)(base, size, callback, arg);
458}
459
460// Disable calls to malloc so malloc_iterate gets a consistent view of
461// allocated memory.
462extern "C" void malloc_disable() {
463 auto _malloc_disable = __libc_globals->malloc_dispatch.malloc_disable;
464 if (__predict_false(_malloc_disable != nullptr)) {
465 return _malloc_disable();
466 }
467 return Malloc(malloc_disable)();
468}
469
470// Re-enable calls to malloc after a previous call to malloc_disable.
471extern "C" void malloc_enable() {
472 auto _malloc_enable = __libc_globals->malloc_dispatch.malloc_enable;
473 if (__predict_false(_malloc_enable != nullptr)) {
474 return _malloc_enable();
475 }
476 return Malloc(malloc_enable)();
477}
Colin Cross2d4721c2016-02-02 11:57:54 -0800478
479#ifndef LIBC_STATIC
480extern "C" ssize_t malloc_backtrace(void* pointer, uintptr_t* frames, size_t frame_count) {
481 if (g_debug_malloc_backtrace_func == nullptr) {
482 return 0;
483 }
484 return g_debug_malloc_backtrace_func(pointer, frames, frame_count);
485}
486#else
487extern "C" ssize_t malloc_backtrace(void*, uintptr_t*, size_t) {
488 return 0;
489}
490#endif