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