PostgreSQL Source Code git master
Loading...
Searching...
No Matches
fe_memutils.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MaxAllocSize   ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
 
#define MCXT_ALLOC_HUGE
 
#define MCXT_ALLOC_NO_OOM   0x02 /* no failure if out-of-memory */
 
#define MCXT_ALLOC_ZERO   0x04 /* zero allocated memory */
 
#define pg_malloc_object(type)   ((type *) pg_malloc(sizeof(type)))
 
#define pg_malloc0_object(type)   ((type *) pg_malloc0(sizeof(type)))
 
#define pg_malloc_array(type, count)   ((type *) pg_malloc_mul(sizeof(type), count))
 
#define pg_malloc0_array(type, count)   ((type *) pg_malloc0_mul(sizeof(type), count))
 
#define pg_malloc_array_extended(type, count, flags)   ((type *) pg_malloc_mul_extended(sizeof(type), count, flags))
 
#define pg_realloc_array(pointer, type, count)   ((type *) pg_realloc_mul(pointer, sizeof(type), count))
 
#define palloc_object(type)   ((type *) palloc(sizeof(type)))
 
#define palloc0_object(type)   ((type *) palloc0(sizeof(type)))
 
#define palloc_array(type, count)   ((type *) palloc_mul(sizeof(type), count))
 
#define palloc0_array(type, count)   ((type *) palloc0_mul(sizeof(type), count))
 
#define palloc_array_extended(type, count, flags)   ((type *) palloc_mul_extended(sizeof(type), count, flags))
 
#define repalloc_array(pointer, type, count)   ((type *) repalloc_mul(pointer, sizeof(type), count))
 

Functions

charpg_strdup (const char *in)
 
voidpg_malloc (size_t size)
 
voidpg_malloc0 (size_t size)
 
voidpg_malloc_extended (size_t size, int flags)
 
voidpg_realloc (void *ptr, size_t size)
 
void pg_free (void *ptr)
 
Size add_size (Size s1, Size s2)
 
Size mul_size (Size s1, Size s2)
 
voidpg_malloc_mul (Size s1, Size s2)
 
voidpg_malloc0_mul (Size s1, Size s2)
 
voidpg_malloc_mul_extended (Size s1, Size s2, int flags)
 
voidpg_realloc_mul (void *p, Size s1, Size s2)
 
charpstrdup (const char *in)
 
charpnstrdup (const char *in, Size size)
 
voidpalloc (Size size)
 
voidpalloc0 (Size size)
 
voidpalloc_extended (Size size, int flags)
 
voidrepalloc (void *pointer, Size size)
 
void pfree (void *pointer)
 
voidpalloc_mul (Size s1, Size s2)
 
voidpalloc0_mul (Size s1, Size s2)
 
voidpalloc_mul_extended (Size s1, Size s2, int flags)
 
voidrepalloc_mul (void *p, Size s1, Size s2)
 
charpsprintf (const char *fmt,...) pg_attribute_printf(1
 
char size_t pvsnprintf (char *buf, size_t len, const char *fmt, va_list args) pg_attribute_printf(3
 

Macro Definition Documentation

◆ MaxAllocSize

#define MaxAllocSize   ((Size) 0x3fffffff) /* 1 gigabyte - 1 */

Definition at line 22 of file fe_memutils.h.

◆ MCXT_ALLOC_HUGE

#define MCXT_ALLOC_HUGE
Value:
0x01 /* allow huge allocation (> 1 GB) not
* actually used for frontends */

Definition at line 28 of file fe_memutils.h.

◆ MCXT_ALLOC_NO_OOM

#define MCXT_ALLOC_NO_OOM   0x02 /* no failure if out-of-memory */

Definition at line 29 of file fe_memutils.h.

◆ MCXT_ALLOC_ZERO

#define MCXT_ALLOC_ZERO   0x04 /* zero allocated memory */

Definition at line 30 of file fe_memutils.h.

◆ palloc0_array

#define palloc0_array (   type,
  count 
)    ((type *) palloc0_mul(sizeof(type), count))

Definition at line 92 of file fe_memutils.h.

◆ palloc0_object

#define palloc0_object (   type)    ((type *) palloc0(sizeof(type)))

Definition at line 90 of file fe_memutils.h.

◆ palloc_array

#define palloc_array (   type,
  count 
)    ((type *) palloc_mul(sizeof(type), count))

Definition at line 91 of file fe_memutils.h.

◆ palloc_array_extended

