当前位置: 首页>>代码示例>>C++>>正文


C++ VALGRIND_MAKE_MEM_NOACCESS函数代码示例

本文整理汇总了C++中VALGRIND_MAKE_MEM_NOACCESS函数的典型用法代码示例。如果您正苦于以下问题:C++ VALGRIND_MAKE_MEM_NOACCESS函数的具体用法?C++ VALGRIND_MAKE_MEM_NOACCESS怎么用?C++ VALGRIND_MAKE_MEM_NOACCESS使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了VALGRIND_MAKE_MEM_NOACCESS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dm_pool_free

void dm_pool_free(struct dm_pool *p, void *ptr)
{
	struct chunk *c = p->chunk;

	while (c) {
		if (((char *) c < (char *) ptr) &&
		    ((char *) c->end > (char *) ptr)) {
			c->begin = ptr;
#ifdef VALGRIND_POOL
			VALGRIND_MAKE_MEM_NOACCESS(c->begin, c->end - c->begin);
#endif
			break;
		}

		if (p->spare_chunk)
			_free_chunk(p->spare_chunk);

		c->begin = (char *) (c + 1);
#ifdef VALGRIND_POOL
                VALGRIND_MAKE_MEM_NOACCESS(c->begin, c->end - c->begin);
#endif

		p->spare_chunk = c;
		c = c->prev;
	}

	if (!c)
		log_error(INTERNAL_ERROR "pool_free asked to free pointer "
			  "not in pool");
	else
		p->chunk = c;
}
开发者ID:Jajcus,项目名称:lvm2,代码行数:32,代码来源:pool-fast.c

示例2: stat_dump_mem_leaks

static void stat_dump_mem_leaks(void) {
    stat_mem_block_t *info;
    /* we need access to the root for this */
    VALGRIND_MAKE_MEM_DEFINED(stat_mem_block_root, sizeof(stat_mem_block_t));
    for (info = stat_mem_block_root; info; info = info->next) {
        /* we need access to the block */
        VALGRIND_MAKE_MEM_DEFINED(info, sizeof(stat_mem_block_t));
        con_out("lost: %u (bytes) at %s:%u from expression `%s`\n",
            info->size,
            info->file,
            info->line,
            info->expr
        );

        stat_dump_mem_contents(info, OPTS_OPTION_U16(OPTION_MEMDUMPCOLS));

        /*
         * we're finished with the access, the redzone should be marked
         * inaccesible so that invalid read/writes that could 'step-into'
         * those redzones will show up as invalid read/writes in valgrind.
         */
        VALGRIND_MAKE_MEM_NOACCESS(info, sizeof(stat_mem_block_t));
    }
    VALGRIND_MAKE_MEM_NOACCESS(stat_mem_block_root, sizeof(stat_mem_block_t));
}
开发者ID:CurrentResident,项目名称:gmqcc,代码行数:25,代码来源:stat.c

示例3: Assert

void ContextMemoryManager::newChunk() {

  // Increment index to chunk list
  ++d_indexChunkList;
  Assert(d_chunkList.size() == d_indexChunkList,
         "Index should be at the end of the list");

  // Create new chunk if no free chunk available
  if(d_freeChunks.empty()) {
    d_chunkList.push_back((char*)malloc(chunkSizeBytes));
    if(d_chunkList.back() == NULL) {
      throw std::bad_alloc();
    }

#ifdef CVC4_VALGRIND
    VALGRIND_MAKE_MEM_NOACCESS(d_chunkList.back(), chunkSizeBytes);
#endif /* CVC4_VALGRIND */
  }
  // If there is a free chunk, use that
  else {
    d_chunkList.push_back(d_freeChunks.back());
    d_freeChunks.pop_back();
  }
  // Set up the current chunk pointers
  d_nextFree = d_chunkList.back();
  d_endChunk = d_nextFree + chunkSizeBytes;
}
开发者ID:4tXJ7f,项目名称:CVC4,代码行数:27,代码来源:context_mm.cpp

示例4: sec_allocated

static size_t
sec_allocated (Block *block, void *memory)
{
	Cell *cell;
	word_t *word;

	ASSERT (block);
	ASSERT (memory);

	word = memory;
	--word;

#ifdef WITH_VALGRIND
	VALGRIND_MAKE_MEM_DEFINED (word, sizeof (word_t));
#endif

	/* Lookup the meta for this memory block (using guard pointer) */
	ASSERT (sec_is_valid_word (block, word));
	ASSERT (pool_valid (*word));
	cell = *word;

	sec_check_guards (cell);
	ASSERT (cell->next == NULL);
	ASSERT (cell->prev == NULL);
	ASSERT (cell->allocated > 0);

#ifdef WITH_VALGRIND
	VALGRIND_MAKE_MEM_NOACCESS (word, sizeof (word_t));
#endif

	return cell->allocated;
}
开发者ID:dmashal,项目名称:libmatekeyring,代码行数:32,代码来源:egg-secure-memory.c

示例5: memcpy

/*
 * A basic header of information wrapper allocator. Simply stores
 * information as a header, returns the memory + 1 past it, can be
 * retrieved again with - 1. Where type is stat_mem_block_t*.
 */
