]> mj.ucw.cz Git - libucw.git/commitdiff
obj_add_attr_ref() with an on-stack buffer is not advisable, better
authorMartin Mares <mj@ucw.cz>
Thu, 5 Aug 2004 22:33:19 +0000 (22:33 +0000)
committerMartin Mares <mj@ucw.cz>
Thu, 5 Aug 2004 22:33:19 +0000 (22:33 +0000)
allocate the buffer in the object pool.

lib/buck2obj.c

index 18ce8e2132126fe98bc9d71dd14b746cb0e0a63d..d75b48ab19e212b2d65e8996981db3b6dda85325 100644 (file)
@@ -123,12 +123,12 @@ buck2obj_parse(struct buck2obj_buf *buf, uns buck_type, uns buck_len, struct fas
       while (btell(body) < end)
       {
        uns len = bget_utf8(body);
-       if (!len--)
+       if (!len)
          break;
-       byte buf[MAX_ATTR_SIZE];
+       byte *buf = mp_alloc_fast_noalign(o_hdr->pool, len);
        bread(body, buf, len);
+       uns type = buf[--len];
        buf[len] = 0;
-       byte type = bgetc(body);
        obj_add_attr_ref(o_hdr, type, buf);
       }
       *body_start = btell(body) - start;