这篇教程C++ AllocSizeIsValid函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中AllocSizeIsValid函数的典型用法代码示例。如果您正苦于以下问题:C++ AllocSizeIsValid函数的具体用法?C++ AllocSizeIsValid怎么用?C++ AllocSizeIsValid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了AllocSizeIsValid函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: MemoryContextAllocZeroAligned/* * MemoryContextAllocZeroAligned * MemoryContextAllocZero where length is suitable for MemSetLoop * * This might seem overly specialized, but it's not because newNode() * is so often called with compile-time-constant sizes. */void *MemoryContextAllocZeroAligned(MemoryContext context, Size size){ void *ret; AssertArg(MemoryContextIsValid(context)); AssertNotInCriticalSection(context); if (!AllocSizeIsValid(size)) elog(ERROR, "invalid memory alloc request size %zu", size); context->isReset = false; ret = (*context->methods->alloc) (context, size); if (ret == NULL) { MemoryContextStats(TopMemoryContext); ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"), errdetail("Failed on request of size %zu.", size))); } VALGRIND_MEMPOOL_ALLOC(context, ret, size); MemSetLoop(ret, 0, size); return ret;}
开发者ID:gavioto,项目名称:postgres_cluster,代码行数:36,
示例2: MemoryContextContains/* * MemoryContextContains * Detect whether an allocated chunk of memory belongs to a given * context or not. * * Caution: this test is reliable as long as 'pointer' does point to * a chunk of memory allocated from *some* context. If 'pointer' points * at memory obtained in some other way, there is a small chance of a * false-positive result, since the bits right before it might look like * a valid chunk header by chance. */boolMemoryContextContains(MemoryContext context, void *pointer){ StandardChunkHeader *header; /* * Try to detect bogus pointers handed to us, poorly though we can. * Presumably, a pointer that isn't MAXALIGNED isn't pointing at an * allocated chunk. */ if (pointer == NULL || pointer != (void *) MAXALIGN(pointer)) return false; /* * OK, it's probably safe to look at the chunk header. */ header = (StandardChunkHeader *) ((char *) pointer - STANDARDCHUNKHEADERSIZE); /* * If the context link doesn't match then we certainly have a non-member * chunk. Also check for a reasonable-looking size as extra guard against * being fooled by bogus pointers. */ if (header->context == context && AllocSizeIsValid(header->size)) return true; return false;}
开发者ID:adunstan,项目名称:postgresql-dev,代码行数:39,
示例3: repalloc/* * repalloc * Adjust the size of a previously allocated chunk. */void *repalloc(void *pointer, Size size){ MemoryContext context; void *ret; if (!AllocSizeIsValid(size)) elog(ERROR, "invalid memory alloc request size %zu", size); /* pgpool hack by Muhammad Usama <[email C++ AllocVar函数代码示例 C++ AllocSetContextCreate函数代码示例
|