unbound 0.1
memstats.c File Reference

This program reads a log file and prints the memory allocation summed up. More...

#include "config.h"
#include "util/log.h"
#include "util/rbtree.h"
#include "util/locks.h"
#include "util/fptr_wlist.h"
#include <sys/stat.h>

Data Structures

struct  codeline
 The allocation statistics block. More...

Functions

static void usage (void)
 print usage and exit
static int match (char *line)
 match logfile line to see if it needs accounting processing
static struct codeline * get_codeline (rbtree_type *tree, char *key, char *func)
 find or alloc codeline in tree
static void read_malloc_stat (char *line, rbtree_type *tree)
 read up the malloc stats
static void read_calloc_stat (char *line, rbtree_type *tree)
 read up the calloc stats
static off_t get_file_size (const char *fname)
 get size of file
static void readfile (rbtree_type *tree, const char *fname)
 read the logfile
static void printstats (rbtree_type *tree)
 print memory stats
int main (int argc, const char *argv[])
 main program

Detailed Description

This program reads a log file and prints the memory allocation summed up.

Function Documentation

◆ usage()

void usage ( void )
static

print usage and exit

References usage().

◆ match()

int match ( char * line)
static

match logfile line to see if it needs accounting processing

Referenced by readfile().

◆ get_codeline()

struct codeline * get_codeline ( rbtree_type * tree,
char * key,
char * func )
static

◆ read_malloc_stat()

void read_malloc_stat ( char * line,
rbtree_type * tree )
static

read up the malloc stats

References codeline::alloc, codeline::calls, fatal_exit(), get_codeline(), and read_malloc_stat().

Referenced by read_malloc_stat(), and readfile().

◆ read_calloc_stat()

void read_calloc_stat ( char * line,
rbtree_type * tree )
static

read up the calloc stats

References codeline::alloc, codeline::calls, fatal_exit(), get_codeline(), and read_calloc_stat().

Referenced by read_calloc_stat(), and readfile().

◆ get_file_size()

off_t get_file_size ( const char * fname)
static

get size of file

References fatal_exit(), and get_file_size().

Referenced by get_file_size(), and readfile().

◆ readfile()

void readfile ( rbtree_type * tree,
const char * fname )
static

read the logfile

References fatal_exit(), get_file_size(), match(), read_calloc_stat(), read_malloc_stat(), and readfile().

Referenced by main(), and readfile().

◆ printstats()

void printstats ( rbtree_type * tree)
static

◆ main()

int main ( int argc,
const char * argv[] )