This has little cost and it is occasionally valuable.
---
src/libpspp/str.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libpspp/str.c b/src/libpspp/str.c
index bde4de4..9f0cb6e 100644
--- a/src/libpspp/str.c
+++ b/src/libpspp/str.c
@@ -30,6 +30,7 @@
#include <relocatable.h>
#include "minmax.h"
#include "xalloc.h"
+#include "xmemdup0.h"
#include "xsize.h"
/* Reverses the order of NBYTES bytes at address P, thus converting
@@ -379,14 +380,13 @@ ss_tail (struct substring ss, size_t cnt)
return ss;
}
-/* Makes a malloc()'d copy of the contents of OLD
+/* Makes a malloc()'d, null-terminated copy of the contents of OLD
and stores it in NEW. */
void
ss_alloc_substring (struct substring *new, struct substring old)
{
- new->string = xmalloc (old.length);
+ new->string = xmemdup0 (old.string, old.length);
new->length = old.length;
- memcpy (new->string, old.string, old.length);
}
/* Allocates room for a CNT-character string in NEW. */
--
1.7.1
_______________________________________________
pspp-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-dev