Index: libabac/abac.h
===================================================================
--- libabac/abac.h	(revision c5720ad1266cb26f87b523cda06d988df090d258)
+++ libabac/abac.h	(revision 44c85058a2e3cbb99e15b4cf6665bab8cf165e3b)
@@ -22,10 +22,5 @@
 } abac_chunk_t;
 
-void abac_chunk_free(abac_chunk_t);
-abac_chunk_t abac_chunk_dup(char *, int);
-abac_chunk_t abac_chunk_new(char *, int);
-int abac_chunk_null(abac_chunk_t);
-void abac_chunk_show(abac_chunk_t);
-
+void abac_chunk_free(abac_chunk_t *);
 #endif /* __ABAC_CHUNK_T__ */
 
Index: libabac/abac_attribute.c
===================================================================
--- libabac/abac_attribute.c	(revision c5720ad1266cb26f87b523cda06d988df090d258)
+++ libabac/abac_attribute.c	(revision 44c85058a2e3cbb99e15b4cf6665bab8cf165e3b)
@@ -104,5 +104,6 @@
 
     // NULL until baked
-    attr->cert=abac_chunk_new(NULL,0);
+    attr->cert.ptr = NULL;
+    attr->cert.len = 0;
 
     *ret = attr;
@@ -272,10 +273,11 @@
 
     /*MEI, free id_chunk */
-    abac_chunk_free(id_chunk);
+    abac_chunk_free(&id_chunk);
 
     if (attr_cert == NULL)
         return 0;
 
-    attr->cert=abac_chunk_new(attr_cert,strlen(attr_cert));
+    attr->cert.ptr = attr_cert;
+    attr->cert.len = strlen(attr_cert)+1;
 
     return 1;
@@ -288,13 +290,14 @@
 /* 
  * caller is responsible to free up the chunk after use
-*/
+ */
 abac_chunk_t abac_attribute_cert_chunk(abac_attribute_t *attr) {
     abac_chunk_t chunk= {NULL,0};
 
-    if (abac_chunk_null(attr->cert))
+    if (abac_chunk_null(&attr->cert))
         return chunk;
 
     /* return the xml chunk */
-    chunk= abac_chunk_dup(attr->cert.ptr, attr->cert.len);
+    chunk.ptr=(unsigned char *) abac_xstrdup(attr->cert.ptr);
+    chunk.len = attr->cert.len;
     return chunk;
 }
@@ -345,5 +348,6 @@
     attr->role =abac_xstrdup(tmp+1);
 
-    attr->cert=abac_chunk_dup(xml,strlen(xml));
+    attr->cert.ptr = (unsigned char *) abac_xstrdup(xml);
+    attr->cert.len = strlen(xml)+1;
 
     attr->output_format = NULL;
@@ -429,5 +433,5 @@
     assert(attr != NULL);
 
-    if (abac_chunk_null(attr->cert))
+    if (abac_chunk_null(&attr->cert))
         return ABAC_FAILURE;
 
@@ -440,5 +444,5 @@
 // returns ABAC_FAILURE if the cert hasn't been baked
 int abac_attribute_write_file(abac_attribute_t *attr, const char *fname) {
-    if (abac_chunk_null(attr->cert))
+    if (abac_chunk_null(&attr->cert))
         return ABAC_FAILURE;
 
@@ -481,5 +485,5 @@
     if ( attr->keymap ) abac_keyid_map_free(attr->keymap);
 
-    abac_chunk_free(attr->cert);
+    abac_chunk_free(&attr->cert);
 
     free(attr);
Index: libabac/abac_id.c
===================================================================
--- libabac/abac_id.c	(revision c5720ad1266cb26f87b523cda06d988df090d258)
+++ libabac/abac_id.c	(revision 44c85058a2e3cbb99e15b4cf6665bab8cf165e3b)
@@ -131,5 +131,6 @@
     char *new_naked_pem=abac_xstrdup(naked_pem);
     char *pem=make_pem_from_naked_pem(new_naked_pem);
-    chunk=abac_chunk_new(pem,strlen(pem));
+    chunk.ptr = pem;
+    chunk.len = strlen(pem)+1;
     X509 *cert=abac_load_id_from_chunk(chunk.ptr,chunk.len);
     *sha1=NULL;
@@ -142,5 +143,5 @@
     X509_free(cert);
     free(new_naked_pem);
-    abac_chunk_free(chunk);
+    abac_chunk_free(&chunk);
 }
 
@@ -386,9 +387,7 @@
     }
 
