diff options
| author | Kristian Evers <kristianevers@gmail.com> | 2020-01-26 21:36:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-26 21:36:19 +0100 |
| commit | 66013a0202ae77ea6c5ae0e0f0c79f5a0edc5622 (patch) | |
| tree | 00bc3e8ca1db1d8d9013e627073b5c3c44f00983 /src/init.cpp | |
| parent | 0f22959cb2f052fd55e2b8b83289d9eca7b1c71f (diff) | |
| parent | 9ae11763257da599388f522364c6be2d044d1d87 (diff) | |
| download | PROJ-66013a0202ae77ea6c5ae0e0f0c79f5a0edc5622.tar.gz PROJ-66013a0202ae77ea6c5ae0e0f0c79f5a0edc5622.zip | |
Merge pull request #1886 from rouault/cppcheck_1_90_happyness
Few improvements to make cppcheck 1.90 happier
Diffstat (limited to 'src/init.cpp')
| -rw-r--r-- | src/init.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/init.cpp b/src/init.cpp index 19fcf47b..c1683285 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -48,25 +48,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; } |
