libctf: drop mmap()-based CTF data allocator
[deliverable/binutils-gdb.git] / libctf / ctf-create.c
index 5b53479294c1b99942c08272a89b761b3477309a..86695f5abfb8a35e646e3b90991687a7a24136d2 100644 (file)
@@ -310,7 +310,7 @@ ctf_update (ctf_file_t *fp)
 
   buf_size = sizeof (ctf_header_t) + hdr.cth_stroff + hdr.cth_strlen;
 
-  if ((buf = ctf_data_alloc (buf_size)) == NULL)
+  if ((buf = malloc (buf_size)) == NULL)
     return (ctf_set_errno (fp, EAGAIN));
 
   memcpy (buf, &hdr, sizeof (ctf_header_t));
@@ -449,11 +449,9 @@ ctf_update (ctf_file_t *fp)
   /* Finally, we are ready to ctf_simple_open() the new container.  If this
      is successful, we then switch nfp and fp and free the old container.  */
 
-  ctf_data_protect (buf, buf_size);
-
   if ((nfp = ctf_simple_open (buf, buf_size, NULL, 0, 0, NULL, 0, &err)) == NULL)
     {
-      ctf_data_free (buf, buf_size);
+      ctf_free (buf);
       return (ctf_set_errno (fp, err));
     }
 
@@ -462,7 +460,7 @@ ctf_update (ctf_file_t *fp)
 
   nfp->ctf_refcnt = fp->ctf_refcnt;
   nfp->ctf_flags |= fp->ctf_flags & ~LCTF_DIRTY;
-  nfp->ctf_data.cts_data = NULL;       /* Force ctf_data_free() on close.  */
+  nfp->ctf_data.cts_data = NULL;       /* Force ctf_free() on close.  */
   nfp->ctf_dthash = fp->ctf_dthash;
   nfp->ctf_dtdefs = fp->ctf_dtdefs;
   nfp->ctf_dtbyname = fp->ctf_dtbyname;
@@ -1993,16 +1991,17 @@ ctf_compress_write (ctf_file_t *fp, int fd)
   memcpy (hp, fp->ctf_base, header_len);
   hp->cth_flags |= CTF_F_COMPRESS;
 
-  if ((buf = ctf_data_alloc (max_compress_len)) == NULL)
+  if ((buf = ctf_alloc (max_compress_len)) == NULL)
     return (ctf_set_errno (fp, ECTF_ZALLOC));
 
   compress_len = max_compress_len;
-  if ((rc = compress (buf, (uLongf *) & compress_len,
+  if ((rc = compress (buf, (uLongf *) &compress_len,
                      fp->ctf_base + header_len,
                      fp->ctf_size - header_len)) != Z_OK)
     {
       ctf_dprintf ("zlib deflate err: %s\n", zError (rc));
       err = ctf_set_errno (fp, ECTF_COMPRESS);
+      ctf_free (buf);
       goto ret;
     }
 
@@ -2030,7 +2029,7 @@ ctf_compress_write (ctf_file_t *fp, int fd)
     }
 
 ret:
-  ctf_data_free (buf, max_compress_len);
+  ctf_free (buf);
   return err;
 }
 
This page took 0.024922 seconds and 4 git commands to generate.