Changeset 2290 for trunk/src/kash/shinstance.c
- Timestamp:
- Feb 27, 2009, 5:08:07 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/shinstance.c
r2289 r2290 169 169 { 170 170 memset(psh, 0, sizeof(*psh)); 171 free(psh);171 sh_free(NULL, psh); 172 172 } 173 173 … … 190 190 191 191 /* alloc clone array. */ 192 *dstp = dst = malloc(sizeof(*dst) * items + 1);192 *dstp = dst = sh_malloc(NULL, sizeof(*dst) * items + 1); 193 193 if (!dst) 194 194 return -1; … … 198 198 while (items-- > 0) 199 199 { 200 dst[items] = s trdup(src[items]);200 dst[items] = sh_strdup(NULL, src[items]); 201 201 if (!dst[items]) 202 202 { 203 203 /* allocation error, clean up. */ 204 204 while (dst[++items]) 205 free(dst[items]);206 free(dst);205 sh_free(NULL, dst[items]); 206 sh_free(NULL, dst); 207 207 errno = ENOMEM; 208 208 return -1; … … 231 231 * The allocations. 232 232 */ 233 psh = calloc(sizeof(*psh), 1);233 psh = sh_calloc(NULL, sizeof(*psh), 1); 234 234 if (psh) 235 235 { … … 344 344 345 345 return ret; 346 } 347 348 /** malloc() */ 349 void *sh_malloc(shinstance *psh, size_t size) 350 { 351 (void)psh; 352 return malloc(size); 353 } 354 355 /** calloc() */ 356 void *sh_calloc(shinstance *psh, size_t num, size_t size) 357 { 358 (void)psh; 359 return calloc(num, size); 360 } 361 362 /** realloc() */ 363 void *sh_realloc(shinstance *psh, void *old, size_t new_size) 364 { 365 return realloc(old, new_size); 366 } 367 368 /** strdup() */ 369 char *sh_strdup(shinstance *psh, const char *string) 370 { 371 size_t len = strlen(string); 372 char *ret = sh_malloc(psh, len + 1); 373 if (ret) 374 memcpy(ret, string, len + 1); 375 return ret; 376 } 377 378 /** free() */ 379 void sh_free(shinstance *psh, void *ptr) 380 { 381 if (ptr) 382 free(ptr); 383 (void)psh; 346 384 } 347 385
Note:
See TracChangeset
for help on using the changeset viewer.