Main Page | Class List | Directories | File List | Class Members | File Members

ObitMem.h File Reference

Obit memory manager utilities This system allocates, deallocates and determines the usability of memory. More...

#include "ObitThread.h"
#include <stdio.h>
#include <stdlib.h>
#include "memwatch.h"

Go to the source code of this file.

Functions

void ObitMemClassInit (void)
 Public: Class initializer.
gpointer ObitMemAlloc (gulong size)
 Public: allocate memory.
gpointer ObitMemAlloc0 (gulong size)
 Public: allocate memory and zero fill.
gpointer ObitMemAllocName (gulong size, gchar *name)
 Public: allocate memory giving name.
gpointer ObitMemAlloc0Name (gulong size, gchar *name)
 Public: allocate memory and zero fill, giving name.
gpointer ObitMemRealloc (gpointer mem, gulong size)
 Public: reallocate memory.
gpointer ObitMemFree (gpointer mem)
 Public: deallocate.
gboolean ObitMemValid (gpointer mem)
 Public: Check if in allocated block.
void ObitMemPrint (FILE *file)
 Public: Print contents to file (e.g.
void ObitMemSummary (glong *number, glong *total)
 Public: Summary of contents.


Detailed Description

Obit memory manager utilities This system allocates, deallocates and determines the usability of memory.

It is designed to minimize the chances of some of the more common c memory problems, especially freeing bad pointers or memory multiple times.


Function Documentation

gpointer ObitMemAlloc gulong  size  ) 
 

Public: allocate memory.

Implementation used g_malloc

Parameters:
size Number of bytes requested
Returns:
pointer to allocated memory, NULL on failure

gpointer ObitMemAlloc0 gulong  size  ) 
 

Public: allocate memory and zero fill.

Implementation uses g_malloc0

Parameters:
size Number of bytes requested
Returns:
pointer to allocated memory, NULL on failure

gpointer ObitMemAlloc0Name gulong  size,
gchar *  name
 

Public: allocate memory and zero fill, giving name.

Implementation uses g_malloc0

Parameters:
size Number of bytes requested
name Name for entry, up to 20 char. Useful for debugging.
Returns:
pointer to allocated memory, NULL on failure

gpointer ObitMemAllocName gulong  size,
gchar *  name
 

Public: allocate memory giving name.

Initializes class if needed on first call. Implementation used g_malloc

Parameters:
size Number of bytes requested
name Name for entry, up to 20 char. Useful for debugging.
Returns:
pointer to allocated memory, NULL on failure

void ObitMemClassInit void   ) 
 

Public: Class initializer.

gpointer ObitMemFree gpointer  mem  ) 
 

Public: deallocate.

This is a NOP if mem is not to a valid block of memory. Note: ONLY FREE MEMORY ALLOCATED BY ObitMem!!! Implementation used g_free

Parameters:
mem Pointer to memory to be freed.
Returns:
pointer to allocated memory, NULL on failure

void ObitMemPrint FILE *  file  ) 
 

Public: Print contents to file (e.g.

stdout)

Parameters:
file to print to.

gpointer ObitMemRealloc gpointer  mem,
gulong  size
 

Public: reallocate memory.

Parameters:
mem Pointer to old memory, if null, allocates anonymous slot
size Number of bytes requested
Returns:
pointer to allocated memory, NULL on failure

void ObitMemSummary glong *  number,
glong *  total
 

Public: Summary of contents.

Parameters:
number Number of entries
total Total memory allocated in MByte

gboolean ObitMemValid gpointer  mem  ) 
 

Public: Check if in allocated block.

Parameters:
mem Pointer to memory to be tested.
Returns:
TRUE if in allocated block, else FALSE


Generated on Fri Aug 31 22:13:07 2007 for Obit by  doxygen 1.3.9.1