summaryrefslogtreecommitdiff
path: root/sql/rpl_utility.h
diff options
context:
space:
mode:
authorunknown <tsmith@sita.local>2007-08-29 15:28:38 -0600
committerunknown <tsmith@sita.local>2007-08-29 15:28:38 -0600
commit48193af48948acb84ddd3b488b6f8faa4a6d126b (patch)
tree81c00dc60322deeb0c094deef5d141509c980a60 /sql/rpl_utility.h
parent024bd2f612825cd36c93775728f56856e5f28267 (diff)
parent053c9d1c473df4e1457992ee6a39da3e0cb39bdd (diff)
downloadmariadb-git-48193af48948acb84ddd3b488b6f8faa4a6d126b.tar.gz
Merge sita.local:/Users/tsmith/m/bk/maint/51-target22
into sita.local:/Users/tsmith/m/bk/maint/51 sql/field.cc: Auto merged sql/log_event_old.cc: Auto merged sql/rpl_record.h: Auto merged sql/rpl_utility.cc: Auto merged sql/rpl_utility.h: Auto merged sql/slave.h: Auto merged storage/innobase/handler/ha_innodb.cc: Auto merged sql/log_event.cc: Manual merge sql/log_event.h: Manual merge sql/log_event_old.h: Manual merge sql/rpl_record.cc: Manual merge sql/slave.cc: Manual merge
Diffstat (limited to 'sql/rpl_utility.h')
-rw-r--r--sql/rpl_utility.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h
index eac3d14dfc6..4fd38022da0 100644
--- a/sql/rpl_utility.h
+++ b/sql/rpl_utility.h
@@ -217,7 +217,7 @@ public:
WL#3915) or needs to advance the pointer for the fields in the raw
data from the master to a specific column.
*/
- uint32 calc_field_size(uint col, uchar *master_data);
+ uint32 calc_field_size(uint col, uchar *master_data) const;
/**
Decide if the table definition is compatible with a table.
@@ -258,4 +258,44 @@ struct RPL_TABLE_LIST
table_def m_tabledef;
};
+
+/* Anonymous namespace for template functions/classes */
+namespace {
+
+ /*
+ Smart pointer that will automatically call my_afree (a macro) when
+ the pointer goes out of scope. This is used so that I do not have
+ to remember to call my_afree() before each return. There is no
+ overhead associated with this, since all functions are inline.
+
+ I (Matz) would prefer to use the free function as a template
+ parameter, but that is not possible when the "function" is a
+ macro.
+ */
+ template <class Obj>
+ class auto_afree_ptr
+ {
+ Obj* m_ptr;
+ public:
+ auto_afree_ptr(Obj* ptr) : m_ptr(ptr) { }
+ ~auto_afree_ptr() { if (m_ptr) my_afree(m_ptr); }
+ void assign(Obj* ptr) {
+ /* Only to be called if it hasn't been given a value before. */
+ DBUG_ASSERT(m_ptr == NULL);
+ m_ptr= ptr;
+ }
+ Obj* get() { return m_ptr; }
+ };
+
+}
+
+#define DBUG_PRINT_BITSET(N,FRM,BS) \
+ do { \
+ char buf[256]; \
+ for (uint i = 0 ; i < (BS)->n_bits ; ++i) \
+ buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \
+ buf[(BS)->n_bits] = '\0'; \
+ DBUG_PRINT((N), ((FRM), buf)); \
+ } while (0)
+
#endif /* RPL_UTILITY_H */