~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/replication/utility.h

  • Committer: Monty Taylor
  • Date: 2008-12-06 07:22:02 UTC
  • mto: (656.1.7 devel) (660.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: monty@inaugust.com-20081206072202-2g25o9doqr1l8euu
OOOh doggie. Got rid of my_alloca.

Show diffs side-by-side

added added

removed removed

Lines of Context:
244
244
  table_def m_tabledef;
245
245
};
246
246
 
247
 
 
248
 
/* Anonymous namespace for template functions/classes */
249
 
namespace {
250
 
 
251
 
  /*
252
 
    Smart pointer that will automatically call my_afree (a macro) when
253
 
    the pointer goes out of scope.  This is used so that I do not have
254
 
    to remember to call my_afree() before each return.  There is no
255
 
    overhead associated with this, since all functions are inline.
256
 
 
257
 
    I (Matz) would prefer to use the free function as a template
258
 
    parameter, but that is not possible when the "function" is a
259
 
    macro.
260
 
  */
261
 
  template <class Obj>
262
 
  class auto_afree_ptr
263
 
  {
264
 
    Obj* m_ptr;
265
 
  public:
266
 
    auto_afree_ptr(Obj* ptr) : m_ptr(ptr) { }
267
 
    ~auto_afree_ptr() { if (m_ptr) my_afree(m_ptr); }
268
 
    void assign(Obj* ptr) {
269
 
      /* Only to be called if it hasn't been given a value before. */
270
 
      assert(m_ptr == NULL);
271
 
      m_ptr= ptr;
272
 
    }
273
 
    Obj* get() { return m_ptr; }
274
 
  };
275
 
 
276
 
}
277
 
 
278
247
#endif /* RPL_UTILITY_H */