veil_utils.c

Go to the documentation of this file.
00001 /**
00002  * @file   veil_utils.c
00003  * \code
00004  *     Author:       Marc Munro
00005  *     Copyright (c) 2005, 2006 Marc Munro
00006  *     License:      BSD
00007  * $Id: veil_utils.c,v 1.3 2006/10/04 15:50:10 bloodnok Exp $
00008  * \endcode
00009  * @brief  
00010  * Miscelaneous functions for veil
00011  * 
00012  */
00013 
00014 
00015 #include "postgres.h"
00016 #include "utils/memutils.h"
00017 #include "veil_funcs.h"
00018 #include "veil_datatypes.h"
00019 
00020 /** 
00021  * Dynamically allocate memory using palloc in TopMemoryContext.
00022  * 
00023  * @param size The size of the chunk of memory being requested.
00024  * 
00025  * @return Pointer to the newly allocated chunk of memory
00026  */
00027 void *
00028 vl_malloc(size_t size)
00029 {
00030     void *result;
00031     MemoryContext oldcontext = MemoryContextSwitchTo(TopMemoryContext);
00032     result = palloc(size);
00033     (void) MemoryContextSwitchTo(oldcontext);
00034     return result;
00035 }
00036 
00037 /** 
00038  * Return a static string describing an ObjType object.
00039  * 
00040  * @param obj The ObjType for which we want a description.
00041  * 
00042  * @return Pointer to a static string describing obj.
00043  */
00044 char *
00045 vl_ObjTypeName(ObjType obj)
00046 {
00047     static char *names[] = {
00048         "Undefined", "ShmemCtl", "Int4", 
00049         "Range", "Bitmap", "BitmapArray", 
00050         "BitmapHash", "BitmapRef", "Int4Array"
00051     };
00052 
00053     if ((obj < OBJ_UNDEFINED) ||
00054         (obj > OBJ_INT4_ARRAY)) 
00055     {
00056         return "Unknown";
00057     }
00058     else {
00059         return names[obj];
00060     }
00061 }
00062 

Generated on Tue Mar 11 10:08:36 2008 for Veil by  doxygen 1.5.4