projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed some memory leaks in GUI.
[pspp-builds.git]
/
src
/
libpspp
/
str.c
diff --git
a/src/libpspp/str.c
b/src/libpspp/str.c
index c72f19969ec8f1090f958e39c36a276f6b5b1f8f..70edaeede16c0ac5bdf871d620b690cbd7118d59 100644
(file)
--- a/
src/libpspp/str.c
+++ b/
src/libpspp/str.c
@@
-18,13
+18,16
@@
02110-1301, USA. */
#include <config.h>
02110-1301, USA. */
#include <config.h>
+
#include "str.h"
#include "str.h"
-#include "message.h"
+
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
-#include "alloc.h"
-#include "message.h"
+
+#include <libpspp/alloc.h>
+#include <libpspp/message.h>
+
#include "minmax.h"
#include "size_max.h"
\f
#include "minmax.h"
#include "size_max.h"
\f
@@
-681,6
+684,21
@@
ds_concat (struct string *st, const char *buf, size_t len)
st->length += len;
}
st->length += len;
}
+/* Returns ds_end(ST) and THEN increases the length by INCR. */
+char *
+ds_append_uninit(struct string *st, size_t incr)
+{
+ char *end;
+
+ ds_extend(st, ds_length(st) + incr);
+
+ end = ds_end(st);
+
+ st->length += incr;
+
+ return end;
+}
+
/* Formats FORMAT as a printf string and appends the result to ST. */
void
ds_printf (struct string *st, const char *format, ...)
/* Formats FORMAT as a printf string and appends the result to ST. */
void
ds_printf (struct string *st, const char *format, ...)
@@
-699,12
+717,8
@@
ds_vprintf (struct string *st, const char *format, va_list args_)
int avail, needed;
va_list args;
int avail, needed;
va_list args;
-#ifndef va_copy
-#define va_copy(DST, SRC) (DST) = (SRC)
-#endif
-
va_copy (args, args_);
va_copy (args, args_);
- avail = st->
capacity - st->length + 1
;
+ avail = st->
string != NULL ? st->capacity - st->length + 1 : 0
;
needed = vsnprintf (st->string + st->length, avail, format, args);
va_end (args);
needed = vsnprintf (st->string + st->length, avail, format, args);
va_end (args);