Use pg_malloc_object() and pg_alloc_array() variants in frontend code

This commit updates the frontend tools (src/bin/, contrib/ and
src/test/) to use the memory allocation variants based on
pg_malloc_object() and pg_malloc_array() in various code paths.  This
does not cover all the allocations, but a good chunk of them.

Like all the changes of this kind (31d3847a37, etc.), this should
encourage any future code to use this new style.

Author: Andreas Karlsson <andreas@proxel.se>
Discussion: https://postgr.es/m/cfb645da-6b3a-4f22-9bcc-5bc46b0e9c61@proxel.se
This commit is contained in:
Michael Paquier 2026-02-27 18:59:41 +09:00
parent a2c89835f5
commit 574bee89c2
39 changed files with 153 additions and 158 deletions

View file

@ -237,13 +237,13 @@ add_one_elt(char *eltname, eary *eary)
if (eary->alloc == 0)
{
eary ->alloc = 8;
eary ->array = (char **) pg_malloc(8 * sizeof(char *));
eary ->array = pg_malloc_array(char *, 8);
}
else if (eary->num >= eary->alloc)
{
eary ->alloc *= 2;
eary ->array = (char **) pg_realloc(eary->array,
eary->alloc * sizeof(char *));
eary ->array = pg_realloc_array(eary->array, char *,
eary->alloc);
}
eary ->array[eary->num] = pg_strdup(eltname);
@ -400,7 +400,7 @@ sql_exec(PGconn *conn, const char *todo, bool quiet)
nfields = PQnfields(res);
/* for each field, get the needed width */
length = (int *) pg_malloc(sizeof(int) * nfields);
length = pg_malloc_array(int, nfields);
for (j = 0; j < nfields; j++)
length[j] = strlen(PQfname(res, j));
@ -585,11 +585,11 @@ main(int argc, char **argv)
struct options *my_opts;
PGconn *pgconn;
my_opts = (struct options *) pg_malloc(sizeof(struct options));
my_opts = pg_malloc_object(struct options);
my_opts->oids = (eary *) pg_malloc(sizeof(eary));
my_opts->tables = (eary *) pg_malloc(sizeof(eary));
my_opts->filenumbers = (eary *) pg_malloc(sizeof(eary));
my_opts->oids = pg_malloc_object(eary);
my_opts->tables = pg_malloc_object(eary);
my_opts->filenumbers = pg_malloc_object(eary);
my_opts->oids->num = my_opts->oids->alloc = 0;
my_opts->tables->num = my_opts->tables->alloc = 0;

View file