void *stat_mem_allocate(size_t size, size_t line, const char *file, const char *expr) {
    stat_mem_block_t *info = (stat_mem_block_t*)malloc(size + IDENT_MEM_TOP);
    void             *data = (void *)((char*)info + IDENT_MEM_TOP);

    if(GMQCC_UNLIKELY(!info))
        return NULL;

    info->line = line;
    info->size = size;
    info->file = file;
    info->expr = expr;
    info->prev = NULL;
    info->next = stat_mem_block_root;
    
    /* Write identifier */
    memcpy(info + 1, IDENT_MEM, IDENT_SIZE);

    /* likely since it only happens once */
    if (GMQCC_LIKELY(stat_mem_block_root != NULL)) {
        VALGRIND_MAKE_MEM_DEFINED(stat_mem_block_root, IDENT_MEM_TOP);
        stat_mem_block_root->prev = info;
        VALGRIND_MAKE_MEM_NOACCESS(stat_mem_block_root, IDENT_MEM_TOP);
    }

    stat_mem_block_root       = info;
    stat_mem_allocated       += size;
    stat_mem_high            += size;
    stat_mem_allocated_total ++;

    if (stat_mem_high > stat_mem_peak)
        stat_mem_peak = stat_mem_high;

    VALGRIND_MALLOCLIKE_BLOCK(data, size, IDENT_MEM_TOP, 0);
    return data;
}
开发者ID:CurrentResident,项目名称:gmqcc,代码行数:40,代码来源:stat.c

示例6: _cairo_region_fini

void
_cairo_region_fini (cairo_region_t *region)
{
    assert (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&region->ref_count));
    pixman_region32_fini (&region->rgn);
    VG (VALGRIND_MAKE_MEM_NOACCESS (region, sizeof (cairo_region_t)));
}
开发者ID:Blueprintts,项目名称:npm-pdf2svg,代码行数:7,代码来源:cairo-region.c

示例7: sec_write_guards

static inline void
sec_write_guards (Cell *cell)
{
#ifdef WITH_VALGRIND
	VALGRIND_MAKE_MEM_UNDEFINED (cell->words, sizeof (word_t));
	VALGRIND_MAKE_MEM_UNDEFINED (cell->words + cell->n_words - 1, sizeof (word_t));
#endif

	((void**)cell->words)[0] = (void*)cell;
	((void**)cell->words)[cell->n_words - 1] = (void*)cell;

#ifdef WITH_VALGRIND
	VALGRIND_MAKE_MEM_NOACCESS (cell->words, sizeof (word_t));
	VALGRIND_MAKE_MEM_NOACCESS (cell->words + cell->n_words - 1, sizeof (word_t));
#endif
}
开发者ID:dmashal,项目名称:libmatekeyring,代码行数:16,代码来源:egg-secure-memory.c

示例8: VALGRIND_MEMPOOL_FREE

void ContextMemoryManager::pop() {
#ifdef CVC4_VALGRIND
  for (auto allocation : d_allocations.back())
  {
    VALGRIND_MEMPOOL_FREE(this, allocation);
  }
  d_allocations.pop_back();
#endif /* CVC4_VALGRIND */

  Assert(d_nextFreeStack.size() > 0 && d_endChunkStack.size() > 0);

  // Restore state from stack
  d_nextFree = d_nextFreeStack.back();
  d_nextFreeStack.pop_back();
  d_endChunk = d_endChunkStack.back();
  d_endChunkStack.pop_back();

  // Free all the new chunks since the last push
  while(d_indexChunkList > d_indexChunkListStack.back()) {
    d_freeChunks.push_back(d_chunkList.back());
#ifdef CVC4_VALGRIND
    VALGRIND_MAKE_MEM_NOACCESS(d_chunkList.back(), chunkSizeBytes);
#endif /* CVC4_VALGRIND */
    d_chunkList.pop_back();
    --d_indexChunkList;
  }
  d_indexChunkListStack.pop_back();

  // Delete excess free chunks
  while(d_freeChunks.size() > maxFreeChunks) {
    free(d_freeChunks.front());
    d_freeChunks.pop_front();
  }
}
开发者ID:4tXJ7f,项目名称:CVC4,代码行数:34,代码来源:context_mm.cpp

示例9: _cairo_freepool_alloc_from_new_pool