#define palloc_array_extended (   type,
  count,
  flags 
)    ((type *) palloc_mul_extended(sizeof(type), count, flags))

Definition at line 93 of file fe_memutils.h.

◆ palloc_object

#define palloc_object (   type)    ((type *) palloc(sizeof(type)))

Definition at line 89 of file fe_memutils.h.

◆ pg_malloc0_array

#define pg_malloc0_array (   type,
  count 
)    ((type *) pg_malloc0_mul(sizeof(type), count))

Definition at line 67 of file fe_memutils.h.

◆ pg_malloc0_object

#define pg_malloc0_object (   type)    ((type *) pg_malloc0(sizeof(type)))

Definition at line 61 of file fe_memutils.h.

◆ pg_malloc_array

#define pg_malloc_array (   type,
  count 
)    ((type *) pg_malloc_mul(sizeof(type), count))

Definition at line 66 of file fe_memutils.h.

◆ pg_malloc_array_extended

#define pg_malloc_array_extended (   type,
  count,
  flags 
)    ((type *) pg_malloc_mul_extended(sizeof(type), count, flags))

Definition at line 68 of file fe_memutils.h.

◆ pg_malloc_object

#define pg_malloc_object (   type)    ((type *) pg_malloc(sizeof(type)))

Definition at line 60 of file fe_memutils.h.

◆ pg_realloc_array

#define pg_realloc_array (   pointer,
  type,
  count 
)    ((type *) pg_realloc_mul(pointer, sizeof(type), count))

Definition at line 74 of file fe_memutils.h.

◆ repalloc_array

#define repalloc_array (   pointer,
  type,
  count 
)    ((type *) repalloc_mul(pointer, sizeof(type), count))

Definition at line 94 of file fe_memutils.h.

Function Documentation

◆ add_size()

Size add_size ( Size  s1,
Size  s2 
)
extern

Definition at line 1733 of file mcxt.c.

1734{
1735 Size result;
1736
1739 return result;
1740}
#define unlikely(x)
Definition c.h:438
size_t Size
Definition c.h:689
uint32 result
static bool pg_add_size_overflow(size_t a, size_t b, size_t *result)
Definition int.h:608
static pg_noreturn pg_noinline void add_size_error(Size s1, Size s2)
Definition mcxt.c:1743
char * s1
char * s2

◆ mul_size()

Size mul_size ( Size  s1,
Size  s2 
)
extern

Definition at line 1752 of file mcxt.c.

1753{
1754 Size result;
1755
1758 return result;
1759}
static bool pg_mul_size_overflow(size_t a, size_t b, size_t *result)
Definition int.h:642
static pg_noreturn pg_noinline void mul_size_error(Size s1, Size s2)
Definition mcxt.c:1762

◆ palloc()

void * palloc ( Size  size)
extern

Definition at line 1390 of file mcxt.c.

1391{
1392 /* duplicates MemoryContextAlloc to avoid increased overhead */
1393 void *ret;
1395
1396 Assert(MemoryContextIsValid(context));
1398
1399 context->isReset = false;
1400
1401 /*
1402 * For efficiency reasons, we purposefully offload the handling of
1403 * allocation failures to the MemoryContextMethods implementation as this
1404 * allows these checks to be performed only when an actual malloc needs to
1405 * be done to request more memory from the OS. Additionally, not having
1406 * to execute any instructions after this call allows the compiler to use
1407 * the sibling call optimization. If you're considering adding code after
1408 * this call, consider making it the responsibility of the 'alloc'
1409 * function instead.
1410 */
1411 ret = context->methods->alloc(context, size, 0);
1412 /* We expect OOM to be handled by the alloc function */
1413 Assert(ret != NULL);
1414 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
1415
1416 return ret;
1417}
#define Assert(condition)
Definition c.h:943
#define AssertNotInCriticalSection(context)
Definition mcxt.c:198
MemoryContext CurrentMemoryContext
Definition mcxt.c:161
#define VALGRIND_MEMPOOL_ALLOC(context, addr, size)
Definition memdebug.h:29
#define MemoryContextIsValid(context)
Definition memnodes.h:145
static int fb(int x)
const MemoryContextMethods * methods
Definition memnodes.h:126
void *(* alloc)(MemoryContext context, Size size, int flags)
Definition memnodes.h:66

◆ palloc0()

void * palloc0 ( Size  size)
extern

Definition at line 1420 of file mcxt.c.

