[svn:parrot] r37960 - branches/packfile_revamp/src/packfile

bacek at svn.parrot.org bacek at svn.parrot.org
Tue Apr 7 21:35:26 UTC 2009


Author: bacek
Date: Tue Apr  7 21:35:25 2009
New Revision: 37960
URL: https://trac.parrot.org/parrot/changeset/37960

Log:
Fill padding for stored cstring with zeros.

Modified:
   branches/packfile_revamp/src/packfile/pf_items.c

Modified: branches/packfile_revamp/src/packfile/pf_items.c
==============================================================================
--- branches/packfile_revamp/src/packfile/pf_items.c	Tue Apr  7 21:34:48 2009	(r37959)
+++ branches/packfile_revamp/src/packfile/pf_items.c	Tue Apr  7 21:35:25 2009	(r37960)
@@ -1473,8 +1473,14 @@
 PF_store_cstring(ARGOUT(opcode_t *cursor), ARGIN(const char *s))
 {
     ASSERT_ARGS(PF_store_cstring)
+    /*
+     * This is not very efficient for filling padding with zeros.
+     * But it's more efficient than calculate strlen twice.
+     */
+    size_t store_size = PF_size_cstring(s);
+    memset((char *) cursor, 0, store_size * sizeof (opcode_t));
     strcpy((char *) cursor, s);
-    return cursor + PF_size_cstring(s);
+    return cursor + store_size;
 }
 
 /*


More information about the parrot-commits mailing list