Veil
veil_utils.c
Go to the documentation of this file.
1 /**
2  * @file veil_utils.c
3  * \code
4  * Author: Marc Munro
5  * Copyright (c) 2005 - 2011 Marc Munro
6  * License: BSD
7  *
8  * \endcode
9  * @brief
10  * Miscelaneous functions for veil
11  *
12  */
13 
14 
15 #include "postgres.h"
16 #include "utils/memutils.h"
17 #include "veil_funcs.h"
18 #include "veil_datatypes.h"
19 
20 /**
21  * Dynamically allocate memory using palloc in TopMemoryContext.
22  *
23  * @param size The size of the chunk of memory being requested.
24  *
25  * @return Pointer to the newly allocated chunk of memory
26  */
27 void *
28 vl_malloc(size_t size)
29 {
30  void *result;
31  MemoryContext oldcontext = MemoryContextSwitchTo(TopMemoryContext);
32  result = palloc(size);
33  (void) MemoryContextSwitchTo(oldcontext);
34  return result;
35 }
36 
37 /**
38  * Return a static string describing an ObjType object.
39  *
40  * @param obj The ObjType for which we want a description.
41  *
42  * @return Pointer to a static string describing obj.
43  */
44 char *
46 {
47  static char *names[] = {
48  "Undefined", "ShmemCtl", "Int4",
49  "Range", "Bitmap", "BitmapArray",
50  "BitmapHash", "BitmapRef", "Int4Array"
51  };
52 
53  if ((obj < OBJ_UNDEFINED) ||
54  (obj > OBJ_INT4_ARRAY))
55  {
56  return "Unknown";
57  }
58  else {
59  return names[obj];
60  }
61 }
62 
void * vl_malloc(size_t size)
Dynamically allocate memory using palloc in TopMemoryContext.
Definition: veil_utils.c:28
Provide definitions for all non-local C-callable Veil functions.
ObjType
Describes the type of an Object record or one of its subtypes.
char * vl_ObjTypeName(ObjType obj)
Return a static string describing an ObjType object.
Definition: veil_utils.c:45
Define all Veil public datatypes.