aboutsummaryrefslogtreecommitdiff
path: root/py/vstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-10-14 16:46:34 +1100
committerDamien George <damien.p.george@gmail.com>2016-10-14 16:46:34 +1100
commit824f5c5a32d740acad50d23b7ab1d69660dcf3ad (patch)
treec2d1f13b656b7a2f218fa59e20fd2ca039d03721 /py/vstr.c
parented878275b020c006ec197bb5f5bdd8179fb36a4c (diff)
py/vstr: Combine vstr_new_size with vstr_new since they are rarely used.
Now there is just one function to allocate a new vstr, namely vstr_new (in addition to vstr_init etc). The caller of this function should know what initial size to allocate for the buffer, or at least have some policy or config option, instead of leaving it to a default (as it was before).
Diffstat (limited to 'py/vstr.c')
-rw-r--r--py/vstr.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/py/vstr.c b/py/vstr.c
index 5096475f1..6a91552b5 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -74,20 +74,8 @@ void vstr_clear(vstr_t *vstr) {
vstr->buf = NULL;
}
-vstr_t *vstr_new(void) {
+vstr_t *vstr_new(size_t alloc) {
vstr_t *vstr = m_new_obj(vstr_t);
- if (vstr == NULL) {
- return NULL;
- }
- vstr_init(vstr, 16);
- return vstr;
-}
-
-vstr_t *vstr_new_size(size_t alloc) {
- vstr_t *vstr = m_new_obj(vstr_t);
- if (vstr == NULL) {
- return NULL;
- }
vstr_init(vstr, alloc);
return vstr;
}