void *
_cairo_freepool_alloc_from_new_pool (cairo_freepool_t *freepool)
{
    cairo_freelist_pool_t *pool;
    int poolsize;

    if (freepool->pools != &freepool->embedded_pool)
        poolsize = 2 * freepool->pools->size;
    else
        poolsize = (128 * freepool->nodesize + 8191) & -8192;
    pool = malloc (sizeof (cairo_freelist_pool_t) + poolsize);
    if (unlikely (pool == NULL))
        return pool;

    pool->next = freepool->pools;
    freepool->pools = pool;

    pool->size = poolsize;
    pool->rem = poolsize - freepool->nodesize;
    pool->data = (uint8_t *) (pool + 1) + freepool->nodesize;

    VG (VALGRIND_MAKE_MEM_NOACCESS (pool->data, poolsize));
    VG (VALGRIND_MAKE_MEM_UNDEFINED (pool->data, freepool->nodesize));

    return pool + 1;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:26,代码来源:cairo-freelist.c

示例10: sec_neighbor_after

static Cell*
sec_neighbor_after (Block *block, Cell *cell)
{
	word_t *word;

	ASSERT (cell);
	ASSERT (block);

	word = cell->words + cell->n_words;
	if (!sec_is_valid_word (block, word))
		return NULL;

#ifdef WITH_VALGRIND
	VALGRIND_MAKE_MEM_DEFINED (word, sizeof (word_t));
#endif

	cell = *word;
	sec_check_guards (cell);

#ifdef WITH_VALGRIND
	VALGRIND_MAKE_MEM_NOACCESS (word, sizeof (word_t));
#endif

	return cell;
}
开发者ID:dmashal,项目名称:libmatekeyring,代码行数:25,代码来源:egg-secure-memory.c

示例11: sec_check_guards

static inline void
sec_check_guards (Cell *cell)
{
#ifdef WITH_VALGRIND
	VALGRIND_MAKE_MEM_DEFINED (cell->words, sizeof (word_t));
	VALGRIND_MAKE_MEM_DEFINED (cell->words + cell->n_words - 1, sizeof (word_t));
#endif

	ASSERT(((void**)cell->words)[0] == (void*)cell);
	ASSERT(((void**)cell->words)[cell->n_words - 1] == (void*)cell);

#ifdef WITH_VALGRIND
	VALGRIND_MAKE_MEM_NOACCESS (cell->words, sizeof (word_t));
	VALGRIND_MAKE_MEM_NOACCESS (cell->words + cell->n_words - 1, sizeof (word_t));
#endif
}
开发者ID:dmashal,项目名称:libmatekeyring,代码行数:16,代码来源:egg-secure-memory.c

示例12: VALGRIND_MAKE_MEM_DEFINED

/*
 * A basic header of information wrapper allocator. Simply stores
 * information as a header, returns the memory + 1 past it, can be
 * retrieved again with - 1. Where type is stat_mem_block_t*.
 */
void *stat_mem_allocate(size_t size, size_t line, const char *file) {
    stat_mem_block_t *info = (stat_mem_block_t*)malloc(sizeof(stat_mem_block_t) + size);
    void             *data = (void*)(info + 1);

    if(GMQCC_UNLIKELY(!info))
        return NULL;

    info->line = line;
    info->size = size;
    info->file = file;
    info->prev = NULL;
    info->next = stat_mem_block_root;

    /* likely since it only happens once */
    if (GMQCC_LIKELY(stat_mem_block_root != NULL)) {
        VALGRIND_MAKE_MEM_DEFINED(stat_mem_block_root, sizeof(stat_mem_block_t));
        stat_mem_block_root->prev = info;
        VALGRIND_MAKE_MEM_NOACCESS(stat_mem_block_root, sizeof(stat_mem_block_t));
    }

    stat_mem_block_root       = info;
    stat_mem_allocated       += size;
    stat_mem_high            += size;
    stat_mem_allocated_total ++;

    if (stat_mem_high > stat_mem_peak)
        stat_mem_peak = stat_mem_high;

    VALGRIND_MALLOCLIKE_BLOCK(data, size, sizeof(stat_mem_block_t), 0);
    return data;
}
开发者ID:matthiaskrgr,项目名称:gmqcc,代码行数:36,代码来源:stat.c

示例13: dm_pool_abandon_object

void dm_pool_abandon_object(struct dm_pool *p)
{
#ifdef VALGRIND_POOL
	VALGRIND_MAKE_MEM_NOACCESS(p->chunk, p->object_len);
#endif
	p->object_len = 0;
	p->object_alignment = DEFAULT_ALIGNMENT;
}
开发者ID:Jajcus,项目名称:lvm2,代码行数:8,代码来源:pool-fast.c

示例14: _cairo_polygon_fini

void
_cairo_polygon_fini (cairo_polygon_t *polygon)
{
    if (polygon->edges != polygon->edges_embedded)
	xmemory_free (polygon->edges);

    VG (VALGRIND_MAKE_MEM_NOACCESS (polygon, sizeof (cairo_polygon_t)));
}
开发者ID:mgya,项目名称:xCairo,代码行数:8,代码来源:cairo-polygon.c

示例15: valgrindMakeMemNoaccess

void valgrindMakeMemNoaccess(uintptr_t address, uintptr_t size)
{

#if defined(VALGRIND_REQUEST_LOGS)
    VALGRIND_PRINTF_BACKTRACE("Marking an area as noaccess at 0x%lx of size %lu\n", address, size);
#endif /* defined(VALGRIND_REQUEST_LOGS) */

    VALGRIND_MAKE_MEM_NOACCESS(address, size);
}
开发者ID:LinHu2016,项目名称:omr,代码行数:9,代码来源:MemcheckWrapper.cpp


注:本文中的VALGRIND_MAKE_MEM_NOACCESS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。