Ejemplo n.º 1
0
 // If the context is not present, create it with value x.
 template <class T> static T& ref(id id_) {
     T* ctx = context::ptr<T>(id_);
     if (!ctx) {
         ctx = create<T>();
         pn_record_def(id_.first, id_.second, pn_class());
         pn_record_set(id_.first, id_.second, ctx);
         pn_decref(ctx);
     }
     return *ctx;
 }
Ejemplo n.º 2
0
static void test_new(size_t size, const pn_class_t *clazz)
{
  void *obj = pn_class_new(clazz, size);
  assert(obj);
  assert(pn_class_refcount(PN_OBJECT, obj) == 1);
  assert(pn_class(obj) == clazz);
  char *bytes = (char *) obj;
  for (size_t i = 0; i < size; i++) {
    // touch everything for valgrind
    bytes[i] = i;
  }
  pn_free(obj);
}