aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/init.cpp b/src/init.cpp
index ba3d86e4..9c7b7b19 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -49,25 +49,23 @@ static paralist *string_to_paralist (PJ_CONTEXT *ctx, char *definition) {
Convert a string (presumably originating from get_init_string) to a paralist.
***************************************************************************************/
const char *c = definition;
- paralist *first = nullptr, *next = nullptr;
+ paralist *first = nullptr, *last = nullptr;
while (*c) {
/* Keep a handle to the start of the list, so we have something to return */
- if (nullptr==first)
- first = next = pj_mkparam_ws (c, &c);
- else
- next = next->next = pj_mkparam_ws (c, &c);
- if (nullptr==next) {
+ auto param = pj_mkparam_ws (c, &c);
+ if (nullptr==param) {
pj_dealloc_params (ctx, first, ENOMEM);
return nullptr;
}
+ if (nullptr==last) {
+ first = param;
+ }
+ else {
+ last->next = param;
+ }
+ last = param;
}
-
- if( next == nullptr )
- return nullptr;
-
- /* Terminate list and return */
- next->next = nullptr;
return first;
}