1421{
1422 /* duplicates MemoryContextAllocZero to avoid increased overhead */
1423 void *ret;
1425
1426 Assert(MemoryContextIsValid(context));
1428
1429 context->isReset = false;
1430
1431 ret = context->methods->alloc(context, size, 0);
1432 /* We expect OOM to be handled by the alloc function */
1433 Assert(ret != NULL);
1434 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
1435
1436 MemSetAligned(ret, 0, size);
1437
1438 return ret;
1439}
#define MemSetAligned(start, val, len)
Definition c.h:1137

◆ palloc0_mul()

void * palloc0_mul ( Size  s1,
Size  s2 
)
extern

Definition at line 1792 of file mcxt.c.

1793{
1794 /* inline mul_size() for efficiency */
1795 Size req;
1796
1799 return palloc0(req);
1800}
void * palloc0(Size size)
Definition mcxt.c:1420

◆ palloc_extended()

void * palloc_extended ( Size  size,
int  flags 
)
extern

Definition at line 1442 of file mcxt.c.

1443{
1444 /* duplicates MemoryContextAllocExtended to avoid increased overhead */
1445 void *ret;
1447
1448 Assert(MemoryContextIsValid(context));
1450
1451 context->isReset = false;
1452
1453 ret = context->methods->alloc(context, size, flags);
1454 if (unlikely(ret == NULL))
1455 {
1456 /* NULL can be returned only when using MCXT_ALLOC_NO_OOM */
1457 Assert(flags & MCXT_ALLOC_NO_OOM);
1458 return NULL;
1459 }
1460
1461 VALGRIND_MEMPOOL_ALLOC(context, ret, size);
1462
1463 if ((flags & MCXT_ALLOC_ZERO) != 0)
1464 MemSetAligned(ret, 0, size);
1465
1466 return ret;
1467}
#define MCXT_ALLOC_ZERO
Definition fe_memutils.h:30
#define MCXT_ALLOC_NO_OOM
Definition fe_memutils.h:29

◆ palloc_mul()

void * palloc_mul ( Size  s1,
Size  s2 
)
extern

Definition at line 1775 of file mcxt.c.

1776{
1777 /* inline mul_size() for efficiency */
1778 Size req;
1779
1782 return palloc(req);
1783}
void * palloc(Size size)
Definition mcxt.c:1390

◆ palloc_mul_extended()

void * palloc_mul_extended ( Size  s1,
Size  s2,
int  flags 
)
extern

Definition at line 1807 of file mcxt.c.

1808{
1809 /* inline mul_size() for efficiency */
1810 Size req;
1811
1814 return palloc_extended(req, flags);
1815}
void * palloc_extended(Size size, int flags)
Definition mcxt.c:1442

◆ pfree()

void pfree ( void pointer)
extern

Definition at line 1619 of file mcxt.c.

1620{
1621#ifdef USE_VALGRIND
1622 MemoryContext context = GetMemoryChunkContext(pointer);
1623#endif
1624
1625 MCXT_METHOD(pointer, free_p) (pointer);
1626
1627 VALGRIND_MEMPOOL_FREE(context, pointer);
1628}
MemoryContext GetMemoryChunkContext(void *pointer)
Definition mcxt.c:759
#define MCXT_METHOD(pointer, method)
Definition mcxt.c:205
#define VALGRIND_MEMPOOL_FREE(context, addr)
Definition memdebug.h:30

◆ pg_free()

void pg_free ( void ptr)
extern

Definition at line 111 of file fe_memutils.c.

112{
113 free(ptr);
114}
#define free(a)

References free.

