- Timestamp:
- Dec 4, 2011, 6:26:15 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_fInotify.c
r376 r382 167 167 { 168 168 ssize_t len = -1; 169 char * buffer = SH_ALLOC(16384);169 char * buffer; 170 170 static int count = 0; 171 171 static int count2 = 0; 172 172 173 173 if (ShfInotifyActive == S_FALSE) 174 return SH_MOD_FAILED; 174 { 175 return SH_MOD_FAILED; 176 } 175 177 176 178 if ( (sh.flag.inotify & SH_INOTIFY_DOSCAN) || … … 178 180 { 179 181 if (0 != sh_fInotify_init_internal()) 180 return SH_MOD_FAILED; 181 } 182 { 183 return SH_MOD_FAILED; 184 } 185 } 186 187 buffer = SH_ALLOC(16384); 182 188 183 189 /* Blocking read from inotify file descriptor. … … 203 209 { 204 210 if (0 != sh_fInotify_init_internal()) 205 return SH_MOD_FAILED; 211 { 212 SH_FREE(buffer); 213 return SH_MOD_FAILED; 214 } 206 215 } 207 216 } … … 230 239 } 231 240 241 SH_FREE(buffer); 232 242 return 0; 233 243 } … … 371 381 } 372 382 } 383 SH_FREE(filename); 373 384 } 374 385 -
trunk/src/sh_inotify.c
r377 r382 246 246 } 247 247 248 static sh_watch * sh_inotify_create_watch(const char * file, int nwatch, int flag) 248 static sh_watch * sh_inotify_create_watch(const char * file, 249 int nwatch, int flag) 249 250 { 250 251 sh_watch * this = SH_ALLOC(sizeof(sh_watch)); 251 252 252 this->file = sh_util_strdup (file);253 this->file = sh_util_strdup_track(file, __FILE__, __LINE__); 253 254 this->watch = nwatch; 254 255 this->flag = flag; … … 378 379 *rdepth = this->watch->rdepth; 379 380 *check_mask = this->watch->check_mask; 380 popret = sh_util_strdup (this->watch->file);381 popret = sh_util_strdup_track(this->watch->file, __FILE__, __LINE__); 381 382 382 383 watches->dormant_watches = this->next; … … 477 478 int sh_inotify_add_watch_later(const char * filename, sh_watches * watches, 478 479 int * errnum, 479 int class, unsigned long check_mask, int type, int rdepth) 480 int class, unsigned long check_mask, int type, 481 int rdepth) 480 482 { 481 483 sh_watch * item; … … 645 647 { 646 648 *errnum = ENOMEM; 649 sh_inotify_free_watch(item); 647 650 retval = -1; 648 651 goto retpoint; … … 694 697 *type = item->type; 695 698 *rdepth = item->rdepth; 696 sret = sh_util_strdup (item->file);699 sret = sh_util_strdup_track(item->file, __FILE__, __LINE__); 697 700 } 698 701 SH_MUTEX_UNLOCK(mutex_watches); -
trunk/src/sh_utils.c
r373 r382 329 329 if (0 == strncmp((char *) p, "user", 4)) { 330 330 out[rem] = 'u'; ++rem; 331 p += 3; state = 1;331 p += 3; 332 332 } else if (0 == strncmp((char *) p, "group", 5)) { 333 333 out[rem] = 'g'; ++rem; 334 p += 4; state = 1;334 p += 4; 335 335 } else if (0 == strncmp((char *) p, "mask", 4)) { 336 336 out[rem] = 'm'; ++rem; 337 p += 3; state = 1;337 p += 3; 338 338 } else if (0 == strncmp((char *) p, "other", 5)) { 339 339 out[rem] = 'o'; 340 p += 4; state = 1;++rem;340 p += 4; ++rem; 341 341 } else if (*p == '\0') { 342 342 if (rem > 0) { out[rem-1] = '\0'; } … … 366 366 SH_VALIDATE_NE(len, 0); 367 367 368 if (s l_ok_adds (len, 1))368 if (str && sl_ok_adds (len, 1)) 369 369 { 370 370 p = SH_ALLOC (len + 1); … … 387 387 SH_VALIDATE_NE(str, NULL); 388 388 389 len = sl_strlen(str); 390 p = SH_ALLOC (len + 1); 391 (void) memcpy (p, str, len+1); 392 389 if (str) 390 { 391 len = sl_strlen(str); 392 p = SH_ALLOC (len + 1); 393 (void) memcpy (p, str, len+1); 394 } 393 395 SL_RETURN( p, _("sh_util_strdup")); 396 } 397 398 char * sh_util_strdup_track (const char * str, char * file, int line) 399 { 400 char * p = NULL; 401 size_t len; 402 403 SL_ENTER(_("sh_util_strdup_track")); 404 405 SH_VALIDATE_NE(str, NULL); 406 407 if (str) 408 { 409 len = sl_strlen(str); 410 p = SH_OALLOC (len + 1, file, line); 411 (void) memcpy (p, str, len+1); 412 } 413 SL_RETURN( p, _("sh_util_strdup_track")); 394 414 } 395 415 … … 407 427 SH_VALIDATE_NE(ret, NULL); 408 428 409 for (c = *str; *c != '\0'; c++) { 410 for (d = delim; *d != '\0'; d++) { 411 if (*c == *d) { 412 *c = '\0'; 413 *str = c + 1; 414 SL_RETURN(ret, _("sh_util_strsep")); 429 if (*str) 430 { 431 for (c = *str; *c != '\0'; c++) { 432 for (d = delim; *d != '\0'; d++) { 433 if (*c == *d) { 434 *c = '\0'; 435 *str = c + 1; 436 SL_RETURN(ret, _("sh_util_strsep")); 437 } 438 } 415 439 } 416 440 } 417 }418 441 419 442 /* If we get to here, there's no delimiters in the string */ … … 1960 1983 } 1961 1984 1962 c = strrchr(tmp2, '/'); 1963 if (c) 1964 { 1965 retval = sh_util_strdup(++c); 1966 SH_FREE(tmp2); 1967 } 1968 else 1969 { 1970 retval = tmp2; 1985 if (tmp2) /* for llvm/clang analyzer */ 1986 { 1987 c = strrchr(tmp2, '/'); 1988 if (c) 1989 { 1990 retval = sh_util_strdup(++c); 1991 SH_FREE(tmp2); 1992 } 1993 else 1994 { 1995 retval = tmp2; 1996 } 1971 1997 } 1972 1998 }
Note:
See TracChangeset
for help on using the changeset viewer.