-/*
+
     chunk->ptr=(unsigned char *)tmp;
-    chunk->len=len;
-*/
-    *chunk=abac_chunk_new(tmp,strlen(tmp));
+    chunk->len=strlen(tmp)+1;
 
     return ABAC_CERT_SUCCESS;
@@ -400,6 +399,6 @@
     int len=0;
     if(ptr)
-        len=strlen((char *)ptr);
-    abac_chunk_t ret = abac_chunk_new(ptr,len);
+        len=strlen((char *)ptr)+1;
+    abac_chunk_t ret = { ptr, len};
     return ret;
 }
@@ -479,7 +478,7 @@
     unsigned char *ptr=abac_string_cert(id->cert);
     int len=0;
-    if(ptr) len=strlen( (char *)ptr);
-
-    abac_chunk_t ret = abac_chunk_new(ptr,len);
+    if(ptr) len=strlen( (char *)ptr)+1;
+
+    abac_chunk_t ret = { ptr, len };
     return ret;
 }
@@ -493,7 +492,7 @@
     unsigned char *ptr=abac_string_privkey(id->key);
     int len=0;
-    if(ptr) len=strlen( (char *)ptr);
-
-    abac_chunk_t ret = abac_chunk_new(ptr,len);
+    if(ptr) len=strlen( (char *)ptr)+1;
+
+    abac_chunk_t ret = { ptr, len };
     return ret;
 }
Index: libabac/abac_util.c
===================================================================
--- libabac/abac_util.c	(revision c5720ad1266cb26f87b523cda06d988df090d258)
+++ libabac/abac_util.c	(revision 44c85058a2e3cbb99e15b4cf6665bab8cf165e3b)
@@ -24,12 +24,12 @@
 }
 
-void abac_chunk_free(abac_chunk_t chunk)
+void abac_chunk_free(abac_chunk_t *chunk)
 {
-   if(chunk.len)
-       free(chunk.ptr);
-   chunk.len=0;
-   chunk.ptr=NULL;
+   if(chunk->len)
+       free(chunk->ptr);
+   chunk->len=0;
+   chunk->ptr=NULL;
 }
-
+/*
 abac_chunk_t abac_chunk_dup(char *ptr, int len)
 {
@@ -57,16 +57,17 @@
     return chunk;                                             
 }                
+*/
 
-int abac_chunk_null(abac_chunk_t chunk)
+int abac_chunk_null(abac_chunk_t *chunk)
 {
-    if(chunk.ptr==NULL) return 1;
+    if(chunk->ptr==NULL) return 1;
     return 0;
 }
 
-int abac_chunk_show(abac_chunk_t chunk)
+int abac_chunk_show(abac_chunk_t *chunk)
 {
-    if(chunk.ptr==NULL)
+    if(chunk->ptr==NULL)
         fprintf(stderr,"abac_chunk_show: chunk is NULL\n");
-    fprintf(stderr,"abac_chunk_show: chunk is not NULL (%ld)\n",(long)chunk.ptr);
+    fprintf(stderr,"abac_chunk_show: chunk is not NULL (%ld)\n",(long)chunk->ptr);
 }
 
Index: libabac/abac_util.h
===================================================================
--- libabac/abac_util.h	(revision c5720ad1266cb26f87b523cda06d988df090d258)
+++ libabac/abac_util.h	(revision 44c85058a2e3cbb99e15b4cf6665bab8cf165e3b)
@@ -12,9 +12,7 @@
 } abac_chunk_t;
 
-void abac_chunk_free(abac_chunk_t);
-abac_chunk_t abac_chunk_dup(char *, int);
-abac_chunk_t abac_chunk_new(char *, int);
-int abac_chunk_null(abac_chunk_t);
-int abac_chunk_show(abac_chunk_t);
+void abac_chunk_free(abac_chunk_t *);
+int abac_chunk_null(abac_chunk_t *);
+int abac_chunk_show(abac_chunk_t *);
 
 #endif /* __ABAC_CHUNK_T__ */
Index: libabac/abac_verifier.c
===================================================================
--- libabac/abac_verifier.c	(revision c5720ad1266cb26f87b523cda06d988df090d258)
+++ libabac/abac_verifier.c	(revision 44c85058a2e3cbb99e15b4cf6665bab8cf165e3b)
@@ -214,5 +214,5 @@
     abac_chunk_t chunk = { pem, len }; 
     int rc=abac_verifier_load_id_chunk(id_certs,chunk, km);
-    abac_chunk_free(chunk);
+    abac_chunk_free(&chunk);
     return rc;
     