Referenced by _printTocEntry(), advanceConnectionState(), append_depends_on_extension(), appendQualifiedRelation(), avlFree(), bool_substitute_hook(), calculate_totals(), check_exec(), check_for_data_types_usage(), check_for_incompatible_polymorphics(), check_publisher(), checksum_file(), close_walfile(), copy_file_blocks(), copyFile(), create_script_for_old_cluster_deletion(), datapagemap_print(), dir_close(), dir_free(), dir_open_for_write(), do_connect(), do_watch(), dropDBs(), dumpFunc(), dumpRoleMembership(), dumpSequence(), EndCompressor(), EndCompressorNone(), FindStreamingStart(), free_archive_reader(), free_command(), free_db_and_rel_infos(), free_rel_infos(), free_retrieved_objects(), free_socket_set(), FreeSlruRead(), FreeSlruWrite(), get_control_data(), get_db_rel_and_slot_infos(), get_loadable_libraries(), get_publisher_databases(), get_restricted_token(), get_standby_sysid(), getTimelineHistory(), icu_language_tag(), init_libpq_conn(), IssueACLPerBlob(), IssueCommandPerBlob(), libpq_get_current_wal_insert_lsn(), listSchemas(), main(), make_rfile(), makeAlterConfigCommand(), modify_subscriber_sysid(), open_walfile(), parallel_exec_prog(), parallel_transfer_all_new_dbs(), parseAclItem(), parseCommandLine(), parseQuery(), perform_rewind(), pfree(), printCrosstab(), PrintResultInCrosstab(), process_queued_fetch_requests(), rankSort(), readCommandResponse(), ReadHead(), readMessageFromPipe(), ReceiveXlogStream(), reconstruct_from_incremental_file(), reindex_one_database(), restore_all_databases(), RestoreArchive(), retrieve_objects(), run_schedule(), SendQuery(), set_replication_progress(), setlocales(), setup_publisher(), SetVariable(), simple_oid_list_destroy(), simple_ptr_list_destroy(), simple_string_list_destroy(), SlruReadSwitchPageSlow(), SlruWriteSwitchPageSlow(), SortTocFromFile(), SyncVariables(), tar_close(), tar_free(), tar_open_for_write(), test_gb18030_page_multiple(), transfer_all_new_dbs(), upgrade_task_free(), upgrade_task_run(), vacuum_all_databases(), vacuum_one_database(), verify_tar_file(), WriteDataChunks(), and WriteToc().

◆ pg_malloc()

◆ pg_malloc0()

void * pg_malloc0 ( size_t  size)
extern

◆ pg_malloc0_mul()

void * pg_malloc0_mul ( Size  s1,
Size  s2 
)
extern

Definition at line 256 of file fe_memutils.c.

257{
258 /* inline mul_size() for efficiency */
259 Size req;
260
262 req > (SIZE_MAX / 2)))
264 return pg_malloc0(req);
265}
static pg_noreturn pg_noinline void mul_size_error(Size s1, Size s2)
void * pg_malloc0(size_t size)
Definition fe_memutils.c:59

References fb(), mul_size_error(), pg_malloc0(), pg_mul_size_overflow(), s1, s2, and unlikely.

◆ pg_malloc_extended()

void * pg_malloc_extended ( size_t  size,
int  flags 
)
extern

Definition at line 65 of file fe_memutils.c.

66{
67 return pg_malloc_internal(size, flags);
68}

References pg_malloc_internal().

Referenced by do_lo_import(), pg_log_generic_v(), and pg_malloc_mul_extended().

◆ pg_malloc_mul()

void * pg_malloc_mul ( Size  s1,
Size  s2 
)
extern

Definition at line 238 of file fe_memutils.c.

239{
240 /* inline mul_size() for efficiency */
241 Size req;
242
244 req > (SIZE_MAX / 2)))
246 return pg_malloc(req);
247}
void * pg_malloc(size_t size)
Definition fe_memutils.c:53

References fb(), mul_size_error(), pg_malloc(), pg_mul_size_overflow(), s1, s2, and unlikely.

◆ pg_malloc_mul_extended()

void * pg_malloc_mul_extended ( Size  s1,
Size  s2,
int  flags 
)
extern

Definition at line 272 of file fe_memutils.c.

273{
274 /* inline mul_size() for efficiency */
275 Size req;
276
278 req > (SIZE_MAX / 2)))
280 return pg_malloc_extended(req, flags);
281}
void * pg_malloc_extended(size_t size, int flags)
Definition fe_memutils.c:65

References fb(), mul_size_error(), pg_malloc_extended(), pg_mul_size_overflow(), s1, s2, and unlikely.

◆ pg_realloc()

void * pg_realloc ( void ptr,
size_t  size 
)
extern

Definition at line 71 of file fe_memutils.c.

72{
73 void *tmp;
74
75 /* Avoid unportable behavior of realloc(NULL, 0) */
76 if (ptr == NULL && size == 0)
77 size = 1;
78 tmp = realloc(ptr, size);
79 if (!tmp)
80 {
81 fprintf(stderr, _("out of memory\n"));
83 }
84 return tmp;
85}
#define fprintf(file, fmt, msg)
Definition cubescan.l:21
#define _(x)
Definition elog.c:96
#define EXIT_FAILURE
Definition settings.h:197
#define realloc(a, b)

References _, EXIT_FAILURE, fb(), fprintf, and realloc.

