MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / my_malloc

Function my_malloc

mysys/my_malloc.c:28–67  ·  view source on GitHub ↗

Allocate a sized block of memory. @param size The size of the memory block in bytes. @param flags Failure action modifiers (bitmasks). @return A pointer to the allocated memory block, or NULL on failure. */

Source from the content-addressed store, hash-verified

26 @return A pointer to the allocated memory block, or NULL on failure.
27*/
28void *my_malloc(size_t size, myf my_flags)
29{
30 void* point;
31 DBUG_ENTER("my_malloc");
32 DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags));
33
34 /* Safety */
35 if (!size)
36 size=1;
37
38 point= malloc(size);
39 DBUG_EXECUTE_IF("simulate_out_of_memory",
40 {
41 free(point);
42 point= NULL;
43 });
44 DBUG_EXECUTE_IF("simulate_persistent_out_of_memory",
45 {
46 free(point);
47 point= NULL;
48 });
49
50 if (point == NULL)
51 {
52 my_errno=errno;
53 if (my_flags & MY_FAE)
54 error_handler_hook=fatal_error_handler_hook;
55 if (my_flags & (MY_FAE+MY_WME))
56 my_error(EE_OUTOFMEMORY, MYF(ME_BELL + ME_WAITTANG +
57 ME_NOREFRESH + ME_FATALERROR),size);
58 DBUG_EXECUTE_IF("simulate_out_of_memory",
59 DBUG_SET("-d,simulate_out_of_memory"););
60 if (my_flags & MY_FAE)
61 exit(1);
62 }
63 else if (my_flags & MY_ZEROFILL)
64 memset(point, 0, size);
65 DBUG_PRINT("exit",("ptr: %p", point));
66 DBUG_RETURN(point);
67}
68
69
70/**

Callers 15

create_shared_memoryFunction · 0.85
add_init_commandFunction · 0.85
cli_read_rowsFunction · 0.85
client.cFile · 0.85
cli_use_resultFunction · 0.85
date_time_format_copyFunction · 0.85
my_str_malloc_mysqldFunction · 0.85
ha_init_errorsFunction · 0.85
createMethod · 0.85
push_backMethod · 0.85

Calls 1

my_errorFunction · 0.85

Tested by 1

do_testFunction · 0.68