示例#1
0
rpmioPool rpmioFreePool(rpmioPool pool)
	/*@globals _rpmioPool @*/
	/*@modifies _rpmioPool @*/
{
    if (pool == NULL) {
	pool = _rpmioPool;
	_rpmioPool = NULL;
    }
    if (pool != NULL) {
	rpmioItem item;
	int count = 0;
	yarnPossess(pool->have);
VALGRIND_HG_CLEAN_MEMORY(pool, sizeof(*pool));
	while ((item = pool->head) != NULL) {
VALGRIND_HG_CLEAN_MEMORY(item, pool->size);
	    pool->head = (rpmioItem) item->pool;	/* XXX pool == next */
	    if (item->use != NULL)
		item->use = yarnFreeLock(item->use);
	    item = _free(item);
	    count++;
	}
	yarnRelease(pool->have);
	pool->have = yarnFreeLock(pool->have);
	rpmlog(RPMLOG_DEBUG, D_("pool %s:\treused %d, alloc'd %d, free'd %d items.\n"), pool->name, pool->reused, pool->made, count);
#ifdef	NOTYET
assert(pool->made == count);
#else
if (pool->made != count)
rpmlog(RPMLOG_WARNING, D_("pool %s: FIXME: made %d, count %d\nNote: This is a harmless memory leak discovered while exiting, relax ...\n"), pool->name, pool->made, count);
#endif
	(void) _free(pool);
	VALGRIND_DESTROY_MEMPOOL(pool);
    }
    return NULL;
}
示例#2
0
/*@null@*/
void * rpmioFreePoolItem(/*@killref@*/ /*@null@*/ rpmioItem item,
                const char * msg, const char * fn, unsigned ln)
        /*@modifies item @*/
{
    rpmioPool pool;
    if (item == NULL) return NULL;

#ifdef	NOTYET
assert(item->pool != NULL);	/* XXX (*pool->fini) is likely necessary */
#endif
    yarnPossess(item->use);
ANNOTATE_HAPPENS_AFTER(item);
    if ((pool = (rpmioPool) item->pool) != NULL && pool->flags && msg != NULL) {
	const char * imsg = (pool->dbg ? (*pool->dbg)((void *)item) : "");
/*@-modfilesys@*/
	fprintf(stderr, "--> %s %p -- %ld %s at %s:%u%s\n", pool->name,
			item, yarnPeekLock(item->use), msg, fn, ln, imsg);
/*@=modfilesys@*/
    }
    if (yarnPeekLock(item->use) <= 1L) {
VALGRIND_HG_CLEAN_MEMORY(item, pool->size);
	if (pool != NULL && pool->fini != NULL)
	    (*pool->fini) ((void *)item);
	VALGRIND_MEMPOOL_FREE(pool, item + 1);
	item = rpmioPutPool(item);
    } else
	yarnTwist(item->use, BY, -1);
/*@-retalias@*/	/* XXX returning the deref'd item is used to detect nrefs = 0 */
    return (void *) item;
/*@=retalias@*/
}
示例#3
0
DLL_LOCAL void set_msock_now_msecs()
{
	#ifdef VALGRIND
	VALGRIND_HG_CLEAN_MEMORY(&msock_now_msecs, sizeof(msock_now_msecs));
	#endif

	// make helgrind happy...
	msock_now_msecs = now_msecs();
}
示例#4
0
文件: hash.c 项目: kosmix/ferret
void h_destroy(Hash *self)
{
    if (--(self->ref_cnt) <= 0) {
        h_clear(self);

        /* if a new table was created, be sure to free it */
        if (self->table != self->smalltable) {
            free(self->table);
        }

        mutex_lock(&free_hts_mutex);
        if (num_free_hts < MAX_FREE_HASH_TABLES) {
            VALGRIND_HG_CLEAN_MEMORY(self, sizeof(Hash));
            free_hts[num_free_hts++] = self;
        }
        else {
            free(self);
        }
        mutex_unlock(&free_hts_mutex);
    }
}