mirror of
https://github.com/postgres/postgres.git
synced 2025-12-07 12:02:30 +03:00
Use more palloc_object() and palloc_array() in contrib/
The idea is to encourage more the use of these new routines across the tree, as these offer stronger type safety guarantees than palloc(). In an ideal world, palloc() would then act as an internal routine of these flavors, whose footprint in the tree is minimal. The patch sent by the author is very large, and this chunk of changes represents something like 10% of the overall patch submitted. The code compiled is the same before and after this commit, using objdump to do some validation with a difference taken in-between. There are some diffs, which are caused by changes in line numbers because some of the new allocation formulas are shorter, for the following files: trgm_regexp.c, xpath.c and pg_walinspect.c. Author: David Geier <geidav.pg@gmail.com> Discussion: https://postgr.es/m/ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com
This commit is contained in:
@@ -117,7 +117,7 @@ ginReadTupleWithoutState(IndexTuple itup, int *nitems)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ipd = (ItemPointer) palloc(sizeof(ItemPointerData) * nipd);
|
ipd = palloc_array(ItemPointerData, nipd);
|
||||||
memcpy(ipd, ptr, sizeof(ItemPointerData) * nipd);
|
memcpy(ipd, ptr, sizeof(ItemPointerData) * nipd);
|
||||||
}
|
}
|
||||||
*nitems = nipd;
|
*nitems = nipd;
|
||||||
@@ -152,7 +152,7 @@ gin_check_posting_tree_parent_keys_consistency(Relation rel, BlockNumber posting
|
|||||||
leafdepth = -1;
|
leafdepth = -1;
|
||||||
|
|
||||||
/* Start the scan at the root page */
|
/* Start the scan at the root page */
|
||||||
stack = (GinPostingTreeScanItem *) palloc0(sizeof(GinPostingTreeScanItem));
|
stack = palloc0_object(GinPostingTreeScanItem);
|
||||||
stack->depth = 0;
|
stack->depth = 0;
|
||||||
ItemPointerSetInvalid(&stack->parentkey);
|
ItemPointerSetInvalid(&stack->parentkey);
|
||||||
stack->parentblk = InvalidBlockNumber;
|
stack->parentblk = InvalidBlockNumber;
|
||||||
@@ -354,7 +354,7 @@ gin_check_posting_tree_parent_keys_consistency(Relation rel, BlockNumber posting
|
|||||||
stack->blkno, i)));
|
stack->blkno, i)));
|
||||||
|
|
||||||
/* This is an internal page, recurse into the child. */
|
/* This is an internal page, recurse into the child. */
|
||||||
ptr = (GinPostingTreeScanItem *) palloc(sizeof(GinPostingTreeScanItem));
|
ptr = palloc_object(GinPostingTreeScanItem);
|
||||||
ptr->depth = stack->depth + 1;
|
ptr->depth = stack->depth + 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -412,7 +412,7 @@ gin_check_parent_keys_consistency(Relation rel,
|
|||||||
leafdepth = -1;
|
leafdepth = -1;
|
||||||
|
|
||||||
/* Start the scan at the root page */
|
/* Start the scan at the root page */
|
||||||
stack = (GinScanItem *) palloc0(sizeof(GinScanItem));
|
stack = palloc0_object(GinScanItem);
|
||||||
stack->depth = 0;
|
stack->depth = 0;
|
||||||
stack->parenttup = NULL;
|
stack->parenttup = NULL;
|
||||||
stack->parentblk = InvalidBlockNumber;
|
stack->parentblk = InvalidBlockNumber;
|
||||||
@@ -473,7 +473,7 @@ gin_check_parent_keys_consistency(Relation rel,
|
|||||||
|
|
||||||
elog(DEBUG3, "split detected for blk: %u, parent blk: %u", stack->blkno, stack->parentblk);
|
elog(DEBUG3, "split detected for blk: %u, parent blk: %u", stack->blkno, stack->parentblk);
|
||||||
|
|
||||||
ptr = (GinScanItem *) palloc(sizeof(GinScanItem));
|
ptr = palloc_object(GinScanItem);
|
||||||
ptr->depth = stack->depth;
|
ptr->depth = stack->depth;
|
||||||
ptr->parenttup = CopyIndexTuple(stack->parenttup);
|
ptr->parenttup = CopyIndexTuple(stack->parenttup);
|
||||||
ptr->parentblk = stack->parentblk;
|
ptr->parentblk = stack->parentblk;
|
||||||
@@ -601,7 +601,7 @@ gin_check_parent_keys_consistency(Relation rel,
|
|||||||
{
|
{
|
||||||
GinScanItem *ptr;
|
GinScanItem *ptr;
|
||||||
|
|
||||||
ptr = (GinScanItem *) palloc(sizeof(GinScanItem));
|
ptr = palloc_object(GinScanItem);
|
||||||
ptr->depth = stack->depth + 1;
|
ptr->depth = stack->depth + 1;
|
||||||
/* last tuple in layer has no high key */
|
/* last tuple in layer has no high key */
|
||||||
if (i == maxoff && rightlink == InvalidBlockNumber)
|
if (i == maxoff && rightlink == InvalidBlockNumber)
|
||||||
|
|||||||
@@ -1838,7 +1838,7 @@ check_tuple_attribute(HeapCheckContext *ctx)
|
|||||||
{
|
{
|
||||||
ToastedAttribute *ta;
|
ToastedAttribute *ta;
|
||||||
|
|
||||||
ta = (ToastedAttribute *) palloc0(sizeof(ToastedAttribute));
|
ta = palloc0_object(ToastedAttribute);
|
||||||
|
|
||||||
VARATT_EXTERNAL_GET_POINTER(ta->toast_pointer, attr);
|
VARATT_EXTERNAL_GET_POINTER(ta->toast_pointer, attr);
|
||||||
ta->blkno = ctx->blkno;
|
ta->blkno = ctx->blkno;
|
||||||
|
|||||||
@@ -399,7 +399,7 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
|
|||||||
/*
|
/*
|
||||||
* Initialize state for entire verification operation
|
* Initialize state for entire verification operation
|
||||||
*/
|
*/
|
||||||
state = palloc0(sizeof(BtreeCheckState));
|
state = palloc0_object(BtreeCheckState);
|
||||||
state->rel = rel;
|
state->rel = rel;
|
||||||
state->heaprel = heaprel;
|
state->heaprel = heaprel;
|
||||||
state->heapkeyspace = heapkeyspace;
|
state->heapkeyspace = heapkeyspace;
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ shell_get_sink(bbsink *next_sink, void *detail_arg)
|
|||||||
* We remember the current value of basebackup_to_shell.shell_command to
|
* We remember the current value of basebackup_to_shell.shell_command to
|
||||||
* be certain that it can't change under us during the backup.
|
* be certain that it can't change under us during the backup.
|
||||||
*/
|
*/
|
||||||
sink = palloc0(sizeof(bbsink_shell));
|
sink = palloc0_object(bbsink_shell);
|
||||||
*((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_shell_ops;
|
*((const bbsink_ops **) &sink->base.bbs_ops) = &bbsink_shell_ops;
|
||||||
sink->base.bbs_next = next_sink;
|
sink->base.bbs_next = next_sink;
|
||||||
sink->target_detail = detail_arg;
|
sink->target_detail = detail_arg;
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ blbuild(Relation heap, Relation index, IndexInfo *indexInfo)
|
|||||||
|
|
||||||
MemoryContextDelete(buildstate.tmpCtx);
|
MemoryContextDelete(buildstate.tmpCtx);
|
||||||
|
|
||||||
result = (IndexBuildResult *) palloc(sizeof(IndexBuildResult));
|
result = palloc_object(IndexBuildResult);
|
||||||
result->heap_tuples = reltuples;
|
result->heap_tuples = reltuples;
|
||||||
result->index_tuples = buildstate.indtuples;
|
result->index_tuples = buildstate.indtuples;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ blbeginscan(Relation r, int nkeys, int norderbys)
|
|||||||
|
|
||||||
scan = RelationGetIndexScan(r, nkeys, norderbys);
|
scan = RelationGetIndexScan(r, nkeys, norderbys);
|
||||||
|
|
||||||
so = (BloomScanOpaque) palloc(sizeof(BloomScanOpaqueData));
|
so = (BloomScanOpaque) palloc_object(BloomScanOpaqueData);
|
||||||
initBloomState(&so->state, scan->indexRelation);
|
initBloomState(&so->state, scan->indexRelation);
|
||||||
so->sign = NULL;
|
so->sign = NULL;
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
|
|||||||
/* New search: have to calculate search signature */
|
/* New search: have to calculate search signature */
|
||||||
ScanKey skey = scan->keyData;
|
ScanKey skey = scan->keyData;
|
||||||
|
|
||||||
so->sign = palloc0(sizeof(BloomSignatureWord) * so->state.opts.bloomLength);
|
so->sign = palloc0_array(BloomSignatureWord, so->state.opts.bloomLength);
|
||||||
|
|
||||||
for (i = 0; i < scan->numberOfKeys; i++)
|
for (i = 0; i < scan->numberOfKeys; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ makeDefaultBloomOptions(void)
|
|||||||
BloomOptions *opts;
|
BloomOptions *opts;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
opts = (BloomOptions *) palloc0(sizeof(BloomOptions));
|
opts = palloc0_object(BloomOptions);
|
||||||
/* Convert DEFAULT_BLOOM_LENGTH from # of bits to # of words */
|
/* Convert DEFAULT_BLOOM_LENGTH from # of bits to # of words */
|
||||||
opts->bloomLength = (DEFAULT_BLOOM_LENGTH + SIGNWORDBITS - 1) / SIGNWORDBITS;
|
opts->bloomLength = (DEFAULT_BLOOM_LENGTH + SIGNWORDBITS - 1) / SIGNWORDBITS;
|
||||||
for (i = 0; i < INDEX_MAX_KEYS; i++)
|
for (i = 0; i < INDEX_MAX_KEYS; i++)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
|
|||||||
GenericXLogState *gxlogState;
|
GenericXLogState *gxlogState;
|
||||||
|
|
||||||
if (stats == NULL)
|
if (stats == NULL)
|
||||||
stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult));
|
stats = palloc0_object(IndexBulkDeleteResult);
|
||||||
|
|
||||||
initBloomState(&state, index);
|
initBloomState(&state, index);
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ blvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats)
|
|||||||
return stats;
|
return stats;
|
||||||
|
|
||||||
if (stats == NULL)
|
if (stats == NULL)
|
||||||
stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult));
|
stats = palloc0_object(IndexBulkDeleteResult);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate over the pages: insert deleted pages into FSM and collect
|
* Iterate over the pages: insert deleted pages into FSM and collect
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ gin_btree_extract_value(FunctionCallInfo fcinfo, bool is_varlena)
|
|||||||
{
|
{
|
||||||
Datum datum = PG_GETARG_DATUM(0);
|
Datum datum = PG_GETARG_DATUM(0);
|
||||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
||||||
Datum *entries = (Datum *) palloc(sizeof(Datum));
|
Datum *entries = palloc_object(Datum);
|
||||||
|
|
||||||
/* Ensure that values stored in the index are not toasted */
|
/* Ensure that values stored in the index are not toasted */
|
||||||
if (is_varlena)
|
if (is_varlena)
|
||||||
@@ -75,9 +75,9 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
|
|||||||
StrategyNumber strategy = PG_GETARG_UINT16(2);
|
StrategyNumber strategy = PG_GETARG_UINT16(2);
|
||||||
bool **partialmatch = (bool **) PG_GETARG_POINTER(3);
|
bool **partialmatch = (bool **) PG_GETARG_POINTER(3);
|
||||||
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
|
Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4);
|
||||||
Datum *entries = (Datum *) palloc(sizeof(Datum));
|
Datum *entries = palloc_object(Datum);
|
||||||
QueryInfo *data = (QueryInfo *) palloc(sizeof(QueryInfo));
|
QueryInfo *data = palloc_object(QueryInfo);
|
||||||
bool *ptr_partialmatch = (bool *) palloc(sizeof(bool));
|
bool *ptr_partialmatch = palloc_object(bool);
|
||||||
int btree_strat,
|
int btree_strat,
|
||||||
rhs_code;
|
rhs_code;
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ gin_btree_extract_query(FunctionCallInfo fcinfo,
|
|||||||
data->orig_datum = datum;
|
data->orig_datum = datum;
|
||||||
data->entry_datum = entries[0];
|
data->entry_datum = entries[0];
|
||||||
data->typecmp = cmp_fns[rhs_code];
|
data->typecmp = cmp_fns[rhs_code];
|
||||||
*extra_data = (Pointer *) palloc(sizeof(Pointer));
|
*extra_data = palloc_object(Pointer);
|
||||||
**extra_data = (Pointer) data;
|
**extra_data = (Pointer) data;
|
||||||
|
|
||||||
PG_RETURN_POINTER(entries);
|
PG_RETURN_POINTER(entries);
|
||||||
@@ -579,7 +579,7 @@ GIN_SUPPORT(time, leftmostvalue_time, time_rhs_is_varlena, NULL, time_cmp_fns)
|
|||||||
static Datum
|
static Datum
|
||||||
leftmostvalue_timetz(void)
|
leftmostvalue_timetz(void)
|
||||||
{
|
{
|
||||||
TimeTzADT *v = palloc(sizeof(TimeTzADT));
|
TimeTzADT *v = palloc_object(TimeTzADT);
|
||||||
|
|
||||||
v->time = 0;
|
v->time = 0;
|
||||||
v->zone = -24 * 3600; /* XXX is that true? */
|
v->zone = -24 * 3600; /* XXX is that true? */
|
||||||
@@ -639,7 +639,7 @@ GIN_SUPPORT(date, leftmostvalue_date, date_rhs_is_varlena, date_cvt_fns, date_cm
|
|||||||
static Datum
|
static Datum
|
||||||
leftmostvalue_interval(void)
|
leftmostvalue_interval(void)
|
||||||
{
|
{
|
||||||
Interval *v = palloc(sizeof(Interval));
|
Interval *v = palloc_object(Interval);
|
||||||
|
|
||||||
INTERVAL_NOBEGIN(v);
|
INTERVAL_NOBEGIN(v);
|
||||||
|
|
||||||
@@ -657,7 +657,7 @@ GIN_SUPPORT(interval, leftmostvalue_interval, interval_rhs_is_varlena, NULL, int
|
|||||||
static Datum
|
static Datum
|
||||||
leftmostvalue_macaddr(void)
|
leftmostvalue_macaddr(void)
|
||||||
{
|
{
|
||||||
macaddr *v = palloc0(sizeof(macaddr));
|
macaddr *v = palloc0_object(macaddr);
|
||||||
|
|
||||||
return MacaddrPGetDatum(v);
|
return MacaddrPGetDatum(v);
|
||||||
}
|
}
|
||||||
@@ -673,7 +673,7 @@ GIN_SUPPORT(macaddr, leftmostvalue_macaddr, macaddr_rhs_is_varlena, NULL, macadd
|
|||||||
static Datum
|
static Datum
|
||||||
leftmostvalue_macaddr8(void)
|
leftmostvalue_macaddr8(void)
|
||||||
{
|
{
|
||||||
macaddr8 *v = palloc0(sizeof(macaddr8));
|
macaddr8 *v = palloc0_object(macaddr8);
|
||||||
|
|
||||||
return Macaddr8PGetDatum(v);
|
return Macaddr8PGetDatum(v);
|
||||||
}
|
}
|
||||||
@@ -910,7 +910,7 @@ leftmostvalue_uuid(void)
|
|||||||
* palloc0 will create the UUID with all zeroes:
|
* palloc0 will create the UUID with all zeroes:
|
||||||
* "00000000-0000-0000-0000-000000000000"
|
* "00000000-0000-0000-0000-000000000000"
|
||||||
*/
|
*/
|
||||||
pg_uuid_t *retval = (pg_uuid_t *) palloc0(sizeof(pg_uuid_t));
|
pg_uuid_t *retval = palloc0_object(pg_uuid_t);
|
||||||
|
|
||||||
return UUIDPGetDatum(retval);
|
return UUIDPGetDatum(retval);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,10 +97,10 @@ gbt_inet_compress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (entry->leafkey)
|
if (entry->leafkey)
|
||||||
{
|
{
|
||||||
inetKEY *r = (inetKEY *) palloc(sizeof(inetKEY));
|
inetKEY *r = palloc_object(inetKEY);
|
||||||
bool failure = false;
|
bool failure = false;
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
r->lower = convert_network_to_scalar(entry->key, INETOID, &failure);
|
r->lower = convert_network_to_scalar(entry->key, INETOID, &failure);
|
||||||
Assert(!failure);
|
Assert(!failure);
|
||||||
r->upper = r->lower;
|
r->upper = r->lower;
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ gbt_intv_compress(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
char *r = (char *) palloc(2 * INTERVALSIZE);
|
char *r = (char *) palloc(2 * INTERVALSIZE);
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
|
|
||||||
if (entry->leafkey)
|
if (entry->leafkey)
|
||||||
{
|
{
|
||||||
@@ -190,10 +190,10 @@ gbt_intv_decompress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (INTERVALSIZE != sizeof(Interval))
|
if (INTERVALSIZE != sizeof(Interval))
|
||||||
{
|
{
|
||||||
intvKEY *r = palloc(sizeof(intvKEY));
|
intvKEY *r = palloc_object(intvKEY);
|
||||||
char *key = DatumGetPointer(entry->key);
|
char *key = DatumGetPointer(entry->key);
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
memcpy(&r->lower, key, INTERVALSIZE);
|
memcpy(&r->lower, key, INTERVALSIZE);
|
||||||
memcpy(&r->upper, key + INTERVALSIZE, INTERVALSIZE);
|
memcpy(&r->upper, key + INTERVALSIZE, INTERVALSIZE);
|
||||||
|
|
||||||
|
|||||||
@@ -162,11 +162,11 @@ gbt_timetz_compress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (entry->leafkey)
|
if (entry->leafkey)
|
||||||
{
|
{
|
||||||
timeKEY *r = (timeKEY *) palloc(sizeof(timeKEY));
|
timeKEY *r = palloc_object(timeKEY);
|
||||||
TimeTzADT *tz = DatumGetTimeTzADTP(entry->key);
|
TimeTzADT *tz = DatumGetTimeTzADTP(entry->key);
|
||||||
TimeADT tmp;
|
TimeADT tmp;
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
|
|
||||||
/* We are using the time + zone only to compress */
|
/* We are using the time + zone only to compress */
|
||||||
tmp = tz->time + (tz->zone * INT64CONST(1000000));
|
tmp = tz->time + (tz->zone * INT64CONST(1000000));
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ ts_dist(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
|
if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
|
||||||
{
|
{
|
||||||
Interval *p = palloc(sizeof(Interval));
|
Interval *p = palloc_object(Interval);
|
||||||
|
|
||||||
p->day = INT_MAX;
|
p->day = INT_MAX;
|
||||||
p->month = INT_MAX;
|
p->month = INT_MAX;
|
||||||
@@ -170,7 +170,7 @@ tstz_dist(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
|
if (TIMESTAMP_NOT_FINITE(a) || TIMESTAMP_NOT_FINITE(b))
|
||||||
{
|
{
|
||||||
Interval *p = palloc(sizeof(Interval));
|
Interval *p = palloc_object(Interval);
|
||||||
|
|
||||||
p->day = INT_MAX;
|
p->day = INT_MAX;
|
||||||
p->month = INT_MAX;
|
p->month = INT_MAX;
|
||||||
@@ -212,13 +212,13 @@ gbt_tstz_compress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (entry->leafkey)
|
if (entry->leafkey)
|
||||||
{
|
{
|
||||||
tsKEY *r = (tsKEY *) palloc(sizeof(tsKEY));
|
tsKEY *r = palloc_object(tsKEY);
|
||||||
TimestampTz ts = DatumGetTimestampTz(entry->key);
|
TimestampTz ts = DatumGetTimestampTz(entry->key);
|
||||||
Timestamp gmt;
|
Timestamp gmt;
|
||||||
|
|
||||||
gmt = tstz_to_ts_gmt(ts);
|
gmt = tstz_to_ts_gmt(ts);
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
r->lower = r->upper = gmt;
|
r->lower = r->upper = gmt;
|
||||||
gistentryinit(*retval, PointerGetDatum(r),
|
gistentryinit(*retval, PointerGetDatum(r),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
|
|||||||
|
|
||||||
memcpy(&r[0], leaf, tinfo->size);
|
memcpy(&r[0], leaf, tinfo->size);
|
||||||
memcpy(&r[tinfo->size], leaf, tinfo->size);
|
memcpy(&r[tinfo->size], leaf, tinfo->size);
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page,
|
gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page,
|
||||||
entry->offset, false);
|
entry->offset, false);
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)
|
|||||||
datum = entry->key;
|
datum = entry->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, datum, entry->rel, entry->page, entry->offset,
|
gistentryinit(*retval, datum, entry->rel, entry->page, entry->offset,
|
||||||
false);
|
false);
|
||||||
return retval;
|
return retval;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ gbt_var_decompress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (key != (GBT_VARKEY *) DatumGetPointer(entry->key))
|
if (key != (GBT_VARKEY *) DatumGetPointer(entry->key))
|
||||||
{
|
{
|
||||||
GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
GISTENTRY *retval = palloc_object(GISTENTRY);
|
||||||
|
|
||||||
gistentryinit(*retval, PointerGetDatum(key),
|
gistentryinit(*retval, PointerGetDatum(key),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
@@ -289,7 +289,7 @@ gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo)
|
|||||||
|
|
||||||
r = gbt_var_key_from_datum(leaf);
|
r = gbt_var_key_from_datum(leaf);
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(r),
|
gistentryinit(*retval, PointerGetDatum(r),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, true);
|
entry->offset, true);
|
||||||
@@ -309,7 +309,7 @@ gbt_var_fetch(PG_FUNCTION_ARGS)
|
|||||||
GBT_VARKEY_R r = gbt_var_key_readable(key);
|
GBT_VARKEY_R r = gbt_var_key_readable(key);
|
||||||
GISTENTRY *retval;
|
GISTENTRY *retval;
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(r.lower),
|
gistentryinit(*retval, PointerGetDatum(r.lower),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, true);
|
entry->offset, true);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ gbt_uuid_compress(PG_FUNCTION_ARGS)
|
|||||||
char *r = (char *) palloc(2 * UUID_LEN);
|
char *r = (char *) palloc(2 * UUID_LEN);
|
||||||
pg_uuid_t *key = DatumGetUUIDP(entry->key);
|
pg_uuid_t *key = DatumGetUUIDP(entry->key);
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
|
|
||||||
memcpy(r, key, UUID_LEN);
|
memcpy(r, key, UUID_LEN);
|
||||||
memcpy(r + UUID_LEN, key, UUID_LEN);
|
memcpy(r + UUID_LEN, key, UUID_LEN);
|
||||||
|
|||||||
@@ -471,7 +471,7 @@ g_cube_decompress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (key != DatumGetNDBOXP(entry->key))
|
if (key != DatumGetNDBOXP(entry->key))
|
||||||
{
|
{
|
||||||
GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
GISTENTRY *retval = palloc_object(GISTENTRY);
|
||||||
|
|
||||||
gistentryinit(*retval, PointerGetDatum(key),
|
gistentryinit(*retval, PointerGetDatum(key),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ dintdict_init(PG_FUNCTION_ARGS)
|
|||||||
DictInt *d;
|
DictInt *d;
|
||||||
ListCell *l;
|
ListCell *l;
|
||||||
|
|
||||||
d = (DictInt *) palloc0(sizeof(DictInt));
|
d = palloc0_object(DictInt);
|
||||||
d->maxlen = 6;
|
d->maxlen = 6;
|
||||||
d->rejectlong = false;
|
d->rejectlong = false;
|
||||||
d->absval = false;
|
d->absval = false;
|
||||||
@@ -83,7 +83,7 @@ dintdict_lexize(PG_FUNCTION_ARGS)
|
|||||||
char *in = (char *) PG_GETARG_POINTER(1);
|
char *in = (char *) PG_GETARG_POINTER(1);
|
||||||
int len = PG_GETARG_INT32(2);
|
int len = PG_GETARG_INT32(2);
|
||||||
char *txt;
|
char *txt;
|
||||||
TSLexeme *res = palloc0(sizeof(TSLexeme) * 2);
|
TSLexeme *res = palloc0_array(TSLexeme, 2);
|
||||||
|
|
||||||
res[1].lexeme = NULL;
|
res[1].lexeme = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -109,9 +109,9 @@ read_dictionary(DictSyn *d, const char *filename)
|
|||||||
{
|
{
|
||||||
d->len = (d->len > 0) ? 2 * d->len : 16;
|
d->len = (d->len > 0) ? 2 * d->len : 16;
|
||||||
if (d->syn)
|
if (d->syn)
|
||||||
d->syn = (Syn *) repalloc(d->syn, sizeof(Syn) * d->len);
|
d->syn = repalloc_array(d->syn, Syn, d->len);
|
||||||
else
|
else
|
||||||
d->syn = (Syn *) palloc(sizeof(Syn) * d->len);
|
d->syn = palloc_array(Syn, d->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save first word only if we will match it */
|
/* Save first word only if we will match it */
|
||||||
@@ -150,7 +150,7 @@ dxsyn_init(PG_FUNCTION_ARGS)
|
|||||||
ListCell *l;
|
ListCell *l;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
|
|
||||||
d = (DictSyn *) palloc0(sizeof(DictSyn));
|
d = palloc0_object(DictSyn);
|
||||||
d->len = 0;
|
d->len = 0;
|
||||||
d->syn = NULL;
|
d->syn = NULL;
|
||||||
d->matchorig = true;
|
d->matchorig = true;
|
||||||
@@ -235,7 +235,7 @@ dxsyn_lexize(PG_FUNCTION_ARGS)
|
|||||||
char *end;
|
char *end;
|
||||||
int nsyns = 0;
|
int nsyns = 0;
|
||||||
|
|
||||||
res = palloc(sizeof(TSLexeme));
|
res = palloc_object(TSLexeme);
|
||||||
|
|
||||||
pos = value;
|
pos = value;
|
||||||
while ((syn = find_word(pos, &end)) != NULL)
|
while ((syn = find_word(pos, &end)) != NULL)
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ fileGetForeignRelSize(PlannerInfo *root,
|
|||||||
* we might as well get everything and not need to re-fetch it later in
|
* we might as well get everything and not need to re-fetch it later in
|
||||||
* planning.
|
* planning.
|
||||||
*/
|
*/
|
||||||
fdw_private = (FileFdwPlanState *) palloc(sizeof(FileFdwPlanState));
|
fdw_private = palloc_object(FileFdwPlanState);
|
||||||
fileGetOptions(foreigntableid,
|
fileGetOptions(foreigntableid,
|
||||||
&fdw_private->filename,
|
&fdw_private->filename,
|
||||||
&fdw_private->is_program,
|
&fdw_private->is_program,
|
||||||
@@ -712,7 +712,7 @@ fileBeginForeignScan(ForeignScanState *node, int eflags)
|
|||||||
* Save state in node->fdw_state. We must save enough information to call
|
* Save state in node->fdw_state. We must save enough information to call
|
||||||
* BeginCopyFrom() again.
|
* BeginCopyFrom() again.
|
||||||
*/
|
*/
|
||||||
festate = (FileFdwExecutionState *) palloc(sizeof(FileFdwExecutionState));
|
festate = palloc_object(FileFdwExecutionState);
|
||||||
festate->filename = filename;
|
festate->filename = filename;
|
||||||
festate->is_program = is_program;
|
festate->is_program = is_program;
|
||||||
festate->options = options;
|
festate->options = options;
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ ghstore_compress(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(res),
|
gistentryinit(*retval, PointerGetDatum(res),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset,
|
entry->offset,
|
||||||
@@ -195,7 +195,7 @@ ghstore_compress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
res = ghstore_alloc(true, siglen, NULL);
|
res = ghstore_alloc(true, siglen, NULL);
|
||||||
|
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(res),
|
gistentryinit(*retval, PointerGetDatum(res),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset,
|
entry->offset,
|
||||||
@@ -429,7 +429,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
maxoff = OffsetNumberNext(maxoff);
|
maxoff = OffsetNumberNext(maxoff);
|
||||||
/* sort before ... */
|
/* sort before ... */
|
||||||
costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
|
costvector = palloc_array(SPLITCOST, maxoff);
|
||||||
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
||||||
{
|
{
|
||||||
costvector[j - 1].pos = j;
|
costvector[j - 1].pos = j;
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ parse_hstore(HSParser *state)
|
|||||||
bool escaped = false;
|
bool escaped = false;
|
||||||
|
|
||||||
state->plen = 16;
|
state->plen = 16;
|
||||||
state->pairs = (Pairs *) palloc(sizeof(Pairs) * state->plen);
|
state->pairs = palloc_array(Pairs, state->plen);
|
||||||
state->pcur = 0;
|
state->pcur = 0;
|
||||||
state->ptr = state->begin;
|
state->ptr = state->begin;
|
||||||
state->word = NULL;
|
state->word = NULL;
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ gettoken(WORKSTATE *state, int32 *val)
|
|||||||
static void
|
static void
|
||||||
pushquery(WORKSTATE *state, int32 type, int32 val)
|
pushquery(WORKSTATE *state, int32 type, int32 val)
|
||||||
{
|
{
|
||||||
NODE *tmp = (NODE *) palloc(sizeof(NODE));
|
NODE *tmp = palloc_object(NODE);
|
||||||
|
|
||||||
tmp->type = type;
|
tmp->type = type;
|
||||||
tmp->val = val;
|
tmp->val = val;
|
||||||
@@ -346,7 +346,7 @@ gin_bool_consistent(QUERYTYPE *query, bool *check)
|
|||||||
* extraction code in ginint4_queryextract.
|
* extraction code in ginint4_queryextract.
|
||||||
*/
|
*/
|
||||||
gcv.first = items;
|
gcv.first = items;
|
||||||
gcv.mapped_check = (bool *) palloc(sizeof(bool) * query->size);
|
gcv.mapped_check = palloc_array(bool, query->size);
|
||||||
for (i = 0; i < query->size; i++)
|
for (i = 0; i < query->size; i++)
|
||||||
{
|
{
|
||||||
if (items[i].type == VAL)
|
if (items[i].type == VAL)
|
||||||
@@ -613,7 +613,7 @@ infix(INFIX *in, bool first)
|
|||||||
|
|
||||||
nrm.curpol = in->curpol;
|
nrm.curpol = in->curpol;
|
||||||
nrm.buflen = 16;
|
nrm.buflen = 16;
|
||||||
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
|
nrm.cur = nrm.buf = palloc_array(char, nrm.buflen);
|
||||||
|
|
||||||
/* get right operand */
|
/* get right operand */
|
||||||
infix(&nrm, false);
|
infix(&nrm, false);
|
||||||
@@ -651,7 +651,7 @@ bqarr_out(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
nrm.curpol = GETQUERY(query) + query->size - 1;
|
nrm.curpol = GETQUERY(query) + query->size - 1;
|
||||||
nrm.buflen = 32;
|
nrm.buflen = 32;
|
||||||
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
|
nrm.cur = nrm.buf = palloc_array(char, nrm.buflen);
|
||||||
*(nrm.cur) = '\0';
|
*(nrm.cur) = '\0';
|
||||||
infix(&nrm, true);
|
infix(&nrm, true);
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ ginint4_queryextract(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* Extract all the VAL items as things we want GIN to check for.
|
* Extract all the VAL items as things we want GIN to check for.
|
||||||
*/
|
*/
|
||||||
res = (Datum *) palloc(sizeof(Datum) * query->size);
|
res = palloc_array(Datum, query->size);
|
||||||
*nentries = 0;
|
*nentries = 0;
|
||||||
|
|
||||||
for (i = 0; i < query->size; i++)
|
for (i = 0; i < query->size; i++)
|
||||||
@@ -65,7 +65,7 @@ ginint4_queryextract(PG_FUNCTION_ARGS)
|
|||||||
int32 *arr;
|
int32 *arr;
|
||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
res = (Datum *) palloc(sizeof(Datum) * (*nentries));
|
res = palloc_array(Datum, *nentries);
|
||||||
|
|
||||||
arr = ARRPTR(query);
|
arr = ARRPTR(query);
|
||||||
for (i = 0; i < *nentries; i++)
|
for (i = 0; i < *nentries; i++)
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ g_int_compress(PG_FUNCTION_ARGS)
|
|||||||
errmsg("input array is too big (%d maximum allowed, %d current), use gist__intbig_ops opclass instead",
|
errmsg("input array is too big (%d maximum allowed, %d current), use gist__intbig_ops opclass instead",
|
||||||
2 * num_ranges - 1, ARRNELEMS(r))));
|
2 * num_ranges - 1, ARRNELEMS(r))));
|
||||||
|
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(r),
|
gistentryinit(*retval, PointerGetDatum(r),
|
||||||
entry->rel, entry->page, entry->offset, false);
|
entry->rel, entry->page, entry->offset, false);
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ g_int_compress(PG_FUNCTION_ARGS)
|
|||||||
errmsg("data is too sparse, recreate index using gist__intbig_ops opclass instead")));
|
errmsg("data is too sparse, recreate index using gist__intbig_ops opclass instead")));
|
||||||
|
|
||||||
r = resize_intArrayType(r, len);
|
r = resize_intArrayType(r, len);
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(r),
|
gistentryinit(*retval, PointerGetDatum(r),
|
||||||
entry->rel, entry->page, entry->offset, false);
|
entry->rel, entry->page, entry->offset, false);
|
||||||
PG_RETURN_POINTER(retval);
|
PG_RETURN_POINTER(retval);
|
||||||
@@ -306,7 +306,7 @@ g_int_decompress(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
if (in != (ArrayType *) DatumGetPointer(entry->key))
|
if (in != (ArrayType *) DatumGetPointer(entry->key))
|
||||||
{
|
{
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(in),
|
gistentryinit(*retval, PointerGetDatum(in),
|
||||||
entry->rel, entry->page, entry->offset, false);
|
entry->rel, entry->page, entry->offset, false);
|
||||||
PG_RETURN_POINTER(retval);
|
PG_RETURN_POINTER(retval);
|
||||||
@@ -321,7 +321,7 @@ g_int_decompress(PG_FUNCTION_ARGS)
|
|||||||
{ /* not compressed value */
|
{ /* not compressed value */
|
||||||
if (in != (ArrayType *) DatumGetPointer(entry->key))
|
if (in != (ArrayType *) DatumGetPointer(entry->key))
|
||||||
{
|
{
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(in),
|
gistentryinit(*retval, PointerGetDatum(in),
|
||||||
entry->rel, entry->page, entry->offset, false);
|
entry->rel, entry->page, entry->offset, false);
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ g_int_decompress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (in != (ArrayType *) DatumGetPointer(entry->key))
|
if (in != (ArrayType *) DatumGetPointer(entry->key))
|
||||||
pfree(in);
|
pfree(in);
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(r),
|
gistentryinit(*retval, PointerGetDatum(r),
|
||||||
entry->rel, entry->page, entry->offset, false);
|
entry->rel, entry->page, entry->offset, false);
|
||||||
|
|
||||||
@@ -535,7 +535,7 @@ g_int_picksplit(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* sort entries
|
* sort entries
|
||||||
*/
|
*/
|
||||||
costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
|
costvector = palloc_array(SPLITCOST, maxoff);
|
||||||
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
|
for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
|
||||||
{
|
{
|
||||||
costvector[i - 1].pos = i;
|
costvector[i - 1].pos = i;
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ g_intbig_compress(PG_FUNCTION_ARGS)
|
|||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(res),
|
gistentryinit(*retval, PointerGetDatum(res),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, false);
|
entry->offset, false);
|
||||||
@@ -195,7 +195,7 @@ g_intbig_compress(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = _intbig_alloc(true, siglen, sign);
|
res = _intbig_alloc(true, siglen, sign);
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(res),
|
gistentryinit(*retval, PointerGetDatum(res),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, false);
|
entry->offset, false);
|
||||||
@@ -385,7 +385,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
maxoff = OffsetNumberNext(maxoff);
|
maxoff = OffsetNumberNext(maxoff);
|
||||||
/* sort before ... */
|
/* sort before ... */
|
||||||
costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
|
costvector = palloc_array(SPLITCOST, maxoff);
|
||||||
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
||||||
{
|
{
|
||||||
costvector[j - 1].pos = j;
|
costvector[j - 1].pos = j;
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ SV_to_JsonbValue(SV *in, JsonbParseState **jsonb_state, bool is_elem)
|
|||||||
/* Push result into 'jsonb_state' unless it is a raw scalar. */
|
/* Push result into 'jsonb_state' unless it is a raw scalar. */
|
||||||
return *jsonb_state
|
return *jsonb_state
|
||||||
? pushJsonbValue(jsonb_state, is_elem ? WJB_ELEM : WJB_VALUE, &out)
|
? pushJsonbValue(jsonb_state, is_elem ? WJB_ELEM : WJB_VALUE, &out)
|
||||||
: memcpy(palloc(sizeof(JsonbValue)), &out, sizeof(JsonbValue));
|
: memcpy(palloc_object(JsonbValue), &out, sizeof(JsonbValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ PLyObject_ToJsonbValue(PyObject *obj, JsonbParseState **jsonb_state, bool is_ele
|
|||||||
return PLyMapping_ToJsonbValue(obj, jsonb_state);
|
return PLyMapping_ToJsonbValue(obj, jsonb_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
out = palloc(sizeof(JsonbValue));
|
out = palloc_object(JsonbValue);
|
||||||
|
|
||||||
if (obj == Py_None)
|
if (obj == Py_None)
|
||||||
out->type = jbvNull;
|
out->type = jbvNull;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
|
|||||||
item = NEXTVAL(item);
|
item = NEXTVAL(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(key),
|
gistentryinit(*retval, PointerGetDatum(key),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, false);
|
entry->offset, false);
|
||||||
@@ -97,7 +97,7 @@ _ltree_compress(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
key = ltree_gist_alloc(true, sign, siglen, NULL, NULL);
|
key = ltree_gist_alloc(true, sign, siglen, NULL, NULL);
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(key),
|
gistentryinit(*retval, PointerGetDatum(key),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, false);
|
entry->offset, false);
|
||||||
@@ -310,7 +310,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
maxoff = OffsetNumberNext(maxoff);
|
maxoff = OffsetNumberNext(maxoff);
|
||||||
/* sort before ... */
|
/* sort before ... */
|
||||||
costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
|
costvector = palloc_array(SPLITCOST, maxoff);
|
||||||
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
||||||
{
|
{
|
||||||
costvector[j - 1].pos = j;
|
costvector[j - 1].pos = j;
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ _lca(PG_FUNCTION_ARGS)
|
|||||||
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
|
||||||
errmsg("array must not contain nulls")));
|
errmsg("array must not contain nulls")));
|
||||||
|
|
||||||
a = (ltree **) palloc(sizeof(ltree *) * num);
|
a = palloc_array(ltree *, num);
|
||||||
while (num > 0)
|
while (num > 0)
|
||||||
{
|
{
|
||||||
num--;
|
num--;
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ ltree_compress(PG_FUNCTION_ARGS)
|
|||||||
ltree *val = DatumGetLtreeP(entry->key);
|
ltree *val = DatumGetLtreeP(entry->key);
|
||||||
ltree_gist *key = ltree_gist_alloc(false, NULL, 0, val, 0);
|
ltree_gist *key = ltree_gist_alloc(false, NULL, 0, val, 0);
|
||||||
|
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(key),
|
gistentryinit(*retval, PointerGetDatum(key),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, false);
|
entry->offset, false);
|
||||||
@@ -117,7 +117,7 @@ ltree_decompress(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (PointerGetDatum(key) != entry->key)
|
if (PointerGetDatum(key) != entry->key)
|
||||||
{
|
{
|
||||||
GISTENTRY *retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
GISTENTRY *retval = palloc_object(GISTENTRY);
|
||||||
|
|
||||||
gistentryinit(*retval, PointerGetDatum(key),
|
gistentryinit(*retval, PointerGetDatum(key),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
@@ -318,7 +318,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
|
|||||||
v->spl_right = (OffsetNumber *) palloc(nbytes);
|
v->spl_right = (OffsetNumber *) palloc(nbytes);
|
||||||
v->spl_nleft = 0;
|
v->spl_nleft = 0;
|
||||||
v->spl_nright = 0;
|
v->spl_nright = 0;
|
||||||
array = (RIX *) palloc(sizeof(RIX) * (maxoff + 1));
|
array = palloc_array(RIX, maxoff + 1);
|
||||||
|
|
||||||
/* copy the data into RIXes, and sort the RIXes */
|
/* copy the data into RIXes, and sort the RIXes */
|
||||||
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ parse_ltree(const char *buf, struct Node *escontext)
|
|||||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||||
errmsg("number of ltree labels (%d) exceeds the maximum allowed (%d)",
|
errmsg("number of ltree labels (%d) exceeds the maximum allowed (%d)",
|
||||||
num + 1, LTREE_MAX_LEVELS)));
|
num + 1, LTREE_MAX_LEVELS)));
|
||||||
list = lptr = (nodeitem *) palloc(sizeof(nodeitem) * (num + 1));
|
list = lptr = palloc_array(nodeitem, num + 1);
|
||||||
ptr = buf;
|
ptr = buf;
|
||||||
while (*ptr)
|
while (*ptr)
|
||||||
{
|
{
|
||||||
@@ -318,14 +318,14 @@ parse_lquery(const char *buf, struct Node *escontext)
|
|||||||
case LQPRS_WAITLEVEL:
|
case LQPRS_WAITLEVEL:
|
||||||
if (ISLABEL(ptr))
|
if (ISLABEL(ptr))
|
||||||
{
|
{
|
||||||
GETVAR(curqlevel) = lptr = (nodeitem *) palloc0(sizeof(nodeitem) * (numOR + 1));
|
GETVAR(curqlevel) = lptr = palloc0_array(nodeitem, numOR + 1);
|
||||||
lptr->start = ptr;
|
lptr->start = ptr;
|
||||||
state = LQPRS_WAITDELIM;
|
state = LQPRS_WAITDELIM;
|
||||||
curqlevel->numvar = 1;
|
curqlevel->numvar = 1;
|
||||||
}
|
}
|
||||||
else if (t_iseq(ptr, '!'))
|
else if (t_iseq(ptr, '!'))
|
||||||
{
|
{
|
||||||
GETVAR(curqlevel) = lptr = (nodeitem *) palloc0(sizeof(nodeitem) * (numOR + 1));
|
GETVAR(curqlevel) = lptr = palloc0_array(nodeitem, numOR + 1);
|
||||||
lptr->start = ptr + 1;
|
lptr->start = ptr + 1;
|
||||||
lptr->wlen = -1; /* compensate for counting ! below */
|
lptr->wlen = -1; /* compensate for counting ! below */
|
||||||
state = LQPRS_WAITDELIM;
|
state = LQPRS_WAITDELIM;
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ lca(PG_FUNCTION_ARGS)
|
|||||||
ltree **a,
|
ltree **a,
|
||||||
*res;
|
*res;
|
||||||
|
|
||||||
a = (ltree **) palloc(sizeof(ltree *) * fcinfo->nargs);
|
a = palloc_array(ltree *, fcinfo->nargs);
|
||||||
for (i = 0; i < fcinfo->nargs; i++)
|
for (i = 0; i < fcinfo->nargs; i++)
|
||||||
a[i] = PG_GETARG_LTREE_P(i);
|
a[i] = PG_GETARG_LTREE_P(i);
|
||||||
res = lca_inner(a, (int) fcinfo->nargs);
|
res = lca_inner(a, (int) fcinfo->nargs);
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ gettoken_query(QPRS_STATE *state, int32 *val, int32 *lenval, char **strval, uint
|
|||||||
static bool
|
static bool
|
||||||
pushquery(QPRS_STATE *state, int32 type, int32 val, int32 distance, int32 lenval, uint16 flag)
|
pushquery(QPRS_STATE *state, int32 type, int32 val, int32 distance, int32 lenval, uint16 flag)
|
||||||
{
|
{
|
||||||
NODE *tmp = (NODE *) palloc(sizeof(NODE));
|
NODE *tmp = palloc_object(NODE);
|
||||||
|
|
||||||
tmp->type = type;
|
tmp->type = type;
|
||||||
tmp->val = val;
|
tmp->val = val;
|
||||||
@@ -543,7 +543,7 @@ infix(INFIX *in, bool first)
|
|||||||
nrm.curpol = in->curpol;
|
nrm.curpol = in->curpol;
|
||||||
nrm.op = in->op;
|
nrm.op = in->op;
|
||||||
nrm.buflen = 16;
|
nrm.buflen = 16;
|
||||||
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
|
nrm.cur = nrm.buf = palloc_array(char, nrm.buflen);
|
||||||
|
|
||||||
/* get right operand */
|
/* get right operand */
|
||||||
infix(&nrm, false);
|
infix(&nrm, false);
|
||||||
@@ -582,7 +582,7 @@ ltxtq_out(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
nrm.curpol = GETQUERY(query);
|
nrm.curpol = GETQUERY(query);
|
||||||
nrm.buflen = 32;
|
nrm.buflen = 32;
|
||||||
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
|
nrm.cur = nrm.buf = palloc_array(char, nrm.buflen);
|
||||||
*(nrm.cur) = '\0';
|
*(nrm.cur) = '\0';
|
||||||
nrm.op = GETOPERAND(query);
|
nrm.op = GETOPERAND(query);
|
||||||
infix(&nrm, true);
|
infix(&nrm, true);
|
||||||
@@ -615,7 +615,7 @@ ltxtq_send(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
nrm.curpol = GETQUERY(query);
|
nrm.curpol = GETQUERY(query);
|
||||||
nrm.buflen = 32;
|
nrm.buflen = 32;
|
||||||
nrm.cur = nrm.buf = (char *) palloc(sizeof(char) * nrm.buflen);
|
nrm.cur = nrm.buf = palloc_array(char, nrm.buflen);
|
||||||
*(nrm.cur) = '\0';
|
*(nrm.cur) = '\0';
|
||||||
nrm.op = GETOPERAND(query);
|
nrm.op = GETOPERAND(query);
|
||||||
infix(&nrm, true);
|
infix(&nrm, true);
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ brin_page_items(PG_FUNCTION_ARGS)
|
|||||||
* Initialize output functions for all indexed datatypes; simplifies
|
* Initialize output functions for all indexed datatypes; simplifies
|
||||||
* calling them later.
|
* calling them later.
|
||||||
*/
|
*/
|
||||||
columns = palloc(sizeof(brin_column_state *) * RelationGetDescr(indexRel)->natts);
|
columns = palloc_array(brin_column_state *, RelationGetDescr(indexRel)->natts);
|
||||||
for (attno = 1; attno <= bdesc->bd_tupdesc->natts; attno++)
|
for (attno = 1; attno <= bdesc->bd_tupdesc->natts; attno++)
|
||||||
{
|
{
|
||||||
Oid output;
|
Oid output;
|
||||||
|
|||||||
@@ -379,7 +379,7 @@ bt_multi_page_stats(PG_FUNCTION_ARGS)
|
|||||||
/* Save arguments for reuse */
|
/* Save arguments for reuse */
|
||||||
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
|
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
|
||||||
|
|
||||||
uargs = palloc(sizeof(ua_page_stats));
|
uargs = palloc_object(ua_page_stats);
|
||||||
|
|
||||||
uargs->relid = RelationGetRelid(rel);
|
uargs->relid = RelationGetRelid(rel);
|
||||||
uargs->blkno = blkno;
|
uargs->blkno = blkno;
|
||||||
@@ -660,7 +660,7 @@ bt_page_items_internal(PG_FUNCTION_ARGS, enum pageinspect_version ext_version)
|
|||||||
*/
|
*/
|
||||||
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
|
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
|
||||||
|
|
||||||
uargs = palloc(sizeof(ua_page_items));
|
uargs = palloc_object(ua_page_items);
|
||||||
|
|
||||||
uargs->page = palloc(BLCKSZ);
|
uargs->page = palloc(BLCKSZ);
|
||||||
memcpy(uargs->page, BufferGetPage(buffer), BLCKSZ);
|
memcpy(uargs->page, BufferGetPage(buffer), BLCKSZ);
|
||||||
@@ -752,7 +752,7 @@ bt_page_items_bytea(PG_FUNCTION_ARGS)
|
|||||||
fctx = SRF_FIRSTCALL_INIT();
|
fctx = SRF_FIRSTCALL_INIT();
|
||||||
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
|
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
|
||||||
|
|
||||||
uargs = palloc(sizeof(ua_page_items));
|
uargs = palloc_object(ua_page_items);
|
||||||
|
|
||||||
uargs->page = get_page_from_raw(raw_page);
|
uargs->page = get_page_from_raw(raw_page);
|
||||||
|
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ gin_leafpage_items(PG_FUNCTION_ARGS)
|
|||||||
opaq->flags,
|
opaq->flags,
|
||||||
(GIN_DATA | GIN_LEAF | GIN_COMPRESSED))));
|
(GIN_DATA | GIN_LEAF | GIN_COMPRESSED))));
|
||||||
|
|
||||||
inter_call_data = palloc(sizeof(gin_leafpage_items_state));
|
inter_call_data = palloc_object(gin_leafpage_items_state);
|
||||||
|
|
||||||
/* Build a tuple descriptor for our result type */
|
/* Build a tuple descriptor for our result type */
|
||||||
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ hash_page_items(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
page = verify_hash_page(raw_page, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE);
|
page = verify_hash_page(raw_page, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE);
|
||||||
|
|
||||||
uargs = palloc(sizeof(struct user_args));
|
uargs = palloc_object(struct user_args);
|
||||||
|
|
||||||
uargs->page = page;
|
uargs->page = page;
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ heap_page_items(PG_FUNCTION_ARGS)
|
|||||||
fctx = SRF_FIRSTCALL_INIT();
|
fctx = SRF_FIRSTCALL_INIT();
|
||||||
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
|
mctx = MemoryContextSwitchTo(fctx->multi_call_memory_ctx);
|
||||||
|
|
||||||
inter_call_data = palloc(sizeof(heap_page_items_state));
|
inter_call_data = palloc_object(heap_page_items_state);
|
||||||
|
|
||||||
/* Build a tuple descriptor for our result type */
|
/* Build a tuple descriptor for our result type */
|
||||||
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
@@ -553,7 +553,7 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* build set of raw flags */
|
/* build set of raw flags */
|
||||||
flags = (Datum *) palloc0(sizeof(Datum) * bitcnt);
|
flags = palloc0_array(Datum, bitcnt);
|
||||||
|
|
||||||
/* decode t_infomask */
|
/* decode t_infomask */
|
||||||
if ((t_infomask & HEAP_HASNULL) != 0)
|
if ((t_infomask & HEAP_HASNULL) != 0)
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ overexplain_ensure_options(ExplainState *es)
|
|||||||
|
|
||||||
if (options == NULL)
|
if (options == NULL)
|
||||||
{
|
{
|
||||||
options = palloc0(sizeof(overexplain_options));
|
options = palloc0_object(overexplain_options);
|
||||||
SetExplainExtensionState(es, es_extension_id, options);
|
SetExplainExtensionState(es, es_extension_id, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ gin_extract_value_trgm(PG_FUNCTION_ARGS)
|
|||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
*nentries = trglen;
|
*nentries = trglen;
|
||||||
entries = (Datum *) palloc(sizeof(Datum) * trglen);
|
entries = palloc_array(Datum, trglen);
|
||||||
|
|
||||||
ptr = GETARR(trg);
|
ptr = GETARR(trg);
|
||||||
for (i = 0; i < trglen; i++)
|
for (i = 0; i < trglen; i++)
|
||||||
@@ -123,7 +123,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
|
|||||||
* Pointers, but we just put the same value in each element.
|
* Pointers, but we just put the same value in each element.
|
||||||
*/
|
*/
|
||||||
trglen = ARRNELEM(trg);
|
trglen = ARRNELEM(trg);
|
||||||
*extra_data = (Pointer *) palloc(sizeof(Pointer) * trglen);
|
*extra_data = palloc_array(Pointer, trglen);
|
||||||
for (i = 0; i < trglen; i++)
|
for (i = 0; i < trglen; i++)
|
||||||
(*extra_data)[i] = (Pointer) graph;
|
(*extra_data)[i] = (Pointer) graph;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
if (trglen > 0)
|
if (trglen > 0)
|
||||||
{
|
{
|
||||||
entries = (Datum *) palloc(sizeof(Datum) * trglen);
|
entries = palloc_array(Datum, trglen);
|
||||||
ptr = GETARR(trg);
|
ptr = GETARR(trg);
|
||||||
for (i = 0; i < trglen; i++)
|
for (i = 0; i < trglen; i++)
|
||||||
{
|
{
|
||||||
@@ -338,7 +338,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS)
|
|||||||
* function, promoting all GIN_MAYBE keys to GIN_TRUE will
|
* function, promoting all GIN_MAYBE keys to GIN_TRUE will
|
||||||
* give a conservative result.
|
* give a conservative result.
|
||||||
*/
|
*/
|
||||||
boolcheck = (bool *) palloc(sizeof(bool) * nkeys);
|
boolcheck = palloc_array(bool, nkeys);
|
||||||
for (i = 0; i < nkeys; i++)
|
for (i = 0; i < nkeys; i++)
|
||||||
boolcheck[i] = (check[i] != GIN_FALSE);
|
boolcheck[i] = (check[i] != GIN_FALSE);
|
||||||
if (!trigramsMatchGraph(extra_data[0], boolcheck))
|
if (!trigramsMatchGraph(extra_data[0], boolcheck))
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ gtrgm_compress(PG_FUNCTION_ARGS)
|
|||||||
text *val = DatumGetTextPP(entry->key);
|
text *val = DatumGetTextPP(entry->key);
|
||||||
|
|
||||||
res = generate_trgm(VARDATA_ANY(val), VARSIZE_ANY_EXHDR(val));
|
res = generate_trgm(VARDATA_ANY(val), VARSIZE_ANY_EXHDR(val));
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(res),
|
gistentryinit(*retval, PointerGetDatum(res),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, false);
|
entry->offset, false);
|
||||||
@@ -143,7 +143,7 @@ gtrgm_compress(PG_FUNCTION_ARGS)
|
|||||||
}
|
}
|
||||||
|
|
||||||
res = gtrgm_alloc(true, siglen, sign);
|
res = gtrgm_alloc(true, siglen, sign);
|
||||||
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(res),
|
gistentryinit(*retval, PointerGetDatum(res),
|
||||||
entry->rel, entry->page,
|
entry->rel, entry->page,
|
||||||
entry->offset, false);
|
entry->offset, false);
|
||||||
@@ -163,7 +163,7 @@ gtrgm_decompress(PG_FUNCTION_ARGS)
|
|||||||
if (key != (text *) DatumGetPointer(entry->key))
|
if (key != (text *) DatumGetPointer(entry->key))
|
||||||
{
|
{
|
||||||
/* need to pass back the decompressed item */
|
/* need to pass back the decompressed item */
|
||||||
retval = palloc(sizeof(GISTENTRY));
|
retval = palloc_object(GISTENTRY);
|
||||||
gistentryinit(*retval, PointerGetDatum(key),
|
gistentryinit(*retval, PointerGetDatum(key),
|
||||||
entry->rel, entry->page, entry->offset, entry->leafkey);
|
entry->rel, entry->page, entry->offset, entry->leafkey);
|
||||||
PG_RETURN_POINTER(retval);
|
PG_RETURN_POINTER(retval);
|
||||||
@@ -820,7 +820,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
|
|||||||
SPLITCOST *costvector;
|
SPLITCOST *costvector;
|
||||||
|
|
||||||
/* cache the sign data for each existing item */
|
/* cache the sign data for each existing item */
|
||||||
cache = (CACHESIGN *) palloc(sizeof(CACHESIGN) * (maxoff + 1));
|
cache = palloc_array(CACHESIGN, maxoff + 1);
|
||||||
cache_sign = palloc(siglen * (maxoff + 1));
|
cache_sign = palloc(siglen * (maxoff + 1));
|
||||||
|
|
||||||
for (k = FirstOffsetNumber; k <= maxoff; k = OffsetNumberNext(k))
|
for (k = FirstOffsetNumber; k <= maxoff; k = OffsetNumberNext(k))
|
||||||
@@ -864,7 +864,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
|
|||||||
union_r = GETSIGN(datum_r);
|
union_r = GETSIGN(datum_r);
|
||||||
|
|
||||||
/* sort before ... */
|
/* sort before ... */
|
||||||
costvector = (SPLITCOST *) palloc(sizeof(SPLITCOST) * maxoff);
|
costvector = palloc_array(SPLITCOST, maxoff);
|
||||||
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
|
||||||
{
|
{
|
||||||
costvector[j - 1].pos = j;
|
costvector[j - 1].pos = j;
|
||||||
|
|||||||
@@ -791,12 +791,11 @@ getColorInfo(regex_t *regex, TrgmNFA *trgmNFA)
|
|||||||
|
|
||||||
colorInfo->expandable = true;
|
colorInfo->expandable = true;
|
||||||
colorInfo->containsNonWord = false;
|
colorInfo->containsNonWord = false;
|
||||||
colorInfo->wordChars = (trgm_mb_char *)
|
colorInfo->wordChars = palloc_array(trgm_mb_char, charsCount);
|
||||||
palloc(sizeof(trgm_mb_char) * charsCount);
|
|
||||||
colorInfo->wordCharsCount = 0;
|
colorInfo->wordCharsCount = 0;
|
||||||
|
|
||||||
/* Extract all the chars in this color */
|
/* Extract all the chars in this color */
|
||||||
chars = (pg_wchar *) palloc(sizeof(pg_wchar) * charsCount);
|
chars = palloc_array(pg_wchar, charsCount);
|
||||||
pg_reg_getcharacters(regex, i, chars, charsCount);
|
pg_reg_getcharacters(regex, i, chars, charsCount);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1063,7 +1062,7 @@ addKey(TrgmNFA *trgmNFA, TrgmState *state, TrgmStateKey *key)
|
|||||||
* original NFA.
|
* original NFA.
|
||||||
*/
|
*/
|
||||||
arcsCount = pg_reg_getnumoutarcs(trgmNFA->regex, key->nstate);
|
arcsCount = pg_reg_getnumoutarcs(trgmNFA->regex, key->nstate);
|
||||||
arcs = (regex_arc_t *) palloc(sizeof(regex_arc_t) * arcsCount);
|
arcs = palloc_array(regex_arc_t, arcsCount);
|
||||||
pg_reg_getoutarcs(trgmNFA->regex, key->nstate, arcs, arcsCount);
|
pg_reg_getoutarcs(trgmNFA->regex, key->nstate, arcs, arcsCount);
|
||||||
|
|
||||||
for (i = 0; i < arcsCount; i++)
|
for (i = 0; i < arcsCount; i++)
|
||||||
@@ -1177,7 +1176,7 @@ addKey(TrgmNFA *trgmNFA, TrgmState *state, TrgmStateKey *key)
|
|||||||
static void
|
static void
|
||||||
addKeyToQueue(TrgmNFA *trgmNFA, TrgmStateKey *key)
|
addKeyToQueue(TrgmNFA *trgmNFA, TrgmStateKey *key)
|
||||||
{
|
{
|
||||||
TrgmStateKey *keyCopy = (TrgmStateKey *) palloc(sizeof(TrgmStateKey));
|
TrgmStateKey *keyCopy = palloc_object(TrgmStateKey);
|
||||||
|
|
||||||
memcpy(keyCopy, key, sizeof(TrgmStateKey));
|
memcpy(keyCopy, key, sizeof(TrgmStateKey));
|
||||||
trgmNFA->keysQueue = lappend(trgmNFA->keysQueue, keyCopy);
|
trgmNFA->keysQueue = lappend(trgmNFA->keysQueue, keyCopy);
|
||||||
@@ -1215,7 +1214,7 @@ addArcs(TrgmNFA *trgmNFA, TrgmState *state)
|
|||||||
TrgmStateKey *key = (TrgmStateKey *) lfirst(cell);
|
TrgmStateKey *key = (TrgmStateKey *) lfirst(cell);
|
||||||
|
|
||||||
arcsCount = pg_reg_getnumoutarcs(trgmNFA->regex, key->nstate);
|
arcsCount = pg_reg_getnumoutarcs(trgmNFA->regex, key->nstate);
|
||||||
arcs = (regex_arc_t *) palloc(sizeof(regex_arc_t) * arcsCount);
|
arcs = palloc_array(regex_arc_t, arcsCount);
|
||||||
pg_reg_getoutarcs(trgmNFA->regex, key->nstate, arcs, arcsCount);
|
pg_reg_getoutarcs(trgmNFA->regex, key->nstate, arcs, arcsCount);
|
||||||
|
|
||||||
for (i = 0; i < arcsCount; i++)
|
for (i = 0; i < arcsCount; i++)
|
||||||
@@ -1311,7 +1310,7 @@ addArc(TrgmNFA *trgmNFA, TrgmState *state, TrgmStateKey *key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Checks were successful, add new arc */
|
/* Checks were successful, add new arc */
|
||||||
arc = (TrgmArc *) palloc(sizeof(TrgmArc));
|
arc = palloc_object(TrgmArc);
|
||||||
arc->target = getState(trgmNFA, destKey);
|
arc->target = getState(trgmNFA, destKey);
|
||||||
arc->ctrgm.colors[0] = key->prefix.colors[0];
|
arc->ctrgm.colors[0] = key->prefix.colors[0];
|
||||||
arc->ctrgm.colors[1] = key->prefix.colors[1];
|
arc->ctrgm.colors[1] = key->prefix.colors[1];
|
||||||
@@ -1467,7 +1466,7 @@ selectColorTrigrams(TrgmNFA *trgmNFA)
|
|||||||
int cnumber;
|
int cnumber;
|
||||||
|
|
||||||
/* Collect color trigrams from all arcs */
|
/* Collect color trigrams from all arcs */
|
||||||
colorTrgms = (ColorTrgmInfo *) palloc0(sizeof(ColorTrgmInfo) * arcsCount);
|
colorTrgms = palloc0_array(ColorTrgmInfo, arcsCount);
|
||||||
trgmNFA->colorTrgms = colorTrgms;
|
trgmNFA->colorTrgms = colorTrgms;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
@@ -1479,7 +1478,7 @@ selectColorTrigrams(TrgmNFA *trgmNFA)
|
|||||||
foreach(cell, state->arcs)
|
foreach(cell, state->arcs)
|
||||||
{
|
{
|
||||||
TrgmArc *arc = (TrgmArc *) lfirst(cell);
|
TrgmArc *arc = (TrgmArc *) lfirst(cell);
|
||||||
TrgmArcInfo *arcInfo = (TrgmArcInfo *) palloc(sizeof(TrgmArcInfo));
|
TrgmArcInfo *arcInfo = palloc_object(TrgmArcInfo);
|
||||||
ColorTrgmInfo *trgmInfo = &colorTrgms[i];
|
ColorTrgmInfo *trgmInfo = &colorTrgms[i];
|
||||||
|
|
||||||
arcInfo->source = state;
|
arcInfo->source = state;
|
||||||
@@ -1964,8 +1963,7 @@ packGraph(TrgmNFA *trgmNFA, MemoryContext rcontext)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Collect array of all arcs */
|
/* Collect array of all arcs */
|
||||||
arcs = (TrgmPackArcInfo *)
|
arcs = palloc_array(TrgmPackArcInfo, trgmNFA->arcsCount);
|
||||||
palloc(sizeof(TrgmPackArcInfo) * trgmNFA->arcsCount);
|
|
||||||
arcIndex = 0;
|
arcIndex = 0;
|
||||||
hash_seq_init(&scan_status, trgmNFA->states);
|
hash_seq_init(&scan_status, trgmNFA->states);
|
||||||
while ((state = (TrgmState *) hash_seq_search(&scan_status)) != NULL)
|
while ((state = (TrgmState *) hash_seq_search(&scan_status)) != NULL)
|
||||||
@@ -2147,7 +2145,7 @@ printSourceNFA(regex_t *regex, TrgmColorInfo *colors, int ncolors)
|
|||||||
appendStringInfoString(&buf, ";\n");
|
appendStringInfoString(&buf, ";\n");
|
||||||
|
|
||||||
arcsCount = pg_reg_getnumoutarcs(regex, state);
|
arcsCount = pg_reg_getnumoutarcs(regex, state);
|
||||||
arcs = (regex_arc_t *) palloc(sizeof(regex_arc_t) * arcsCount);
|
arcs = palloc_array(regex_arc_t, arcsCount);
|
||||||
pg_reg_getoutarcs(regex, state, arcs, arcsCount);
|
pg_reg_getoutarcs(regex, state, arcs, arcsCount);
|
||||||
|
|
||||||
for (i = 0; i < arcsCount; i++)
|
for (i = 0; i < arcsCount; i++)
|
||||||
|
|||||||
@@ -741,7 +741,7 @@ collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen)
|
|||||||
* number of entries allocated. We'll repurpose these fields before
|
* number of entries allocated. We'll repurpose these fields before
|
||||||
* returning.
|
* returning.
|
||||||
*/
|
*/
|
||||||
items = palloc0(sizeof(corrupt_items));
|
items = palloc0_object(corrupt_items);
|
||||||
items->next = 0;
|
items->next = 0;
|
||||||
items->count = 64;
|
items->count = 64;
|
||||||
items->tids = palloc(items->count * sizeof(ItemPointerData));
|
items->tids = palloc(items->count * sizeof(ItemPointerData));
|
||||||
|
|||||||
@@ -109,8 +109,7 @@ InitXLogReaderState(XLogRecPtr lsn)
|
|||||||
errmsg("could not read WAL at LSN %X/%08X",
|
errmsg("could not read WAL at LSN %X/%08X",
|
||||||
LSN_FORMAT_ARGS(lsn))));
|
LSN_FORMAT_ARGS(lsn))));
|
||||||
|
|
||||||
private_data = (ReadLocalXLogPageNoWaitPrivate *)
|
private_data = palloc0_object(ReadLocalXLogPageNoWaitPrivate);
|
||||||
palloc0(sizeof(ReadLocalXLogPageNoWaitPrivate));
|
|
||||||
|
|
||||||
xlogreader = XLogReaderAllocate(wal_segment_size, NULL,
|
xlogreader = XLogReaderAllocate(wal_segment_size, NULL,
|
||||||
XL_ROUTINE(.page_read = &read_local_xlog_page_no_wait,
|
XL_ROUTINE(.page_read = &read_local_xlog_page_no_wait,
|
||||||
@@ -310,7 +309,7 @@ GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record,
|
|||||||
/* Construct and save block_fpi_info */
|
/* Construct and save block_fpi_info */
|
||||||
bitcnt = pg_popcount((const char *) &blk->bimg_info,
|
bitcnt = pg_popcount((const char *) &blk->bimg_info,
|
||||||
sizeof(uint8));
|
sizeof(uint8));
|
||||||
flags = (Datum *) palloc0(sizeof(Datum) * bitcnt);
|
flags = palloc0_array(Datum, bitcnt);
|
||||||
if ((blk->bimg_info & BKPIMAGE_HAS_HOLE) != 0)
|
if ((blk->bimg_info & BKPIMAGE_HAS_HOLE) != 0)
|
||||||
flags[cnt++] = CStringGetTextDatum("HAS_HOLE");
|
flags[cnt++] = CStringGetTextDatum("HAS_HOLE");
|
||||||
if (blk->apply_image)
|
if (blk->apply_image)
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ mbuf_create(int len)
|
|||||||
if (!len)
|
if (!len)
|
||||||
len = 8192;
|
len = 8192;
|
||||||
|
|
||||||
mbuf = palloc(sizeof *mbuf);
|
mbuf = palloc_object(MBuf);
|
||||||
mbuf->data = palloc(len);
|
mbuf->data = palloc(len);
|
||||||
mbuf->buf_end = mbuf->data + len;
|
mbuf->buf_end = mbuf->data + len;
|
||||||
mbuf->data_end = mbuf->data;
|
mbuf->data_end = mbuf->data;
|
||||||
@@ -132,7 +132,7 @@ mbuf_create_from_data(uint8 *data, int len)
|
|||||||
{
|
{
|
||||||
MBuf *mbuf;
|
MBuf *mbuf;
|
||||||
|
|
||||||
mbuf = palloc(sizeof *mbuf);
|
mbuf = palloc_object(MBuf);
|
||||||
mbuf->data = data;
|
mbuf->data = data;
|
||||||
mbuf->buf_end = mbuf->data + len;
|
mbuf->buf_end = mbuf->data + len;
|
||||||
mbuf->data_end = mbuf->data + len;
|
mbuf->data_end = mbuf->data + len;
|
||||||
@@ -206,7 +206,7 @@ pullf_create(PullFilter **pf_p, const PullFilterOps *op, void *init_arg, PullFil
|
|||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pf = palloc0(sizeof(*pf));
|
pf = palloc0_object(PullFilter);
|
||||||
pf->buflen = res;
|
pf->buflen = res;
|
||||||
pf->op = op;
|
pf->op = op;
|
||||||
pf->priv = priv;
|
pf->priv = priv;
|
||||||
@@ -372,7 +372,7 @@ pushf_create(PushFilter **mp_p, const PushFilterOps *op, void *init_arg, PushFil
|
|||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp = palloc0(sizeof(*mp));
|
mp = palloc0_object(PushFilter);
|
||||||
mp->block_size = res;
|
mp->block_size = res;
|
||||||
mp->op = op;
|
mp->op = op;
|
||||||
mp->priv = priv;
|
mp->priv = priv;
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ px_find_digest(const char *name, PX_MD **res)
|
|||||||
ResourceOwnerRememberOSSLDigest(digest->owner, digest);
|
ResourceOwnerRememberOSSLDigest(digest->owner, digest);
|
||||||
|
|
||||||
/* The PX_MD object is allocated in the current memory context. */
|
/* The PX_MD object is allocated in the current memory context. */
|
||||||
h = palloc(sizeof(*h));
|
h = palloc_object(PX_MD);
|
||||||
h->result_size = digest_result_size;
|
h->result_size = digest_result_size;
|
||||||
h->block_size = digest_block_size;
|
h->block_size = digest_block_size;
|
||||||
h->reset = digest_reset;
|
h->reset = digest_reset;
|
||||||
@@ -813,7 +813,7 @@ px_find_cipher(const char *name, PX_Cipher **res)
|
|||||||
od->evp_ciph = i->ciph->cipher_func();
|
od->evp_ciph = i->ciph->cipher_func();
|
||||||
|
|
||||||
/* The PX_Cipher is allocated in current memory context */
|
/* The PX_Cipher is allocated in current memory context */
|
||||||
c = palloc(sizeof(*c));
|
c = palloc_object(PX_Cipher);
|
||||||
c->block_size = gen_ossl_block_size;
|
c->block_size = gen_ossl_block_size;
|
||||||
c->key_size = gen_ossl_key_size;
|
c->key_size = gen_ossl_key_size;
|
||||||
c->iv_size = gen_ossl_iv_size;
|
c->iv_size = gen_ossl_iv_size;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ pgp_cfb_create(PGP_CFB **ctx_p, int algo, const uint8 *key, int key_len,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = palloc0(sizeof(*ctx));
|
ctx = palloc0_object(PGP_CFB);
|
||||||
ctx->ciph = ciph;
|
ctx->ciph = ciph;
|
||||||
ctx->block_size = px_cipher_block_size(ciph);
|
ctx->block_size = px_cipher_block_size(ciph);
|
||||||
ctx->resync = resync;
|
ctx->resync = resync;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ compress_init(PushFilter *next, void *init_arg, void **priv_p)
|
|||||||
/*
|
/*
|
||||||
* init
|
* init
|
||||||
*/
|
*/
|
||||||
st = palloc0(sizeof(*st));
|
st = palloc0_object(struct ZipStat);
|
||||||
st->buf_len = ZIP_OUT_BUF;
|
st->buf_len = ZIP_OUT_BUF;
|
||||||
st->stream.zalloc = z_alloc;
|
st->stream.zalloc = z_alloc;
|
||||||
st->stream.zfree = z_free;
|
st->stream.zfree = z_free;
|
||||||
@@ -211,7 +211,7 @@ decompress_init(void **priv_p, void *arg, PullFilter *src)
|
|||||||
&& ctx->compress_algo != PGP_COMPR_ZIP)
|
&& ctx->compress_algo != PGP_COMPR_ZIP)
|
||||||
return PXE_PGP_UNSUPPORTED_COMPR;
|
return PXE_PGP_UNSUPPORTED_COMPR;
|
||||||
|
|
||||||
dec = palloc0(sizeof(*dec));
|
dec = palloc0_object(struct DecomprData);
|
||||||
dec->buf_len = ZIP_OUT_BUF;
|
dec->buf_len = ZIP_OUT_BUF;
|
||||||
*priv_p = dec;
|
*priv_p = dec;
|
||||||
|
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ pgp_create_pkt_reader(PullFilter **pf_p, PullFilter *src, int len,
|
|||||||
int pkttype, PGP_Context *ctx)
|
int pkttype, PGP_Context *ctx)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct PktData *pkt = palloc(sizeof(*pkt));
|
struct PktData *pkt = palloc_object(struct PktData);
|
||||||
|
|
||||||
pkt->type = pkttype;
|
pkt->type = pkttype;
|
||||||
pkt->len = len;
|
pkt->len = len;
|
||||||
@@ -448,7 +448,7 @@ mdcbuf_init(void **priv_p, void *arg, PullFilter *src)
|
|||||||
PGP_Context *ctx = arg;
|
PGP_Context *ctx = arg;
|
||||||
struct MDCBufData *st;
|
struct MDCBufData *st;
|
||||||
|
|
||||||
st = palloc0(sizeof(*st));
|
st = palloc0_object(struct MDCBufData);
|
||||||
st->buflen = sizeof(st->buf);
|
st->buflen = sizeof(st->buf);
|
||||||
st->ctx = ctx;
|
st->ctx = ctx;
|
||||||
*priv_p = st;
|
*priv_p = st;
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ encrypt_init(PushFilter *next, void *init_arg, void **priv_p)
|
|||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
st = palloc0(sizeof(*st));
|
st = palloc0_object(struct EncStat);
|
||||||
st->ciph = ciph;
|
st->ciph = ciph;
|
||||||
|
|
||||||
*priv_p = st;
|
*priv_p = st;
|
||||||
@@ -240,7 +240,7 @@ pkt_stream_init(PushFilter *next, void *init_arg, void **priv_p)
|
|||||||
{
|
{
|
||||||
struct PktStreamStat *st;
|
struct PktStreamStat *st;
|
||||||
|
|
||||||
st = palloc(sizeof(*st));
|
st = palloc_object(struct PktStreamStat);
|
||||||
st->final_done = 0;
|
st->final_done = 0;
|
||||||
st->pkt_block = 1 << STREAM_BLOCK_SHIFT;
|
st->pkt_block = 1 << STREAM_BLOCK_SHIFT;
|
||||||
*priv_p = st;
|
*priv_p = st;
|
||||||
|
|||||||
@@ -782,8 +782,8 @@ parse_key_value_arrays(ArrayType *key_array, ArrayType *val_array,
|
|||||||
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
|
||||||
errmsg("mismatched array dimensions")));
|
errmsg("mismatched array dimensions")));
|
||||||
|
|
||||||
keys = (char **) palloc(sizeof(char *) * key_count);
|
keys = palloc_array(char *, key_count);
|
||||||
values = (char **) palloc(sizeof(char *) * val_count);
|
values = palloc_array(char *, val_count);
|
||||||
|
|
||||||
for (i = 0; i < key_count; i++)
|
for (i = 0; i < key_count; i++)
|
||||||
{
|
{
|
||||||
@@ -937,7 +937,7 @@ pgp_armor_headers(PG_FUNCTION_ARGS)
|
|||||||
attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
attinmeta = TupleDescGetAttInMetadata(tupdesc);
|
||||||
funcctx->attinmeta = attinmeta;
|
funcctx->attinmeta = attinmeta;
|
||||||
|
|
||||||
state = (pgp_armor_headers_state *) palloc(sizeof(pgp_armor_headers_state));
|
state = palloc_object(pgp_armor_headers_state);
|
||||||
|
|
||||||
res = pgp_extract_armor_headers((uint8 *) VARDATA_ANY(data),
|
res = pgp_extract_armor_headers((uint8 *) VARDATA_ANY(data),
|
||||||
VARSIZE_ANY_EXHDR(data),
|
VARSIZE_ANY_EXHDR(data),
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ pgp_key_alloc(PGP_PubKey **pk_p)
|
|||||||
{
|
{
|
||||||
PGP_PubKey *pk;
|
PGP_PubKey *pk;
|
||||||
|
|
||||||
pk = palloc0(sizeof(*pk));
|
pk = palloc0_object(PGP_PubKey);
|
||||||
*pk_p = pk;
|
*pk_p = pk;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ px_find_hmac(const char *name, PX_HMAC **res)
|
|||||||
return PXE_HASH_UNUSABLE_FOR_HMAC;
|
return PXE_HASH_UNUSABLE_FOR_HMAC;
|
||||||
}
|
}
|
||||||
|
|
||||||
h = palloc(sizeof(*h));
|
h = palloc_object(PX_HMAC);
|
||||||
h->p.ipad = palloc(bs);
|
h->p.ipad = palloc(bs);
|
||||||
h->p.opad = palloc(bs);
|
h->p.opad = palloc(bs);
|
||||||
h->md = md;
|
h->md = md;
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ px_find_combo(const char *name, PX_Combo **res)
|
|||||||
|
|
||||||
PX_Combo *cx;
|
PX_Combo *cx;
|
||||||
|
|
||||||
cx = palloc0(sizeof(*cx));
|
cx = palloc0_object(PX_Combo);
|
||||||
buf = pstrdup(name);
|
buf = pstrdup(name);
|
||||||
|
|
||||||
err = parse_cipher_name(buf, &s_cipher, &s_pad);
|
err = parse_cipher_name(buf, &s_cipher, &s_pad);
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ Datum
|
|||||||
seg_in(PG_FUNCTION_ARGS)
|
seg_in(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
char *str = PG_GETARG_CSTRING(0);
|
char *str = PG_GETARG_CSTRING(0);
|
||||||
SEG *result = palloc(sizeof(SEG));
|
SEG *result = palloc_object(SEG);
|
||||||
yyscan_t scanner;
|
yyscan_t scanner;
|
||||||
|
|
||||||
seg_scanner_init(str, &scanner);
|
seg_scanner_init(str, &scanner);
|
||||||
@@ -370,7 +370,7 @@ gseg_picksplit(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* Emit segments to the left output page, and compute its bounding box.
|
* Emit segments to the left output page, and compute its bounding box.
|
||||||
*/
|
*/
|
||||||
seg_l = (SEG *) palloc(sizeof(SEG));
|
seg_l = palloc_object(SEG);
|
||||||
memcpy(seg_l, sort_items[0].data, sizeof(SEG));
|
memcpy(seg_l, sort_items[0].data, sizeof(SEG));
|
||||||
*left++ = sort_items[0].index;
|
*left++ = sort_items[0].index;
|
||||||
v->spl_nleft++;
|
v->spl_nleft++;
|
||||||
@@ -388,7 +388,7 @@ gseg_picksplit(PG_FUNCTION_ARGS)
|
|||||||
/*
|
/*
|
||||||
* Likewise for the right page.
|
* Likewise for the right page.
|
||||||
*/
|
*/
|
||||||
seg_r = (SEG *) palloc(sizeof(SEG));
|
seg_r = palloc_object(SEG);
|
||||||
memcpy(seg_r, sort_items[firstright].data, sizeof(SEG));
|
memcpy(seg_r, sort_items[firstright].data, sizeof(SEG));
|
||||||
*right++ = sort_items[firstright].index;
|
*right++ = sort_items[firstright].index;
|
||||||
v->spl_nright++;
|
v->spl_nright++;
|
||||||
@@ -632,7 +632,7 @@ seg_union(PG_FUNCTION_ARGS)
|
|||||||
SEG *b = PG_GETARG_SEG_P(1);
|
SEG *b = PG_GETARG_SEG_P(1);
|
||||||
SEG *n;
|
SEG *n;
|
||||||
|
|
||||||
n = (SEG *) palloc(sizeof(*n));
|
n = palloc_object(SEG);
|
||||||
|
|
||||||
/* take max of upper endpoints */
|
/* take max of upper endpoints */
|
||||||
if (a->upper > b->upper)
|
if (a->upper > b->upper)
|
||||||
@@ -672,7 +672,7 @@ seg_inter(PG_FUNCTION_ARGS)
|
|||||||
SEG *b = PG_GETARG_SEG_P(1);
|
SEG *b = PG_GETARG_SEG_P(1);
|
||||||
SEG *n;
|
SEG *n;
|
||||||
|
|
||||||
n = (SEG *) palloc(sizeof(*n));
|
n = palloc_object(SEG);
|
||||||
|
|
||||||
/* take min of upper endpoints */
|
/* take min of upper endpoints */
|
||||||
if (a->upper < b->upper)
|
if (a->upper < b->upper)
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ sepgsql_set_client_label(const char *new_label)
|
|||||||
*/
|
*/
|
||||||
oldcxt = MemoryContextSwitchTo(CurTransactionContext);
|
oldcxt = MemoryContextSwitchTo(CurTransactionContext);
|
||||||
|
|
||||||
plabel = palloc0(sizeof(pending_label));
|
plabel = palloc0_object(pending_label);
|
||||||
plabel->subid = GetCurrentSubTransactionId();
|
plabel->subid = GetCurrentSubTransactionId();
|
||||||
if (new_label)
|
if (new_label)
|
||||||
plabel->label = pstrdup(new_label);
|
plabel->label = pstrdup(new_label);
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ sepgsql_avc_compute(const char *scontext, const char *tcontext, uint16 tclass)
|
|||||||
*/
|
*/
|
||||||
oldctx = MemoryContextSwitchTo(avc_mem_cxt);
|
oldctx = MemoryContextSwitchTo(avc_mem_cxt);
|
||||||
|
|
||||||
cache = palloc0(sizeof(avc_cache));
|
cache = palloc0_object(avc_cache);
|
||||||
|
|
||||||
cache->hash = hash;
|
cache->hash = hash;
|
||||||
cache->scontext = pstrdup(scontext);
|
cache->scontext = pstrdup(scontext);
|
||||||
|
|||||||
@@ -651,7 +651,7 @@ find_plan(char *ident, EPlan **eplan, int *nplans)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newp = *eplan = (EPlan *) palloc(sizeof(EPlan));
|
newp = *eplan = palloc_object(EPlan);
|
||||||
(*nplans) = i = 0;
|
(*nplans) = i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ ssl_extension_info(PG_FUNCTION_ARGS)
|
|||||||
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
|
||||||
|
|
||||||
/* Create a user function context for cross-call persistence */
|
/* Create a user function context for cross-call persistence */
|
||||||
fctx = (SSLExtensionInfoContext *) palloc(sizeof(SSLExtensionInfoContext));
|
fctx = palloc_object(SSLExtensionInfoContext);
|
||||||
|
|
||||||
/* Construct tuple descriptor */
|
/* Construct tuple descriptor */
|
||||||
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ normal_rand(PG_FUNCTION_ARGS)
|
|||||||
funcctx->max_calls = num_tuples;
|
funcctx->max_calls = num_tuples;
|
||||||
|
|
||||||
/* allocate memory for user context */
|
/* allocate memory for user context */
|
||||||
fctx = (normal_rand_fctx *) palloc(sizeof(normal_rand_fctx));
|
fctx = palloc_object(normal_rand_fctx);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use fctx to keep track of upper and lower bounds from call to call.
|
* Use fctx to keep track of upper and lower bounds from call to call.
|
||||||
@@ -766,7 +766,7 @@ load_categories_hash(char *cats_sql, MemoryContext per_query_ctx)
|
|||||||
|
|
||||||
SPIcontext = MemoryContextSwitchTo(per_query_ctx);
|
SPIcontext = MemoryContextSwitchTo(per_query_ctx);
|
||||||
|
|
||||||
catdesc = (crosstab_cat_desc *) palloc(sizeof(crosstab_cat_desc));
|
catdesc = palloc_object(crosstab_cat_desc);
|
||||||
catdesc->catname = catname;
|
catdesc->catname = catname;
|
||||||
catdesc->attidx = i;
|
catdesc->attidx = i;
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
|
|||||||
TestDecodingData *data;
|
TestDecodingData *data;
|
||||||
bool enable_streaming = false;
|
bool enable_streaming = false;
|
||||||
|
|
||||||
data = palloc0(sizeof(TestDecodingData));
|
data = palloc0_object(TestDecodingData);
|
||||||
data->context = AllocSetContextCreate(ctx->context,
|
data->context = AllocSetContextCreate(ctx->context,
|
||||||
"text conversion context",
|
"text conversion context",
|
||||||
ALLOCSET_DEFAULT_SIZES);
|
ALLOCSET_DEFAULT_SIZES);
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ system_rows_samplescangetsamplesize(PlannerInfo *root,
|
|||||||
static void
|
static void
|
||||||
system_rows_initsamplescan(SampleScanState *node, int eflags)
|
system_rows_initsamplescan(SampleScanState *node, int eflags)
|
||||||
{
|
{
|
||||||
node->tsm_state = palloc0(sizeof(SystemRowsSamplerData));
|
node->tsm_state = palloc0_object(SystemRowsSamplerData);
|
||||||
/* Note the above leaves tsm_state->step equal to zero */
|
/* Note the above leaves tsm_state->step equal to zero */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ system_time_samplescangetsamplesize(PlannerInfo *root,
|
|||||||
static void
|
static void
|
||||||
system_time_initsamplescan(SampleScanState *node, int eflags)
|
system_time_initsamplescan(SampleScanState *node, int eflags)
|
||||||
{
|
{
|
||||||
node->tsm_state = palloc0(sizeof(SystemTimeSamplerData));
|
node->tsm_state = palloc0_object(SystemTimeSamplerData);
|
||||||
/* Note the above leaves tsm_state->step equal to zero */
|
/* Note the above leaves tsm_state->step equal to zero */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ placeChar(TrieChar *node, const unsigned char *str, int lenstr,
|
|||||||
TrieChar *curnode;
|
TrieChar *curnode;
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
node = (TrieChar *) palloc0(sizeof(TrieChar) * 256);
|
node = palloc0_array(TrieChar, 256);
|
||||||
|
|
||||||
Assert(lenstr > 0); /* else str[0] doesn't exist */
|
Assert(lenstr > 0); /* else str[0] doesn't exist */
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ initTrie(const char *filename)
|
|||||||
if (trgquoted && state > 0)
|
if (trgquoted && state > 0)
|
||||||
{
|
{
|
||||||
/* Ignore first and end quotes */
|
/* Ignore first and end quotes */
|
||||||
trgstore = (char *) palloc(sizeof(char) * (trglen - 2));
|
trgstore = palloc_array(char, trglen - 2);
|
||||||
trgstorelen = 0;
|
trgstorelen = 0;
|
||||||
for (int i = 1; i < trglen - 1; i++)
|
for (int i = 1; i < trglen - 1; i++)
|
||||||
{
|
{
|
||||||
@@ -252,7 +252,7 @@ initTrie(const char *filename)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
trgstore = (char *) palloc(sizeof(char) * trglen);
|
trgstore = palloc_array(char, trglen);
|
||||||
trgstorelen = trglen;
|
trgstorelen = trglen;
|
||||||
memcpy(trgstore, trg, trgstorelen);
|
memcpy(trgstore, trg, trgstorelen);
|
||||||
}
|
}
|
||||||
@@ -421,7 +421,7 @@ unaccent_lexize(PG_FUNCTION_ARGS)
|
|||||||
/* return a result only if we made at least one substitution */
|
/* return a result only if we made at least one substitution */
|
||||||
if (buf.data != NULL)
|
if (buf.data != NULL)
|
||||||
{
|
{
|
||||||
res = (TSLexeme *) palloc0(sizeof(TSLexeme) * 2);
|
res = palloc0_array(TSLexeme, 2);
|
||||||
res->lexeme = buf.data;
|
res->lexeme = buf.data;
|
||||||
res->flags = TSL_FILTER;
|
res->flags = TSL_FILTER;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,8 +485,7 @@ pgxml_xpath(text *document, xmlChar *xpath, PgXmlErrorContext *xmlerrcxt)
|
|||||||
{
|
{
|
||||||
int32 docsize = VARSIZE_ANY_EXHDR(document);
|
int32 docsize = VARSIZE_ANY_EXHDR(document);
|
||||||
xmlXPathCompExprPtr comppath;
|
xmlXPathCompExprPtr comppath;
|
||||||
xpath_workspace *workspace = (xpath_workspace *)
|
xpath_workspace *workspace = palloc0_object(xpath_workspace);
|
||||||
palloc0(sizeof(xpath_workspace));
|
|
||||||
|
|
||||||
workspace->doctree = NULL;
|
workspace->doctree = NULL;
|
||||||
workspace->ctxt = NULL;
|
workspace->ctxt = NULL;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ xslt_process(PG_FUNCTION_ARGS)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* No parameters */
|
/* No parameters */
|
||||||
params = (const char **) palloc(sizeof(char *));
|
params = palloc_object(const char *);
|
||||||
params[0] = NULL;
|
params[0] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user