Referenced by addlitchar(), datapagemap_add(), exec_command_set(), icu_language_tag(), main(), pg_realloc_mul(), read_file_contents(), readMessageFromPipe(), repalloc(), and replaceVariable().

◆ pg_realloc_mul()

void * pg_realloc_mul ( void p,
Size  s1,
Size  s2 
)
extern

Definition at line 288 of file fe_memutils.c.

289{
290 /* inline mul_size() for efficiency */
291 Size req;
292
294 req > (SIZE_MAX / 2)))
296 return pg_realloc(p, req);
297}
void * pg_realloc(void *ptr, size_t size)
Definition fe_memutils.c:71

References fb(), mul_size_error(), pg_mul_size_overflow(), pg_realloc(), s1, s2, and unlikely.

◆ pg_strdup()

char * pg_strdup ( const char in)
extern

Definition at line 91 of file fe_memutils.c.

92{
93 char *tmp;
94
95 if (!in)
96 {
98 _("cannot duplicate null pointer (internal error)\n"));
100 }
101 tmp = strdup(in);
102 if (!tmp)
103 {
104 fprintf(stderr, _("out of memory\n"));
106 }
107 return tmp;
108}

References _, EXIT_FAILURE, fb(), and fprintf.

Referenced by _allocAH(), _ArchiveEntry(), _ArchiveEntry(), _becomeUser(), _check_database_version(), _getObjectDescription(), _selectOutputSchema(), _selectTableAccessMethod(), _selectTablespace(), _tarGetHeader(), add_one_elt(), add_stringlist_item(), add_stringlist_item(), adjust_data_dir(), adjust_data_dir(), append_depends_on_extension(), ArchiveEntry(), bool_substitute_hook(), check_locale_name(), check_publisher(), check_required_directory(), check_subscriber(), CloneArchive(), collectComments(), collectRoleNames(), collectSecLabels(), comp_keyword_case_substitute_hook(), concat_conninfo_dbname(), ConnectDatabaseAhx(), constructConnStr(), convertRegProcReference(), convertTSFunction(), create_logical_replication_slot(), create_script_for_old_cluster_deletion(), createBoundaryObjects(), CreateWalDirectoryMethod(), describeOneTableDetails(), describeRoles(), dir_open_for_write(), do_pset(), dumpAccessMethod(), dumpAttrDef(), dumpBaseType(), dumpCollation(), dumpCompositeType(), dumpConstraint(), dumpConversion(), dumpDatabase(), dumpDomain(), dumpEnumType(), dumpEventTrigger(), dumpExtension(), dumpForeignDataWrapper(), dumpForeignServer(), dumpIndex(), dumpNamespace(), dumpOpclass(), dumpOpfamily(), dumpOptionsFromRestoreOptions(), dumpPolicy(), dumpProcLang(), dumpPublication(), dumpRangeType(), dumpRoleGUCPrivs(), dumpRule(), dumpSearchPath(), dumpSequence(), dumpStatisticsExt(), dumpSubscription(), dumpTable(), dumpTableConstraintComment(), dumpTableData(), dumpTableSchema(), dumpTablespaces(), dumpTrigger(), dumpTSConfig(), dumpTSDictionary(), dumpTSParser(), dumpTSTemplate(), dumpUndefinedType(), echo_substitute_hook(), encodingid_to_string(), exec_command_g(), exec_command_gset(), exec_command_password(), exec_command_set(), fetch_count_substitute_hook(), find_matching_ts_config(), FindDbnameInConnOpts(), fix_path_separator(), flagInhAttrs(), flagInhIndexes(), flagInhTables(), format_numeric_locale(), get_base_conninfo(), get_comma_elts(), get_conninfo_value(), get_control_data(), get_db_infos(), get_id(), get_language_name(), get_loadable_libraries(), get_opts(), get_restricted_token(), get_sock_dir(), get_sub_conninfo(), get_synchronized_snapshot(), get_tablespace_paths(), get_template0_info(), get_user_info(), getAccessMethods(), getAggregates(), getCollations(), getConstraints(), getConversions(), getDefaultACLs(), getDomainConstraints(), getEventTriggers(), getExtendedStatistics(), getExtensions(), getForeignDataWrappers(), getForeignServers(), getFormattedTypeName(), getFuncs(), getIndexes(), getLOs(), getNamespaces(), getOpclasses(), getOperators(), getOpfamilies(), getPolicies(), getProcLangs(), getPublications(), getPublicationTables(), getRelationStatistics(), getRules(), gets_fromFile(), getSubscriptionRelations(), getSubscriptions(), getTableAttrs(), getTables(), getTriggers(), getTSConfigurations(), getTSDictionaries(), getTSParsers(), getTSTemplates(), getTypes(), getVariable(), handle_args(), histcontrol_substitute_hook(), histsize_substitute_hook(), identify_target_directory(), ignoreeof_substitute_hook(), InitDiscoverCompressFileHandle(), initializeInput(), insert_filehash_entry(), IssueACLPerBlob(), IssueCommandPerBlob(), keepwal_add_entry(), listSchemas(), load_resultmap(), lookupCreateVariable(), main(), main(), MainLoop(), makeAlterConfigCommand(), open_result_files(), parallel_exec_prog(), parallel_transfer_all_new_dbs(), parse_psql_options(), parse_slash_copy(), parseAclItem(), parseCommandLine(), parseQuery(), ParseScript(), parseScriptWeight(), pg_send_history(), postprocess_sql_command(), printTableAddFooter(), printTableSetFooter(), process_backslash_command(), process_old_cluster_logical_slot_infos(), process_rel_infos(), process_source_file(), process_target_file(), processEncodingEntry(), processExtensionTables(), processSearchPathEntry(), progress_update_filename(), psql_get_variable(), psqlscan_push_new_buffer(), pstrdup(), putVariable(), read_post_opts(), readfile(), ReconnectToServer(), regression_main(), RestoreArchive(), run_schedule(), run_simple_query(), RunIdentifySystem(), sanitize_line(), save_global_locale(), savePsetInfo(), search_directory(), sendCommand(), set_info_version(), setDecimalLocale(), setup(), setup_config(), setup_connection(), setup_pgdata(), setup_publisher(), SetVariable(), SetVariableHooks(), show_context_substitute_hook(), simple_action_list_append(), simple_prompt_extended(), split_path(), split_to_stringlist(), tar_open_for_write(), tarOpen(), verbosity_substitute_hook(), and watch_interval_substitute_hook().

