aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2022-08-31 23:16:08 -0800
committerDavid M. Syzdek <david@syzdek.net>2022-08-31 23:16:08 -0800
commitea503396fa498941fa03860bd1dc41887d32f283 (patch)
tree45ef330aab5049b202552ae68c8fc8cb0fe9e0df /lib
parentc8d06caf32b5419f370377973d29e611e77d229e (diff)
downloadbindletools-ea503396fa498941fa03860bd1dc41887d32f283.tar.gz
bindletools-ea503396fa498941fa03860bd1dc41887d32f283.tar.bz2
bindletools-ea503396fa498941fa03860bd1dc41887d32f283.tar.xz
bindletools-ea503396fa498941fa03860bd1dc41887d32f283.zip
libbindle: refactoring bindle_strsadd()
Diffstat (limited to 'lib')
-rw-r--r--lib/libbindle/lstrings.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/libbindle/lstrings.c b/lib/libbindle/lstrings.c
index 80f34e8..2d44c58 100644
--- a/lib/libbindle/lstrings.c
+++ b/lib/libbindle/lstrings.c
@@ -78,6 +78,7 @@ bindle_strsadd(
78{ 78{
79 size_t count; 79 size_t count;
80 char ** strs; 80 char ** strs;
81 char * dup;
81 82
82 BindleDebugTrace(); 83 BindleDebugTrace();
83 84
@@ -86,14 +87,18 @@ bindle_strsadd(
86 87
87 count = bindle_strscount(*strsp); 88 count = bindle_strscount(*strsp);
88 89
90 // copy string
91 if ((dup = bindle_strdup(str)) == NULL)
92 return(ENOMEM);
93
89 // increase size of array 94 // increase size of array
90 if ((strs = realloc(*strsp, (sizeof(char *)*(count+2)))) == NULL) 95 if ((strs = realloc(*strsp, (sizeof(char *)*(count+2)))) == NULL)
96 {
97 free(dup);
91 return(ENOMEM); 98 return(ENOMEM);
99 };
92 *strsp = strs; 100 *strsp = strs;
93 101 strs[count] = dup;
94 // copy string
95 if ((strs[count] = bindle_strdup(str)) == NULL)
96 return(ENOMEM);
97 102
98 // terminate array 103 // terminate array
99 count++; 104 count++;