Commit cdfa1181 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Cosmetic changes.

Added dump_smalloc_counts().
parent 4592a03b
......@@ -14,6 +14,7 @@
#include "smalloc.h"
#include "lyskomd.h"
#include "log.h"
#include "exp.h"
static u_long no_of_allocated_blocks = 0;
......@@ -21,11 +22,10 @@ static u_long no_of_allocated_blocks = 0;
* "safe" malloc. Handles the case when malloc returns NULL.
* smalloc cannot fail.
*/
void *
EXPORT void *
smalloc(size_t size)
{
unsigned int *p;
p = (unsigned int *) malloc(size + 2*sizeof(unsigned int) + 2);
if (p == NULL)
......@@ -42,7 +42,7 @@ smalloc(size_t size)
}
void
EXPORT void
sfree(void * ptr) /* it is legal to sfree a NULL pointer */
{
unsigned int *ip;
......@@ -76,7 +76,7 @@ sfree(void * ptr) /* it is legal to sfree a NULL pointer */
}
}
extern void *
EXPORT void *
srealloc(void * ptr, size_t size) /* Never fails. It is legal to */
{ /* realloc the NULL ptr. */
unsigned int * ip;
......@@ -131,7 +131,7 @@ static void **tmp_alloc_table = NULL;
static int tmp_alloc_table_size = 0; /* Size */
static int tmp_alloc_table_use = 0; /* Used size */
void *
EXPORT void *
tmp_alloc(u_long size)
{
if ( tmp_alloc_table_size <= tmp_alloc_table_use )
......@@ -153,7 +153,7 @@ tmp_alloc(u_long size)
* Free all core which is allocated with tmp_alloc(). This is called from
* end_of_atomic().
*/
void
EXPORT void
free_tmp(void)
{
int i;
......@@ -167,7 +167,7 @@ free_tmp(void)
tmp_alloc_table_use = 0;
}
void
EXPORT void
free_all_tmp(void)
{
free_tmp();
......@@ -175,3 +175,10 @@ free_all_tmp(void)
tmp_alloc_table = NULL;
tmp_alloc_table_size = 0;
}
EXPORT void
dump_smalloc_counts(FILE *stat_file)
{
fprintf(stat_file, "Allocated blocks (grand total): %lu\n",
no_of_allocated_blocks);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment