~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to plugin/pbxt/src/memory_xt.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2011-03-15 10:41:18 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110315104118-eaf0hvlytjdl4zrf
Tags: 2011.03.13-0ubuntu1
* New upstream release.
* Added slave plugin.
* Removed archive, blackhole and blitzdb plugins.
* Moved location of libdrizzle headers.
* Removed drizzleadmin manpage patch.
* Add drizzle_safe_write_string to symbols.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2005 PrimeBase Technologies GmbH
2
 
 *
3
 
 * PrimeBase XT
4
 
 *
5
 
 * This program is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License as published by
7
 
 * the Free Software Foundation; either version 2 of the License, or
8
 
 * (at your option) any later version.
9
 
 *
10
 
 * This program is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU General Public License for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU General Public License
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
 
 *
19
 
 * 2005-01-04   Paul McCullagh
20
 
 *
21
 
 * H&G2JCtL
22
 
 */
23
 
#ifndef __xt_memory_h__
24
 
#define __xt_memory_h__
25
 
 
26
 
#include <string.h>
27
 
 
28
 
#include "xt_defs.h"
29
 
 
30
 
struct XTThread;
31
 
 
32
 
#ifdef DEBUG
33
 
#define DEBUG_MEMORY
34
 
#endif
35
 
 
36
 
#ifdef DEBUG_MEMORY
37
 
 
38
 
#define XT_MM_STACK_TRACE       200
39
 
#define XT_MM_TRACE_DEPTH       4
40
 
#define XT_MM_TRACE_INC         ((char *) 1)
41
 
#define XT_MM_TRACE_DEC         ((char *) 2)
42
 
#define XT_MM_TRACE_SW_INC      ((char *) 1)
43
 
#define XT_MM_TRACE_SW_DEC      ((char *) 2)
44
 
#define XT_MM_TRACE_ERROR       ((char *) 3)
45
 
 
46
 
typedef struct XTMMTraceRef {
47
 
        int                                             mm_pos;
48
 
        u_int                                   mm_id;
49
 
        u_int                                   mm_line[XT_MM_STACK_TRACE];
50
 
        c_char                                  *mm_trace[XT_MM_STACK_TRACE];
51
 
} XTMMTraceRefRec, *XTMMTraceRefPtr;
52
 
 
53
 
#define XT_MM_TRACE_INIT(x)     (x)->mm_pos = 0
54
 
 
55
 
extern char *mm_watch_point;
56
 
 
57
 
#define XT_MEMMOVE(b, d, s, l)  xt_mm_memmove(b, d, s, l)
58
 
#define XT_MEMCPY(b, d, s, l)   xt_mm_memcpy(b, d, s, l)
59
 
#define XT_MEMSET(b, d, v, l)   xt_mm_memset(b, d, v, l)
60
 
 
61
 
#define xt_malloc(t, s)                 xt_mm_malloc(t, s, __LINE__, __FILE__)
62
 
#define xt_calloc(t, s)                 xt_mm_calloc(t, s, __LINE__, __FILE__)
63
 
#define xt_realloc(t, p, s)             xt_mm_realloc(t, p, s, __LINE__, __FILE__)
64
 
#define xt_free                                 xt_mm_free
65
 
#define xt_pfree                                xt_mm_pfree
66
 
 
67
 
#define xt_malloc_ns(s)                 xt_mm_malloc(NULL, s, __LINE__, __FILE__)
68
 
#define xt_calloc_ns(s)                 xt_mm_calloc(NULL, s, __LINE__, __FILE__)
69
 
#define xt_realloc_ns(p, s)             xt_mm_sys_realloc(NULL, p, s, __LINE__, __FILE__)
70
 
#define xt_free_ns(p)                   xt_mm_free(NULL, p)
71
 
 
72
 
void    xt_mm_memmove(void *block, void *dest, void *source, size_t size);
73
 
void    xt_mm_memcpy(void *block, void *dest, void *source, size_t size);
74
 
void    xt_mm_memset(void *block, void *dest, int value, size_t size);
75
 
 
76
 
void    *xt_mm_malloc(struct XTThread *self, size_t size, u_int line, const char *file);
77
 
void    *xt_mm_calloc(struct XTThread *self, size_t size, u_int line, const char *file);
78
 
xtBool  xt_mm_realloc(struct XTThread *self, void **ptr, size_t size, u_int line, const char *file);
79
 
void    xt_mm_free(struct XTThread *self, void *ptr);
80
 
void    xt_mm_pfree(struct XTThread *self, void **ptr);
81
 
size_t  xt_mm_malloc_size(struct XTThread *self, void *ptr);
82
 
void    xt_mm_check_ptr(struct XTThread *self, void *ptr);
83
 
xtBool  xt_mm_sys_realloc(struct XTThread *self, void **ptr, size_t newsize, u_int line, const char *file);
84
 
 
85
 
#ifndef XT_SCAN_CORE_DEFINED
86
 
#define XT_SCAN_CORE_DEFINED
87
 
xtBool  xt_mm_scan_core(void);
88
 
#endif
89
 
 
90
 
void    mm_trace_print_id(void *ptr);
91
 
void    mm_trace_inc(struct XTThread *self, XTMMTraceRefPtr tr);
92
 
void    mm_trace_dec(struct XTThread *self, XTMMTraceRefPtr tr);
93
 
void    mm_trace_init(struct XTThread *self, XTMMTraceRefPtr tr);
94
 
void    mm_trace_print(XTMMTraceRefPtr tr);
95
 
 
96
 
#else
97
 
 
98
 
#define XT_MEMMOVE(b, d, s, l)  memmove(d, s, l)
99
 
#define XT_MEMCPY(b, d, s, l)   memcpy(d, s, l)
100
 
#define XT_MEMSET(b, d, v, l)   memset(d, v, l)
101
 
 
102
 
void    *xt_malloc(struct XTThread *self, size_t size);
103
 
void    *xt_calloc(struct XTThread *self, size_t size);
104
 
xtBool  xt_realloc(struct XTThread *self, void **ptr, size_t size);
105
 
void    xt_free(struct XTThread *self, void *ptr);
106
 
void    xt_pfree(struct XTThread *self, void **ptr);
107
 
 
108
 
void    *xt_malloc_ns(size_t size);
109
 
void    *xt_calloc_ns(size_t size);
110
 
xtBool  xt_realloc_ns(void **ptr, size_t size);
111
 
void    xt_free_ns(void *ptr);
112
 
 
113
 
#define xt_pfree(t, p)                  xt_pfree(t, (void **) p)
114
 
 
115
 
#endif
116
 
 
117
 
#ifdef DEBUG_MEMORY
118
 
#define xt_dup_string(t, s)             xt_mm_dup_string(t, s, __LINE__, __FILE__)
119
 
 
120
 
char    *xt_mm_dup_string(struct XTThread *self, const char *path, u_int line, const char *file);
121
 
#else
122
 
char    *xt_dup_string(struct XTThread *self, const char *path);
123
 
#endif
124
 
 
125
 
char    *xt_long_to_str(struct XTThread *self, long v);
126
 
char    *xt_dup_nstr(struct XTThread *self, const char *str, int start, size_t len);
127
 
 
128
 
xtBool  xt_init_memory(void);
129
 
void    xt_exit_memory(void);
130
 
 
131
 
#endif