* repalloc_huge * Adjust the size of a previously allocated chunk, permitting a large * value. The previous allocation need not have been "huge". */
| 1487 | * value. The previous allocation need not have been "huge". |
| 1488 | */ |
| 1489 | void * |
| 1490 | repalloc_huge(void *pointer, Size size) |
| 1491 | { |
| 1492 | MemoryContext context = GetMemoryChunkContext(pointer); |
| 1493 | void *ret; |
| 1494 | |
| 1495 | if (!AllocHugeSizeIsValid(size)) |
| 1496 | elog(ERROR, "invalid memory alloc request size %zu", size); |
| 1497 | |
| 1498 | AssertNotInCriticalSection(context); |
| 1499 | |
| 1500 | /* isReset must be false already */ |
| 1501 | Assert(!context->isReset); |
| 1502 | |
| 1503 | ret = context->methods->realloc(context, pointer, size); |
| 1504 | if (unlikely(ret == NULL)) |
| 1505 | { |
| 1506 | MemoryContextStats(TopMemoryContext); |
| 1507 | ereport(ERROR, |
| 1508 | (errcode(ERRCODE_OUT_OF_MEMORY), |
| 1509 | errmsg("out of memory"), |
| 1510 | errdetail("Failed on request of size %zu in memory context \"%s\".", |
| 1511 | size, context->name))); |
| 1512 | } |
| 1513 | |
| 1514 | VALGRIND_MEMPOOL_CHANGE(context, pointer, ret, size); |
| 1515 | |
| 1516 | return ret; |
| 1517 | } |
| 1518 | |
| 1519 | /* |
| 1520 | * MemoryContextStrdup |
no test coverage detected