◆ pnstrdup()

char * pnstrdup ( const char in,
Size  size 
)
extern

Definition at line 1921 of file mcxt.c.

1922{
1923 char *out;
1924
1925 len = strnlen(in, len);
1926
1927 out = palloc(len + 1);
1928 memcpy(out, in, len);
1929 out[len] = '\0';
1930
1931 return out;
1932}
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
const void size_t len

◆ psprintf()

char * psprintf ( const char fmt,
  ... 
)
extern

◆ pstrdup()

char * pstrdup ( const char in)
extern

Definition at line 1910 of file mcxt.c.

1911{
1913}
char * MemoryContextStrdup(MemoryContext context, const char *string)
Definition mcxt.c:1897

◆ pvsnprintf()

char size_t pvsnprintf ( char buf,
size_t  len,
const char fmt,
va_list  args 
)
extern

◆ repalloc()

void * repalloc ( void pointer,
Size  size 
)
extern

Definition at line 1635 of file mcxt.c.

1636{
1637#if defined(USE_ASSERT_CHECKING) || defined(USE_VALGRIND)
1638 MemoryContext context = GetMemoryChunkContext(pointer);
1639#endif
1640 void *ret;
1641
1643
1644 /* isReset must be false already */
1645 Assert(!context->isReset);
1646
1647 /*
1648 * For efficiency reasons, we purposefully offload the handling of
1649 * allocation failures to the MemoryContextMethods implementation as this
1650 * allows these checks to be performed only when an actual malloc needs to
1651 * be done to request more memory from the OS. Additionally, not having
1652 * to execute any instructions after this call allows the compiler to use
1653 * the sibling call optimization. If you're considering adding code after
1654 * this call, consider making it the responsibility of the 'realloc'
1655 * function instead.
1656 */
1657 ret = MCXT_METHOD(pointer, realloc) (pointer, size, 0);
1658
1659 VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size);
1660
1661 return ret;
1662}
#define VALGRIND_MEMPOOL_CHANGE(context, optr, nptr, size)
Definition memdebug.h:31

◆ repalloc_mul()

void * repalloc_mul ( void p,
Size  s1,
Size  s2 
)
extern

Definition at line 1822 of file mcxt.c.

1823{
1824 /* inline mul_size() for efficiency */
1825 Size req;
1826
1829 return repalloc(p, req);
1830}
void * repalloc(void *pointer, Size size)
Definition mcxt.c:1635