Changeset 2294 for trunk/src/kash/shinstance.c
- Timestamp:
- Feb 28, 2009, 9:33:26 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/shinstance.c
r2293 r2294 181 181 182 182 /** 183 * Clones a n environment vector.183 * Clones a string vector like enviorn or argv. 184 184 * 185 185 * @returns 0 on success, -1 and errno on failure. 186 * @param psh The shell to associate the allocations with. 186 187 * @param dstp Where to store the clone. 187 188 * @param src The vector to be cloned. 188 189 */ 189 static int sh_ env_clone(char ***dstp, char **src)190 static int sh_clone_string_vector(shinstance *psh, char ***dstp, char **src) 190 191 { 191 192 char **dst; … … 198 199 199 200 /* alloc clone array. */ 200 *dstp = dst = sh_malloc( NULL, sizeof(*dst) * items + 1);201 *dstp = dst = sh_malloc(psh, sizeof(*dst) * items + 1); 201 202 if (!dst) 202 203 return -1; … … 206 207 while (items-- > 0) 207 208 { 208 dst[items] = sh_strdup( NULL, src[items]);209 dst[items] = sh_strdup(psh, src[items]); 209 210 if (!dst[items]) 210 211 { 211 212 /* allocation error, clean up. */ 212 213 while (dst[++items]) 213 sh_free( NULL, dst[items]);214 sh_free( NULL, dst);214 sh_free(psh, dst[items]); 215 sh_free(psh, dst); 215 216 errno = ENOMEM; 216 217 return -1; … … 246 247 247 248 /* Call the basic initializers. */ 248 if ( !sh_env_clone(&psh->shenviron, envp) 249 if ( !sh_clone_string_vector(psh, &psh->shenviron, envp) 250 && !sh_clone_string_vector(psh, &psh->argptr, argv) 249 251 && !shfile_init(&psh->fdtab, inherit ? &inherit->fdtab : NULL)) 250 252 { … … 916 918 #elif K_OS == K_OS_WINDOWS //&& defined(SH_FORKED_MODE) 917 919 pid = shfork_do_it(psh); 920 # ifdef DEBUG 921 if (!pid) 922 opentrace(psh); 923 # endif 918 924 919 925 #elif defined(SH_STUB_MODE) || defined(SH_FORKED_MODE) … … 928 934 929 935 #endif 936 937 /* child: update the pid */ 938 if (!pid) 939 # ifdef _MSC_VER 940 psh->pid = _getpid(); 941 # else 942 psh->pid = getpid(); 943 # endif 930 944 931 945 TRACE2((psh, "sh_fork -> %d [%d]\n", pid, errno));
Note:
See TracChangeset
for help on using the changeset viewer.