Example #1
0
void
dfcountfree(void)
{
	daddrt addr;

	dprint("list...\n");
	addr = fs->super->d.free;
	while(addr != 0){
		if(addr >fs->limit){
			fprint(2, "fscheck: d%#010ullx: free overflow\n", addr);
			break;
		}
		countfree(addr);
		addr = dbgetref(addr);
	}
	/* heading unused part */
	dprint("hdr...\n");
	for(addr = 0; addr < Dblk0addr; addr += Dblksz)
		countfree(addr);
	/* DBref blocks */
	dprint("refs...\n");
	for(addr = Dblk0addr; addr < fs->super->d.eaddr; addr += Dblksz*Nblkgrpsz){
		countfree(addr);	/* even DBref */
		countfree(addr+Dblksz);	/* odd DBref */
	}
}
Example #2
0
int _TreeVerify(void *dbid)
{
  PINO_DATABASE *dblist = (PINO_DATABASE *)dbid;
  NODE     *firstempty = (dblist->tree_info->header->free == -1) ? (NODE *) 0 :
		   (NODE *) ((char *) dblist->tree_info->node + 
			     dblist->tree_info->header->free);
  nodecount = 0;
  maxnodes = dblist->tree_info->header->nodes;
  if (countnodes(dblist->tree_info->node))
  {
    int       allocated = nodecount;
    printf("Node summary:\n");
    printf("  Allocated = %d/%d\n", nodecount, maxnodes);
    if (countfree(firstempty))
    {
      int       free = nodecount - allocated;
      int       other = maxnodes - nodecount;
      printf("  Free      = %d/%d\n", free, maxnodes);
      printf("  Other     = %d/%d\n", other, maxnodes);
    }
  }
  return TreeNORMAL;
}
Example #3
0
void         *
countrealloc (const char *fname, int line, void *ptr, size_t length)
{
	if (ptr != NULL && length == 0)
		countfree (fname, line, ptr);
	if (length == 0)
		return NULL;
	if (ptr != NULL)
	{
		mem          *m = NULL;
		ASHashResult  res ;

		if( allocs_hash != NULL )
		{
			ASHashData hd ;
			service_mode++ ;
			if( remove_hash_item (allocs_hash, AS_HASHABLE(ptr), &hd.vptr, False) == ASH_Success )
			{
				m = hd.vptr ;	  
				if( (m->type & 0xff) != C_MEM )
				{
					show_error( "while deallocating pointer 0x%lX discovered that it was allocated with different type", ptr );
					print_simple_backtrace();
#ifdef DEBUG_ALLOC_STRICT
{	char *segv = NULL ;	*segv = 0 ;  }
#endif
					m = NULL ;
				}
			}
			service_mode-- ;
		}
		if (m == NULL)
		{
			show_error ("countrealloc:attempt in %s:%d to realloc memory(%p) that was never allocated!\n",
					     fname, line, ptr);
			print_simple_backtrace();
#ifdef DEBUG_ALLOC_STRICT
{	char *segv = NULL ;	*segv = 0 ;  }
#endif
			return NULL;
		}
		if ((m->type & 0xff) == C_MEM)
		{
			total_alloc -= m->length;
			total_alloc += length;
			if (total_alloc > max_alloc)
				max_alloc = total_alloc;
		} else
		{
			total_x_alloc -= m->length;
			total_x_alloc += length;
			if (total_x_alloc > max_x_alloc)
				max_x_alloc = total_x_alloc;
		}
		m->fname = fname;
		m->line = line;
		m->length = length;
		m->type = C_MEM | C_REALLOC;
		m->ptr = saferealloc (ptr, length);
		m->freed = 0;
		ptr = m->ptr;
		if( (res = add_hash_item( allocs_hash, (ASHashableValue)ptr, m )) != ASH_Success )
		{
			show_error( "failed to log allocation for pointer 0x%lX - result = %d", ptr, res);
#ifdef DEBUG_ALLOC_STRICT
{	char *segv = NULL ;	*segv = 0 ;  }
#endif
		}
  		reallocations++;
	} else
		ptr = countmalloc (fname, line, length);

	return ptr;
}