| 1328 | } |
| 1329 | |
| 1330 | void * |
| 1331 | palloc0(Size size) |
| 1332 | { |
| 1333 | /* duplicates MemoryContextAllocZero to avoid increased overhead */ |
| 1334 | void *ret; |
| 1335 | MemoryContext context = CurrentMemoryContext; |
| 1336 | |
| 1337 | AssertArg(MemoryContextIsValid(context)); |
| 1338 | AssertNotInCriticalSection(context); |
| 1339 | |
| 1340 | if (!AllocSizeIsValid(size)) |
| 1341 | elog(ERROR, "invalid memory alloc request size %zu", size); |
| 1342 | |
| 1343 | context->isReset = false; |
| 1344 | |
| 1345 | ret = context->methods->alloc(context, size); |
| 1346 | if (unlikely(ret == NULL)) |
| 1347 | { |
| 1348 | MemoryContextStats(TopMemoryContext); |
| 1349 | ereport(ERROR, |
| 1350 | (errcode(ERRCODE_OUT_OF_MEMORY), |
| 1351 | errmsg("out of memory"), |
| 1352 | errdetail("Failed on request of size %zu in memory context \"%s\".", |
| 1353 | size, context->name))); |
| 1354 | } |
| 1355 | |
| 1356 | VALGRIND_MEMPOOL_ALLOC(context, ret, size); |
| 1357 | |
| 1358 | MemSetAligned(ret, 0, size); |
| 1359 | |
| 1360 | return ret; |
| 1361 | } |
| 1362 | |
| 1363 | void * |
| 1364 | palloc_extended(Size size, int flags) |