Moved more members of public struct odr (ODR*) to struct Odr_private.
[yaz-moved-to-github.git] / src / odr_mem.c
index e35de26..d9e4025 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * Copyright (C) 1995-2005, Index Data ApS
+ * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_mem.c,v 1.5 2005-06-25 15:46:04 adam Exp $
+ * $Id: odr_mem.c,v 1.9 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_mem.c
@@ -60,6 +60,16 @@ int odr_total(ODR o)
     return o->mem ? nmem_total(o->mem) : 0;
 }
 
+Odr_oct *odr_create_Odr_oct(ODR o, const unsigned char *buf, int sz)
+{
+    Odr_oct *p = (Odr_oct *) odr_malloc(o, sizeof(Odr_oct));
+    p->buf = odr_malloc(o, sz);
+    memcpy(p->buf, buf, sz);
+    p->size = sz;
+    p->len = sz;
+    return p;
+}
+
 /* ---------- memory management for data encoding ----------*/
 
 
@@ -67,7 +77,7 @@ int odr_grow_block(ODR b, int min_bytes)
 {
     int togrow;
 
-    if (!b->can_grow)
+    if (!b->op->can_grow)
         return -1;
     if (!b->size)
         togrow = 1024;
@@ -81,9 +91,6 @@ int odr_grow_block(ODR b, int min_bytes)
     else if (!b->size && !(b->buf = (unsigned char *)
                            xmalloc(b->size = togrow)))
         abort();
-#ifdef ODR_DEBUG
-    fprintf(stderr, "New size for encode_buffer: %d\n", b->size);
-#endif
     return 0;
 }