@ -444,7 +444,7 @@ escape_quotes_bki(const char *src)
static void
add_stringlist_item(_stringlist **listhead, const char *str)
{
_stringlist *newentry = pg_malloc(sizeof(_stringlist));
_stringlist *newentry = pg_malloc_object(_stringlist);
_stringlist *oldentry;
newentry->str = pg_strdup(str);
@ -687,7 +687,7 @@ readfile(const char *path)
initStringInfo(&line);
maxlines = 1024;
result = (char **) pg_malloc(maxlines * sizeof(char *));
result = pg_malloc_array(char *, maxlines);
n = 0;
while (pg_get_line_buf(infile, &line))
@ -696,7 +696,7 @@ readfile(const char *path)
if (n >= maxlines - 1)
{
maxlines *= 2;
result = (char **) pg_realloc(result, maxlines * sizeof(char *));
result = pg_realloc_array(result, char *, maxlines);
}
result[n++] = pg_strdup(line.data);

View file

@ -1338,7 +1338,7 @@ extend_pattern_info_array(PatternInfoArray *pia)
PatternInfo *result;
pia->len++;
pia->data = (PatternInfo *) pg_realloc(pia->data, pia->len * sizeof(PatternInfo));
pia->data = pg_realloc_array(pia->data, PatternInfo, pia->len);
result = &pia->data[pia->len - 1];
memset(result, 0, sizeof(*result));
@ -1593,7 +1593,7 @@ compile_database_list(PGconn *conn, SimplePtrList *databases,
if (initial_dbname)
{
DatabaseInfo *dat = (DatabaseInfo *) pg_malloc0(sizeof(DatabaseInfo));
DatabaseInfo *dat = pg_malloc0_object(DatabaseInfo);
/* This database is included. Add to list */
if (opts.verbose)
@ -1738,7 +1738,7 @@ compile_database_list(PGconn *conn, SimplePtrList *databases,
if (opts.verbose)
pg_log_info("including database \"%s\"", datname);
dat = (DatabaseInfo *) pg_malloc0(sizeof(DatabaseInfo));
dat = pg_malloc0_object(DatabaseInfo);
dat->datname = pstrdup(datname);
simple_ptr_list_append(databases, dat);
}
@ -2202,7 +2202,7 @@ compile_relation_list_one_db(PGconn *conn, SimplePtrList *relations,
{
/* Current record pertains to a relation */
RelationInfo *rel = (RelationInfo *) pg_malloc0(sizeof(RelationInfo));
RelationInfo *rel = pg_malloc0_object(RelationInfo);
Assert(OidIsValid(oid));
Assert((is_heap && !is_btree) || (is_btree && !is_heap));

View file

@ -320,7 +320,7 @@ kill_bgchild_atexit(void)
static void
tablespace_list_append(const char *arg)
{
TablespaceListCell *cell = (TablespaceListCell *) pg_malloc0(sizeof(TablespaceListCell));
TablespaceListCell *cell = pg_malloc0_object(TablespaceListCell);
char *dst;
char *dst_ptr;
const char *arg_ptr;
@ -623,7 +623,7 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier,
lo;
char statusdir[MAXPGPATH];
param = pg_malloc0(sizeof(logstreamer_param));
param = pg_malloc0_object(logstreamer_param);
param->timeline = timeline;
param->sysidentifier = sysidentifier;
param->wal_compress_algorithm = wal_compress_algorithm;

View file

@ -820,7 +820,7 @@ main(int argc, char **argv)
}
noptions += 1;
options = pg_realloc(options, sizeof(char *) * noptions * 2);
options = pg_realloc_array(options, char *, noptions * 2);
options[(noptions - 1) * 2] = data;
options[(noptions - 1) * 2 + 1] = val;

View file

@ -94,8 +94,8 @@ GetConnection(void)
argcount++;
}
keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
values = pg_malloc0((argcount + 1) * sizeof(*values));
keywords = pg_malloc0_array(const char *, argcount + 1);
values = pg_malloc0_array(const char *, argcount + 1);
/*
* Set dbname here already, so it can be overridden by a dbname in the
@ -117,8 +117,8 @@ GetConnection(void)
}
else
{
keywords = pg_malloc0((argcount + 1) * sizeof(*keywords));
values = pg_malloc0((argcount + 1) * sizeof(*values));
keywords = pg_malloc0_array(const char *, argcount + 1);
values = pg_malloc0_array(const char *, argcount + 1);
keywords[i] = "dbname";
values[i] = (dbname == NULL) ? "replication" : dbname;
i++;

View file

@ -102,7 +102,7 @@ static char *
dir_get_file_name(WalWriteMethod *wwmethod,
const char *pathname, const char *temp_suffix)
{
char *filename = pg_malloc0(MAXPGPATH * sizeof(char));
char *filename = pg_malloc0_array(char, MAXPGPATH);
snprintf(filename, MAXPGPATH, "%s%s%s",
pathname,
@ -275,7 +275,7 @@ dir_open_for_write(WalWriteMethod *wwmethod, const char *pathname,
}
}
f = pg_malloc0(sizeof(DirectoryMethodFile));
f = pg_malloc0_object(DirectoryMethodFile);
#ifdef HAVE_LIBZ
if (wwmethod->compression_algorithm == PG_COMPRESSION_GZIP)
f->gzfp = gzfp;
@ -643,7 +643,7 @@ CreateWalDirectoryMethod(const char *basedir,
{
DirectoryMethodData *wwmethod;
wwmethod = pg_malloc0(sizeof(DirectoryMethodData));
wwmethod = pg_malloc0_object(DirectoryMethodData);
*((const WalWriteMethodOps **) &wwmethod->base.ops) =
&WalDirectoryMethodOps;
wwmethod->base.compression_algorithm = compression_algorithm;
@ -825,7 +825,7 @@ static char *
tar_get_file_name(WalWriteMethod *wwmethod, const char *pathname,
const char *temp_suffix)
{
char *filename = pg_malloc0(MAXPGPATH * sizeof(char));
char *filename = pg_malloc0_array(char, MAXPGPATH);
snprintf(filename, MAXPGPATH, "%s%s",
pathname, temp_suffix ? temp_suffix : "");
@ -859,7 +859,7 @@ tar_open_for_write(WalWriteMethod *wwmethod, const char *pathname,
#ifdef HAVE_LIBZ
if (wwmethod->compression_algorithm == PG_COMPRESSION_GZIP)
{
tar_data->zp = (z_streamp) pg_malloc(sizeof(z_stream));
tar_data->zp = pg_malloc_object(z_stream);
tar_data->zp->zalloc = Z_NULL;
tar_data->zp->zfree = Z_NULL;
tar_data->zp->opaque = Z_NULL;
@ -893,7 +893,7 @@ tar_open_for_write(WalWriteMethod *wwmethod, const char *pathname,
return NULL;
}
tar_data->currentfile = pg_malloc0(sizeof(TarMethodFile));
tar_data->currentfile = pg_malloc0_object(TarMethodFile);
tar_data->currentfile->base.wwmethod = wwmethod;
tmppath = tar_get_file_name(wwmethod, pathname, temp_suffix);
@ -1360,7 +1360,7 @@ CreateWalTarMethod(const char *tarbase,
const char *suffix = (compression_algorithm == PG_COMPRESSION_GZIP) ?
".tar.gz" : ".tar";
wwmethod = pg_malloc0(sizeof(TarMethodData));
wwmethod = pg_malloc0_object(TarMethodData);
*((const WalWriteMethodOps **) &wwmethod->base.ops) =
&WalTarMethodOps;
wwmethod->base.compression_algorithm = compression_algorithm;

View file

@ -85,7 +85,7 @@ load_backup_manifests(int n_backups, char **backup_directories)
manifest_data **result;
int i;
result = pg_malloc(sizeof(manifest_data *) * n_backups);
result = pg_malloc_array(manifest_data *, n_backups);
for (i = 0; i < n_backups; ++i)
result[i] = load_backup_manifest(backup_directories[i]);
@ -139,7 +139,7 @@ load_backup_manifest(char *backup_directory)
/* Create the hash table. */
ht = manifest_files_create(initial_size, NULL);
result = pg_malloc0(sizeof(manifest_data));
result = pg_malloc0_object(manifest_data);
result->files = ht;
context.private_data = result;
context.version_cb = combinebackup_version_cb;

View file

@ -455,7 +455,7 @@ main(int argc, char *argv[])
static void
add_tablespace_mapping(cb_options *opt, char *arg)
{
cb_tablespace_mapping *tsmap = pg_malloc0(sizeof(cb_tablespace_mapping));
cb_tablespace_mapping *tsmap = pg_malloc0_object(cb_tablespace_mapping);
char *dst;
char *dst_ptr;
char *arg_ptr;
@ -1171,7 +1171,7 @@ process_directory_recursively(Oid tsoid,
static void
remember_to_cleanup_directory(char *target_path, bool rmtopdir)
{
cb_cleanup_dir *dir = pg_malloc(sizeof(cb_cleanup_dir));
cb_cleanup_dir *dir = pg_malloc_object(cb_cleanup_dir);
dir->target_path = target_path;
dir->rmtopdir = rmtopdir;
@ -1259,7 +1259,7 @@ scan_for_existing_tablespaces(char *pathname, cb_options *opt)
}
/* Create a new tablespace object. */
ts = pg_malloc0(sizeof(cb_tablespace));
ts = pg_malloc0_object(cb_tablespace);
ts->oid = oid;
/*

View file

@ -120,7 +120,7 @@ reconstruct_from_incremental_file(char *input_filename,
* Every block must come either from the latest version of the file or
* from one of the prior backups.
*/
source = pg_malloc0(sizeof(rfile *) * (1 + n_prior_backups));
source = pg_malloc0_array(rfile *, 1 + n_prior_backups);
/*
* Use the information from the latest incremental file to figure out how
@ -135,8 +135,8 @@ reconstruct_from_incremental_file(char *input_filename,
* need to obtain it and at what offset in that file it's stored.
* sourcemap gives us the first of these things, and offsetmap the latter.
*/
sourcemap = pg_malloc0(sizeof(rfile *) * block_length);
offsetmap = pg_malloc0(sizeof(off_t) * block_length);
sourcemap = pg_malloc0_array(rfile *, block_length);
offsetmap = pg_malloc0_array(off_t, block_length);
/*
* Every block that is present in the newest incremental file should be
@ -483,7 +483,7 @@ make_incremental_rfile(char *filename)
if (rf->num_blocks > 0)
{
rf->relative_block_numbers =
pg_malloc0(sizeof(BlockNumber) * rf->num_blocks);
pg_malloc0_array(BlockNumber, rf->num_blocks);
read_bytes(rf, rf->relative_block_numbers,
sizeof(BlockNumber) * rf->num_blocks);
}
@ -512,7 +512,7 @@ make_rfile(char *filename, bool missing_ok)
{
rfile *rf;
rf = pg_malloc0(sizeof(rfile));
rf = pg_malloc0_object(rfile);
rf->filename = pstrdup(filename);
if ((rf->fd = open(filename, O_RDONLY | PG_BINARY, 0)) < 0)
{

View file

@ -47,7 +47,7 @@ static size_t hex_encode(const uint8 *src, size_t len, char *dst);
manifest_writer *
create_manifest_writer(char *directory, uint64 system_identifier)
{
manifest_writer *mwriter = pg_malloc(sizeof(manifest_writer));
manifest_writer *mwriter = pg_malloc_object(manifest_writer);
snprintf(mwriter->pathname, MAXPGPATH, "%s/backup_manifest", directory);
mwriter->fd = -1;

View file

@ -346,7 +346,7 @@ readfile(const char *path, int *numlines)
{
/* empty file */
close(fd);
result = (char **) pg_malloc(sizeof(char *));
result = pg_malloc_object(char *);
*result = NULL;
return result;
}
@ -374,7 +374,7 @@ readfile(const char *path, int *numlines)
}
/* set up the result buffer */
result = (char **) pg_malloc((nlines + 1) * sizeof(char *));
result = pg_malloc_array(char *, nlines + 1);
*numlines = nlines;
/* now split the buffer into lines */

View file

@ -76,7 +76,7 @@ datapagemap_iterate(datapagemap_t *map)
{
datapagemap_iterator_t *iter;
iter = pg_malloc(sizeof(datapagemap_iterator_t));
iter = pg_malloc0_object(datapagemap_iterator_t);
iter->map = map;
iter->nextblkno = 0;

View file

@ -84,7 +84,7 @@ init_libpq_source(PGconn *conn)
init_libpq_conn(conn);
src = pg_malloc0(sizeof(libpq_source));
src = pg_malloc0_object(libpq_source);
src->common.traverse_files = libpq_traverse_files;
src->common.fetch_file = libpq_fetch_file;

View file

@ -39,7 +39,7 @@ init_local_source(const char *datadir)
{
local_source *src;
src = pg_malloc0(sizeof(local_source));
src = pg_malloc0_object(local_source);
src->common.traverse_files = local_traverse_files;
src->common.fetch_file = local_fetch_file;

View file

@ -874,7 +874,7 @@ getTimelineHistory(TimeLineID tli, bool is_source, int *nentries)
*/
if (tli == 1)
{
history = (TimeLineHistoryEntry *) pg_malloc(sizeof(TimeLineHistoryEntry));
history = pg_malloc_object(TimeLineHistoryEntry);
history->tli = tli;
history->begin = history->end = InvalidXLogRecPtr;
*nentries = 1;

View file

@ -91,7 +91,7 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries)
lasttli = tli;
nlines++;
entries = pg_realloc(entries, nlines * sizeof(TimeLineHistoryEntry));
entries = pg_realloc_array(entries, TimeLineHistoryEntry, nlines);
entry = &entries[nlines - 1];
entry->tli = tli;
@ -115,9 +115,9 @@ rewind_parseTimeLineHistory(char *buffer, TimeLineID targetTLI, int *nentries)
*/
nlines++;
if (entries)
entries = pg_realloc(entries, nlines * sizeof(TimeLineHistoryEntry));
entries = pg_realloc_array(entries, TimeLineHistoryEntry, nlines);
else
entries = pg_malloc(1 * sizeof(TimeLineHistoryEntry));
entries = pg_malloc_array(TimeLineHistoryEntry, 1);
entry = &entries[nlines - 1];
entry->tli = targetTLI;

View file

@ -482,8 +482,8 @@ check_for_data_types_usage(ClusterInfo *cluster)
}
/* Allocate memory for queries and for task states */
queries = pg_malloc0(sizeof(char *) * n_data_types_usage_checks);
states = pg_malloc0(sizeof(struct data_type_check_state) * n_data_types_usage_checks);
queries = pg_malloc0_array(char *, n_data_types_usage_checks);
states = pg_malloc0_array(struct data_type_check_state, n_data_types_usage_checks);
for (int i = 0; i < n_data_types_usage_checks; i++)
{

View file

@ -83,7 +83,7 @@ get_loadable_libraries(void)
struct loadable_libraries_state state;
char *query;
state.ress = (PGresult **) pg_malloc(old_cluster.dbarr.ndbs * sizeof(PGresult *));
state.ress = pg_malloc_array(PGresult *, old_cluster.dbarr.ndbs);
state.totaltups = 0;
query = psprintf("SELECT DISTINCT probin "
@ -105,7 +105,7 @@ get_loadable_libraries(void)
* plugins.
*/
n_libinfos = state.totaltups + count_old_cluster_logical_slots();
os_info.libraries = (LibraryInfo *) pg_malloc(sizeof(LibraryInfo) * n_libinfos);
os_info.libraries = pg_malloc_array(LibraryInfo, n_libinfos);
totaltups = 0;
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)

View file

@ -53,8 +53,7 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
bool all_matched = true;
/* There will certainly not be more mappings than there are old rels */
maps = (FileNameMap *) pg_malloc(sizeof(FileNameMap) *
old_db->rel_arr.nrels);
maps = pg_malloc_array(FileNameMap, old_db->rel_arr.nrels);
/*
* Each of the RelInfo arrays should be sorted by OID. Scan through them
@ -364,7 +363,7 @@ get_template0_info(ClusterInfo *cluster)
if (PQntuples(dbres) != 1)
pg_fatal("template0 not found");
locale = pg_malloc(sizeof(DbLocaleInfo));
locale = pg_malloc_object(DbLocaleInfo);
i_datencoding = PQfnumber(dbres, "encoding");
i_datlocprovider = PQfnumber(dbres, "datlocprovider");
@ -433,7 +432,7 @@ get_db_infos(ClusterInfo *cluster)
i_spclocation = PQfnumber(res, "spclocation");
ntups = PQntuples(res);
dbinfos = (DbInfo *) pg_malloc0(sizeof(DbInfo) * ntups);
dbinfos = pg_malloc0_array(DbInfo, ntups);
for (tupnum = 0; tupnum < ntups; tupnum++)
{
@ -579,7 +578,7 @@ static void
process_rel_infos(DbInfo *dbinfo, PGresult *res, void *arg)
{
int ntups = PQntuples(res);
RelInfo *relinfos = (RelInfo *) pg_malloc(sizeof(RelInfo) * ntups);
RelInfo *relinfos = pg_malloc_array(RelInfo, ntups);
int i_reloid = PQfnumber(res, "reloid");
int i_indtable = PQfnumber(res, "indtable");
int i_toastheap = PQfnumber(res, "toastheap");
@ -785,7 +784,7 @@ process_old_cluster_logical_slot_infos(DbInfo *dbinfo, PGresult *res, void *arg)
int i_caught_up;
int i_invalid;
slotinfos = (LogicalSlotInfo *) pg_malloc(sizeof(LogicalSlotInfo) * num_slots);
slotinfos = pg_malloc_array(LogicalSlotInfo, num_slots);
i_slotname = PQfnumber(res, "slot_name");
i_plugin = PQfnumber(res, "plugin");

View file

@ -85,13 +85,13 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
/* parallel */
#ifdef WIN32
if (thread_handles == NULL)
thread_handles = pg_malloc(user_opts.jobs * sizeof(HANDLE));
thread_handles = pg_malloc_array(HANDLE, user_opts.jobs);
if (exec_thread_args == NULL)
{
int i;
exec_thread_args = pg_malloc(user_opts.jobs * sizeof(exec_thread_arg *));
exec_thread_args = pg_malloc_array(exec_thread_arg *, user_opts.jobs);
/*
* For safety and performance, we keep the args allocated during
@ -99,7 +99,7 @@ parallel_exec_prog(const char *log_file, const char *opt_log_file,
* thread different from the one that allocated it.
*/
for (i = 0; i < user_opts.jobs; i++)
exec_thread_args[i] = pg_malloc0(sizeof(exec_thread_arg));
exec_thread_args[i] = pg_malloc0_object(exec_thread_arg);
}
cur_thread_args = (void **) exec_thread_args;
@ -188,13 +188,13 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
/* parallel */
#ifdef WIN32
if (thread_handles == NULL)
thread_handles = pg_malloc(user_opts.jobs * sizeof(HANDLE));
thread_handles = pg_malloc_array(HANDLE, user_opts.jobs);
if (transfer_thread_args == NULL)
{
int i;
transfer_thread_args = pg_malloc(user_opts.jobs * sizeof(transfer_thread_arg *));
transfer_thread_args = pg_malloc_array(transfer_thread_arg *, user_opts.jobs);
/*
* For safety and performance, we keep the args allocated during
@ -202,7 +202,7 @@ parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr,
* thread different from the one that allocated it.
*/
for (i = 0; i < user_opts.jobs; i++)
transfer_thread_args[i] = pg_malloc0(sizeof(transfer_thread_arg));
transfer_thread_args[i] = pg_malloc0_object(transfer_thread_arg);
}
cur_thread_args = (void **) transfer_thread_args;

View file

@ -26,7 +26,7 @@ static void SlruFlush(SlruSegState *state);
static SlruSegState *
AllocSlruSegState(const char *dir)
{
SlruSegState *state = pg_malloc(sizeof(*state));
SlruSegState *state = pg_malloc_object(SlruSegState);
state->dir = pstrdup(dir);
state->fn = NULL;

View file

@ -69,9 +69,9 @@ get_tablespace_paths(void)
if (PQntuples(res) != 0)
{
old_cluster.tablespaces =
(char **) pg_malloc(old_cluster.num_tablespaces * sizeof(char *));
pg_malloc_array(char *, old_cluster.num_tablespaces);
new_cluster.tablespaces =
(char **) pg_malloc(new_cluster.num_tablespaces * sizeof(char *));
pg_malloc_array(char *, new_cluster.num_tablespaces);
}
else
{

View file

@ -116,7 +116,7 @@ typedef struct UpgradeTaskSlot
UpgradeTask *
upgrade_task_create(void)
{
UpgradeTask *task = pg_malloc0(sizeof(UpgradeTask));
UpgradeTask *task = pg_malloc0_object(UpgradeTask);
task->queries = createPQExpBuffer();
@ -154,8 +154,8 @@ upgrade_task_add_step(UpgradeTask *task, const char *query,
{
UpgradeTaskStep *new_step;
task->steps = pg_realloc(task->steps,
++task->num_steps * sizeof(UpgradeTaskStep));
task->steps = pg_realloc_array(task->steps, UpgradeTaskStep,
++task->num_steps);
new_step = &task->steps[task->num_steps - 1];
new_step->process_cb = process_cb;
@ -421,7 +421,7 @@ void
upgrade_task_run(const UpgradeTask *task, const ClusterInfo *cluster)
{
int jobs = Max(1, user_opts.jobs);
UpgradeTaskSlot *slots = pg_malloc0(sizeof(UpgradeTaskSlot) * jobs);
UpgradeTaskSlot *slots = pg_malloc0_array(UpgradeTaskSlot, jobs);
dbs_complete = 0;
dbs_processing = 0;

View file

@ -79,7 +79,7 @@ astreamer_verify_content_new(astreamer *next, verifier_context *context,
streamer->tblspc_oid = tblspc_oid;
if (!context->skip_checksums)
streamer->checksum_ctx = pg_malloc(sizeof(pg_checksum_context));
streamer->checksum_ctx = pg_malloc_object(pg_checksum_context);
return &streamer->base;
}

View file

@ -418,7 +418,7 @@ parse_manifest_file(char *manifest_path)
/* Create the hash table. */
ht = manifest_files_create(initial_size, NULL);
result = pg_malloc0(sizeof(manifest_data));
result = pg_malloc0_object(manifest_data);
result->files = ht;
context.private_data = result;
context.version_cb = verifybackup_version_cb;
@ -970,7 +970,7 @@ precheck_tar_backup_file(verifier_context *context, char *relpath,
* Append the information to the list for complete verification at a later
* stage.
*/
tar = pg_malloc(sizeof(tar_file));
tar = pg_malloc_object(tar_file);
tar->relpath = pstrdup(relpath);
tar->tblspc_oid = tblspc_oid;
tar->compress_algorithm = compress_algorithm;
@ -1065,7 +1065,7 @@ verify_backup_checksums(verifier_context *context)
progress_report(false);
buffer = pg_malloc(READ_CHUNK_SIZE * sizeof(uint8));
buffer = pg_malloc_array(uint8, READ_CHUNK_SIZE);
manifest_files_start_iterate(manifest->files, &it);
while ((m = manifest_files_iterate(manifest->files, &it)) != NULL)

View file

@ -167,7 +167,7 @@ function: FUNCTION { $$ = find_func(yyscanner, $1); pg_free($1); }
static PgBenchExpr *
make_null_constant(void)
{
PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
PgBenchExpr *expr = pg_malloc_object(PgBenchExpr);
expr->etype = ENODE_CONSTANT;
expr->u.constant.type = PGBT_NULL;
@ -178,7 +178,7 @@ make_null_constant(void)
static PgBenchExpr *
make_integer_constant(int64 ival)
{
PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
PgBenchExpr *expr = pg_malloc_object(PgBenchExpr);
expr->etype = ENODE_CONSTANT;
expr->u.constant.type = PGBT_INT;
@ -189,7 +189,7 @@ make_integer_constant(int64 ival)
static PgBenchExpr *
make_double_constant(double dval)
{
PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
PgBenchExpr *expr = pg_malloc_object(PgBenchExpr);
expr->etype = ENODE_CONSTANT;
expr->u.constant.type = PGBT_DOUBLE;
@ -200,7 +200,7 @@ make_double_constant(double dval)
static PgBenchExpr *
make_boolean_constant(bool bval)
{
PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
PgBenchExpr *expr = pg_malloc_object(PgBenchExpr);
expr->etype = ENODE_CONSTANT;
expr->u.constant.type = PGBT_BOOLEAN;
@ -211,7 +211,7 @@ make_boolean_constant(bool bval)
static PgBenchExpr *
make_variable(char *varname)
{
PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
PgBenchExpr *expr = pg_malloc_object(PgBenchExpr);
expr->etype = ENODE_VARIABLE;
expr->u.variable.varname = varname;
@ -415,12 +415,12 @@ make_elist(PgBenchExpr *expr, PgBenchExprList *list)
if (list == NULL)
{
list = pg_malloc(sizeof(PgBenchExprList));
list = pg_malloc_object(PgBenchExprList);
list->head = NULL;
list->tail = NULL;
}
cons = pg_malloc(sizeof(PgBenchExprLink));
cons = pg_malloc_object(PgBenchExprLink);
cons->expr = expr;
cons->next = NULL;
@ -453,7 +453,7 @@ make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args)
{
int len = elist_length(args);
PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
PgBenchExpr *expr = pg_malloc_object(PgBenchExpr);
Assert(fnumber >= 0);

View file

@ -1774,7 +1774,7 @@ enlargeVariables(Variables *variables, int needed)
{
variables->max_vars = needed + VARIABLES_ALLOC_MARGIN;
variables->vars = (Variable *)
pg_realloc(variables->vars, variables->max_vars * sizeof(Variable));
pg_realloc_array(variables->vars, Variable, variables->max_vars);
}
}
@ -3067,7 +3067,7 @@ allocCStatePrepared(CState *st)
{
Assert(st->prepared == NULL);
st->prepared = pg_malloc(sizeof(bool *) * num_scripts);
st->prepared = pg_malloc_array(bool *, num_scripts);
for (int i = 0; i < num_scripts; i++)
{
ParsedScript *script = &sql_script[i];
@ -3075,7 +3075,7 @@ allocCStatePrepared(CState *st)
for (numcmds = 0; script->commands[numcmds] != NULL; numcmds++)
;
st->prepared[i] = pg_malloc0(sizeof(bool) * numcmds);
st->prepared[i] = pg_malloc0_array(bool, numcmds);
}
}
@ -5659,7 +5659,7 @@ create_sql_command(PQExpBuffer buf)
return NULL;
/* Allocate and initialize Command structure */
my_command = (Command *) pg_malloc(sizeof(Command));
my_command = pg_malloc0_object(Command);
initPQExpBuffer(&my_command->lines);
appendPQExpBufferStr(&my_command->lines, p);
my_command->first_line = NULL; /* this is set later */
@ -5755,7 +5755,7 @@ process_backslash_command(PsqlScanState sstate, const char *source,
}
/* Allocate and initialize Command structure */
my_command = (Command *) pg_malloc0(sizeof(Command));
my_command = pg_malloc0_object(Command);
my_command->type = META_COMMAND;
my_command->argc = 0;
initSimpleStats(&my_command->stats);
@ -6011,7 +6011,7 @@ ParseScript(const char *script, const char *desc, int weight)
/* Initialize all fields of ps */
ps.desc = desc;
ps.weight = weight;
ps.commands = (Command **) pg_malloc(sizeof(Command *) * alloc_num);
ps.commands = pg_malloc_array(Command *, alloc_num);
initStats(&ps.stats, 0);
/* Prepare to parse script */
@ -6114,7 +6114,7 @@ ParseScript(const char *script, const char *desc, int weight)
{
alloc_num += COMMANDS_ALLOC_NUM;
ps.commands = (Command **)
pg_realloc(ps.commands, sizeof(Command *) * alloc_num);
pg_realloc_array(ps.commands, Command *, alloc_num);
}
/* Done if we reached EOF */
@ -6844,7 +6844,7 @@ main(int argc, char **argv)
}
}
state = (CState *) pg_malloc0(sizeof(CState));
state = pg_malloc0_object(CState);
/* set random seed early, because it may be used while parsing scripts. */
if (!set_random_seed(getenv("PGBENCH_RANDOM_SEED")))
@ -7298,7 +7298,7 @@ main(int argc, char **argv)
if (nclients > 1)
{
state = (CState *) pg_realloc(state, sizeof(CState) * nclients);
state = pg_realloc_array(state, CState, nclients);
memset(state + 1, 0, sizeof(CState) * (nclients - 1));
/* copy any -D switch values to all clients */
@ -7412,7 +7412,7 @@ main(int argc, char **argv)
PQfinish(con);
/* set up thread data structures */
threads = (TState *) pg_malloc(sizeof(TState) * nthreads);
threads = pg_malloc_array(TState, nthreads);
nclients_dealt = 0;
for (i = 0; i < nthreads; i++)
@ -7993,7 +7993,7 @@ socket_has_input(socket_set *sa, int fd, int idx)
static socket_set *
alloc_socket_set(int count)
{
return (socket_set *) pg_malloc0(sizeof(socket_set));
return pg_malloc0_object(socket_set);
}
static void

View file

@ -4168,8 +4168,8 @@ do_connect(enum trivalue reuse_previous_specification,
/* Loop till we have a connection or fail, which we might've already */
while (success)
{
const char **keywords = pg_malloc((nconnopts + 1) * sizeof(*keywords));
const char **values = pg_malloc((nconnopts + 1) * sizeof(*values));
const char **keywords = pg_malloc_array(const char *, nconnopts + 1);
const char **values = pg_malloc_array(const char *, nconnopts + 1);
int paramnum = 0;
PQconninfoOption *ci;
@ -5665,7 +5665,7 @@ savePsetInfo(const printQueryOpt *popt)
{
printQueryOpt *save;
save = (printQueryOpt *) pg_malloc(sizeof(printQueryOpt));
save = pg_malloc_object(printQueryOpt);
/* Flat-copy all the scalar fields, then duplicate sub-structures. */
memcpy(save, popt, sizeof(printQueryOpt));

View file

@ -99,7 +99,7 @@ parse_slash_copy(const char *args)
return NULL;
}
result = pg_malloc0(sizeof(struct copy_options));
result = pg_malloc0_object(struct copy_options);
result->before_tofrom = pg_strdup(""); /* initialize for appending */

View file

@ -245,11 +245,9 @@ PrintResultInCrosstab(const PGresult *res)
num_columns = piv_columns.count;
num_rows = piv_rows.count;
array_columns = (pivot_field *)
pg_malloc(sizeof(pivot_field) * num_columns);
array_columns = pg_malloc_array(pivot_field, num_columns);
array_rows = (pivot_field *)
pg_malloc(sizeof(pivot_field) * num_rows);
array_rows = pg_malloc_array(pivot_field, num_rows);
avlCollectFields(&piv_columns, piv_columns.root, array_columns, 0);
avlCollectFields(&piv_rows, piv_rows.root, array_rows, 0);
@ -312,7 +310,7 @@ printCrosstab(const PGresult *result,
* map associating each piv_columns[].rank to its index in piv_columns.
* This avoids an O(N^2) loop later.
*/
horiz_map = (int *) pg_malloc(sizeof(int) * num_columns);
horiz_map = pg_malloc_array(int, num_columns);
for (i = 0; i < num_columns; i++)
horiz_map[piv_columns[i].rank] = i;
@ -437,7 +435,7 @@ error:
static void
avlInit(avl_tree *tree)
{
tree->end = (avl_node *) pg_malloc0(sizeof(avl_node));
tree->end = pg_malloc0_object(avl_node);
tree->end->children[0] = tree->end->children[1] = tree->end;
tree->count = 0;
tree->root = tree->end;
@ -532,8 +530,7 @@ avlInsertNode(avl_tree *tree, avl_node **node, pivot_field field)
if (current == tree->end)
{
avl_node *new_node = (avl_node *)
pg_malloc(sizeof(avl_node));
avl_node *new_node = pg_malloc_object(avl_node);
new_node->height = 1;
new_node->field = field;
@ -591,7 +588,7 @@ rankSort(int num_columns, pivot_field *piv_columns)
* every header entry] */
int i;
hmap = (int *) pg_malloc(sizeof(int) * num_columns * 2);
hmap = pg_malloc_array(int, num_columns * 2);
for (i = 0; i < num_columns; i++)
{
char *val = piv_columns[i].sort_value;

View file

@ -3797,7 +3797,7 @@ describeRoles(const char *pattern, bool verbose, bool showSystem)
return false;
nrows = PQntuples(res);
attr = pg_malloc0((nrows + 1) * sizeof(*attr));
attr = pg_malloc0_array(char *, nrows + 1);
printTableInit(&cont, &myopt, _("List of roles"), ncols, nrows);
@ -5306,7 +5306,7 @@ listSchemas(const char *pattern, bool verbose, bool showSystem)
* storing "Publications:" string) + publication schema mapping
* count + 1 (for storing NULL).
*/
footers = (char **) pg_malloc((1 + pub_schema_tuples + 1) * sizeof(char *));
footers = pg_malloc_array(char *, 1 + pub_schema_tuples + 1);
footers[0] = pg_strdup(_("Publications:"));
/* Might be an empty set - that's ok */

View file

@ -6324,8 +6324,7 @@ append_variable_names(char ***varnames, int *nvars,
if (*nvars >= *maxvars)
{
*maxvars *= 2;
*varnames = (char **) pg_realloc(*varnames,
((*maxvars) + 1) * sizeof(char *));
*varnames = pg_realloc_array(*varnames, char *, (*maxvars) + 1);
}
(*varnames)[(*nvars)++] = psprintf("%s%s%s", prefix, varname, suffix);
@ -6350,7 +6349,7 @@ complete_from_variables(const char *text, const char *prefix, const char *suffix
int i;
struct _variable *ptr;
varnames = (char **) pg_malloc((maxvars + 1) * sizeof(char *));
varnames = pg_malloc_array(char *, maxvars + 1);
for (ptr = pset.vars->next; ptr; ptr = ptr->next)
{
@ -6928,7 +6927,7 @@ get_previous_words(int point, char **buffer, int *nwords)
* This is usually much more space than we need, but it's cheaper than
* doing a separate malloc() for each word.
*/
previous_words = (char **) pg_malloc(point * sizeof(char *));
previous_words = pg_malloc_array(char *, point);
*buffer = outptr = (char *) pg_malloc(point * 2);
/*

View file

@ -54,7 +54,7 @@ CreateVariableSpace(void)
{
struct _variable *ptr;
ptr = pg_malloc(sizeof *ptr);
ptr = pg_malloc_object(struct _variable);
ptr->name = NULL;
ptr->value = NULL;
ptr->substitute_hook = NULL;
@ -353,7 +353,7 @@ SetVariable(VariableSpace space, const char *name, const char *value)
/* not present, make new entry ... unless we were asked to delete */
if (value)
{
current = pg_malloc(sizeof *current);
current = pg_malloc_object(struct _variable);
current->name = pg_strdup(name);
current->value = pg_strdup(value);
current->substitute_hook = NULL;
@ -416,7 +416,7 @@ SetVariableHooks(VariableSpace space, const char *name,
}
/* not present, make new entry */
current = pg_malloc(sizeof *current);
current = pg_malloc_object(struct _variable);
current->name = pg_strdup(name);
current->value = NULL;
current->substitute_hook = shook;

View file

@ -322,7 +322,7 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
* database itself, so build a list with a single entry.
*/
Assert(user_list == NULL);
process_list = pg_malloc0(sizeof(SimpleStringList));
process_list = pg_malloc0_object(SimpleStringList);
simple_string_list_append(process_list, PQdb(conn));
break;
@ -713,7 +713,7 @@ get_parallel_tables_list(PGconn *conn, ReindexType type,
return NULL;
}
tables = pg_malloc0(sizeof(SimpleStringList));
tables = pg_malloc0_object(SimpleStringList);
/* Build qualified identifiers for each table */
for (int i = 0; i < ntups; i++)
@ -809,7 +809,7 @@ get_parallel_tabidx_list(PGconn *conn,
return;
}
*table_list = pg_malloc0(sizeof(SimpleOidList));
*table_list = pg_malloc0_object(SimpleOidList);
/*
* Build two lists, one with table OIDs and the other with fully-qualified

View file

@ -147,7 +147,7 @@ main(int argc, char **argv)
* extra for lock wait detection and global work.
*/
nconns = 1 + testspec->nsessions;
conns = (IsoConnInfo *) pg_malloc0(nconns * sizeof(IsoConnInfo));
conns = pg_malloc0_array(IsoConnInfo, nconns);
atexit(disconnect_atexit);
for (i = 0; i < nconns; i++)
@ -262,7 +262,7 @@ check_testspec(TestSpec *testspec)
for (i = 0; i < testspec->nsessions; i++)
nallsteps += testspec->sessions[i]->nsteps;
allsteps = pg_malloc(nallsteps * sizeof(Step *));
allsteps = pg_malloc_array(Step *, nallsteps);
k = 0;
for (i = 0; i < testspec->nsessions; i++)
@ -417,8 +417,8 @@ run_all_permutations(TestSpec *testspec)
nsteps += testspec->sessions[i]->nsteps;
/* Create PermutationStep workspace array */
steps = (PermutationStep *) pg_malloc0(sizeof(PermutationStep) * nsteps);
stepptrs = (PermutationStep **) pg_malloc(sizeof(PermutationStep *) * nsteps);
steps = pg_malloc0_array(PermutationStep, nsteps);
stepptrs = pg_malloc_array(PermutationStep *, nsteps);
for (i = 0; i < nsteps; i++)
stepptrs[i] = steps + i;
@ -431,7 +431,7 @@ run_all_permutations(TestSpec *testspec)
* A pile is actually just an integer which tells how many steps we've
* already picked from this pile.
*/
piles = pg_malloc(sizeof(int) * testspec->nsessions);
piles = pg_malloc_array(int, testspec->nsessions);
for (i = 0; i < testspec->nsessions; i++)
piles[i] = 0;
@ -524,7 +524,7 @@ run_permutation(TestSpec *testspec, int nsteps, PermutationStep **steps)
int nwaiting = 0;
PermutationStep **waiting;
waiting = pg_malloc(sizeof(PermutationStep *) * testspec->nsessions);
waiting = pg_malloc_array(PermutationStep *, testspec->nsessions);
printf("\nstarting permutation:");
for (i = 0; i < nsteps; i++)

View file

@ -83,8 +83,8 @@ setup_list:
}
| setup_list setup
{
$$.elements = pg_realloc($1.elements,
($1.nelements + 1) * sizeof(void *));
$$.elements = pg_realloc_array($1.elements, void *,
$1.nelements + 1);
$$.elements[$1.nelements] = $2;
$$.nelements = $1.nelements + 1;
}
@ -107,15 +107,15 @@ opt_teardown:
session_list:
session_list session
{
$$.elements = pg_realloc($1.elements,
($1.nelements + 1) * sizeof(void *));
$$.elements = pg_realloc_array($1.elements, void *,
$1.nelements + 1);
$$.elements[$1.nelements] = $2;
$$.nelements = $1.nelements + 1;
}
| session
{
$$.nelements = 1;
$$.elements = pg_malloc(sizeof(void *));
$$.elements = pg_malloc_object(void *);
$$.elements[0] = $1;
}
;
@ -123,7 +123,7 @@ session_list:
session:
SESSION identifier opt_setup step_list opt_teardown
{
$$ = pg_malloc(sizeof(Session));
$$ = pg_malloc_object(Session);
$$->name = $2;
$$->setupsql = $3;
$$->steps = (Step **) $4.elements;
@ -135,15 +135,15 @@ session:
step_list:
step_list step
{
$$.elements = pg_realloc($1.elements,
($1.nelements + 1) * sizeof(void *));
$$.elements = pg_realloc_array($1.elements, void *,
$1.nelements + 1);
$$.elements[$1.nelements] = $2;
$$.nelements = $1.nelements + 1;
}
| step
{
$$.nelements = 1;
$$.elements = pg_malloc(sizeof(void *));
$$.elements = pg_malloc_object(void *);
$$.elements[0] = $1;
}
;
@ -152,7 +152,7 @@ step_list:
step:
STEP identifier sqlblock
{
$$ = pg_malloc(sizeof(Step));
$$ = pg_malloc_object(Step);
$$->name = $2;
$$->sql = $3;
$$->session = -1; /* until filled */
@ -175,15 +175,15 @@ opt_permutation_list:
permutation_list:
permutation_list permutation
{
$$.elements = pg_realloc($1.elements,
($1.nelements + 1) * sizeof(void *));
$$.elements = pg_realloc_array($1.elements, void *,
$1.nelements + 1);
$$.elements[$1.nelements] = $2;
$$.nelements = $1.nelements + 1;
}
| permutation
{
$$.nelements = 1;
$$.elements = pg_malloc(sizeof(void *));
$$.elements = pg_malloc_object(void *);
$$.elements[0] = $1;
}
;
@ -192,7 +192,7 @@ permutation_list:
permutation:
PERMUTATION permutation_step_list
{
$$ = pg_malloc(sizeof(Permutation));
$$ = pg_malloc_object(Permutation);
$$->nsteps = $2.nelements;
$$->steps = (PermutationStep **) $2.elements;
}
@ -201,15 +201,15 @@ permutation:
permutation_step_list:
permutation_step_list permutation_step
{
$$.elements = pg_realloc($1.elements,
($1.nelements + 1) * sizeof(void *));
$$.elements = pg_realloc_array($1.elements, void *,
$1.nelements + 1);
$$.elements[$1.nelements] = $2;
$$.nelements = $1.nelements + 1;
}
| permutation_step
{
$$.nelements = 1;
$$.elements = pg_malloc(sizeof(void *));
$$.elements = pg_malloc_object(void *);
$$.elements[0] = $1;
}
;
@ -217,7 +217,7 @@ permutation_step_list:
permutation_step:
identifier
{
$$ = pg_malloc(sizeof(PermutationStep));
$$ = pg_malloc_object(PermutationStep);
$$->name = $1;
$$->blockers = NULL;
$$->nblockers = 0;
@ -225,7 +225,7 @@ permutation_step:
}
| identifier '(' blocker_list ')'
{
$$ = pg_malloc(sizeof(PermutationStep));
$$ = pg_malloc_object(PermutationStep);
$$->name = $1;
$$->blockers = (PermutationStepBlocker **) $3.elements;
$$->nblockers = $3.nelements;
@ -236,15 +236,15 @@ permutation_step:
blocker_list:
blocker_list ',' blocker
{
$$.elements = pg_realloc($1.elements,
($1.nelements + 1) * sizeof(void *));
$$.elements = pg_realloc_array($1.elements, void *,
$1.nelements + 1);
$$.elements[$1.nelements] = $3;
$$.nelements = $1.nelements + 1;
}
| blocker
{
$$.nelements = 1;
$$.elements = pg_malloc(sizeof(void *));
$$.elements = pg_malloc_object(void *);
$$.elements[0] = $1;
}
;
@ -252,7 +252,7 @@ blocker_list:
blocker:
identifier
{
$$ = pg_malloc(sizeof(PermutationStepBlocker));
$$ = pg_malloc_object(PermutationStepBlocker);
$$->stepname = $1;
$$->blocktype = PSB_OTHER_STEP;
$$->num_notices = -1;
@ -261,7 +261,7 @@ blocker:
}
| identifier NOTICES INTEGER
{
$$ = pg_malloc(sizeof(PermutationStepBlocker));
$$ = pg_malloc_object(PermutationStepBlocker);
$$->stepname = $1;
$$->blocktype = PSB_NUM_NOTICES;
$$->num_notices = $3;
@ -270,7 +270,7 @@ blocker:
}
| '*'
{
$$ = pg_malloc(sizeof(PermutationStepBlocker));
$$ = pg_malloc_object(PermutationStepBlocker);
$$->stepname = NULL;
$$->blocktype = PSB_ONCE;
$$->num_notices = -1;

View file

@ -260,8 +260,8 @@ copy_connection(PGconn *conn)
nopts++;
nopts++; /* for the NULL terminator */
keywords = pg_malloc(sizeof(char *) * nopts);
vals = pg_malloc(sizeof(char *) * nopts);
keywords = pg_malloc_array(const char *, nopts);
vals = pg_malloc_array(const char *, nopts);
i = 0;
for (PQconninfoOption *opt = opts; opt->keyword != NULL; ++opt)
@ -1337,8 +1337,8 @@ test_protocol_version(PGconn *conn)
nopts++;
nopts++; /* NULL terminator */
keywords = pg_malloc0(sizeof(char *) * nopts);
vals = pg_malloc0(sizeof(char *) * nopts);
keywords = pg_malloc0_array(const char *, nopts);
vals = pg_malloc0_array(const char *, nopts);
i = 0;
for (PQconninfoOption *opt = opts; opt->keyword != NULL; ++opt)

View file

@ -196,7 +196,7 @@ unlimit_core_size(void)
void
add_stringlist_item(_stringlist **listhead, const char *str)
{
_stringlist *newentry = pg_malloc(sizeof(_stringlist));
_stringlist *newentry = pg_malloc_object(_stringlist);
_stringlist *oldentry;
newentry->str = pg_strdup(str);
@ -674,7 +674,7 @@ load_resultmap(void)
*/
if (string_matches_pattern(host_platform, platform))
{
_resultmap *entry = pg_malloc(sizeof(_resultmap));
_resultmap *entry = pg_malloc_object(_resultmap);
entry->test = pg_strdup(buf);
entry->type = pg_strdup(file_type);
@ -1557,7 +1557,7 @@ wait_for_tests(PID_TYPE * pids, int *statuses, instr_time *stoptimes,
int i;
#ifdef WIN32
PID_TYPE *active_pids = pg_malloc(num_tests * sizeof(PID_TYPE));
PID_TYPE *active_pids = pg_malloc_array(PID_TYPE, num_tests);
memcpy(active_pids, pids, num_tests * sizeof(PID_TYPE));
#endif