projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
SPLIT FILE: Convert test to Autotest framework.
[pspp-builds.git]
/
src
/
libpspp
/
str.c
diff --git
a/src/libpspp/str.c
b/src/libpspp/str.c
index 71f54474d57f995f8c5b73572e1d8f761b7e934e..9f0cb6e31463ab5caf319114e43fed26f640ae2b 100644
(file)
--- a/
src/libpspp/str.c
+++ b/
src/libpspp/str.c
@@
-30,6
+30,7
@@
#include <relocatable.h>
#include "minmax.h"
#include "xalloc.h"
#include <relocatable.h>
#include "minmax.h"
#include "xalloc.h"
+#include "xmemdup0.h"
#include "xsize.h"
\f
/* Reverses the order of NBYTES bytes at address P, thus converting
#include "xsize.h"
\f
/* 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;
}
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)
{
and stores it in NEW. */
void
ss_alloc_substring (struct substring *new, struct substring old)
{
- new->string = xm
alloc (
old.length);
+ new->string = xm
emdup0 (old.string,
old.length);
new->length = old.length;
new->length = old.length;
- memcpy (new->string, old.string, old.length);
}
/* Allocates room for a CNT-character string in NEW. */
}
/* Allocates room for a CNT-character string in NEW. */
@@
-1465,7
+1465,9
@@
ds_relocate (struct string *st)
{
ds_clear (st);
ds_put_cstr (st, rel);
{
ds_clear (st);
ds_put_cstr (st, rel);
- free ((char *) rel);
+ /* The documentation for relocate says that casting away const
+ and then freeing is appropriate ... */
+ free (CONST_CAST (char *, rel));
}
}
}
}