Changeset 481 for trunk/src/sh_fifo.c
- Timestamp:
- Jul 18, 2015, 5:06:52 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_fifo.c
r272 r481 180 180 memset(getit->data, 0, len); 181 181 if (NULL != sl_strstr (getit->data, _("LOGKEY"))) 182 { 183 MUNLOCK(getit->data, (len+1)); 184 ; 185 } 182 MUNLOCK(getit->data, (len+1)); 186 183 if (getit->s_xtra) 187 184 SH_FREE(getit->s_xtra); … … 197 194 /* push an item on the head of the list 198 195 */ 199 int push_list (SH_FIFO * fifo, c har * indat, int in_i, const char * in_str)196 int push_list (SH_FIFO * fifo, const char * indat, int in_i, const char * in_str) 200 197 { 201 198 struct dlist * item; … … 224 221 225 222 if (NULL != sl_strstr (indat, _("LOGKEY"))) 226 { 227 MLOCK(item->data, (len+1)); 228 ; 229 } 223 MLOCK(item->data, (len+1)); 230 224 231 225 sl_strlcpy (item->data, indat, len+1); … … 260 254 /* push an item on the tail of the list 261 255 */ 262 int push_tail_list (SH_FIFO * fifo, c har * indat, int in_i, const char * in_str)256 int push_tail_list (SH_FIFO * fifo, const char * indat, int in_i, const char * in_str) 263 257 { 264 258 struct dlist * item; … … 287 281 288 282 if (NULL != sl_strstr (indat, _("LOGKEY"))) 289 { 290 MLOCK(item->data, (len+1)); 291 ; 292 } 283 MLOCK(item->data, (len+1)); 293 284 294 285 sl_strlcpy (item->data, indat, len+1); … … 318 309 ++(fifo->fifo_cts); 319 310 320 SL_RETURN(( 0), _("push_tail_list"));311 SL_RETURN((fifo->fifo_cts), _("push_tail_list")); 321 312 } 322 313 … … 356 347 357 348 if (NULL != sl_strstr (retval, _("LOGKEY"))) 358 { 359 MUNLOCK(getit->data, (len+1)); 360 ; 361 } 349 MUNLOCK(getit->data, (len+1)); 362 350 363 351 if (getit->s_xtra) … … 372 360 373 361 374 375 362 #ifdef SH_CUTEST 363 #include "CuTest.h" 364 365 void Test_fifo (CuTest *tc) { 366 367 SH_FIFO ff; 368 int ret; 369 char * p; 370 371 fifo_init(&ff); 372 373 p = sh_fifo_pop(&ff); 374 CuAssertPtrEquals(tc, NULL, p); 375 376 /* first sequence */ 377 ret = sh_fifo_push(&ff, "one"); 378 CuAssertIntEquals(tc,1,ret); 379 ret = sh_fifo_push(&ff, "two"); 380 CuAssertIntEquals(tc,2,ret); 381 ret = sh_fifo_push(&ff, "three"); 382 CuAssertIntEquals(tc,3,ret); 383 384 p = sh_fifo_pop(&ff); 385 CuAssertPtrNotNull(tc, p); 386 CuAssertStrEquals(tc,"one", p); 387 p = sh_fifo_pop(&ff); 388 CuAssertPtrNotNull(tc, p); 389 CuAssertStrEquals(tc,"two", p); 390 p = sh_fifo_pop(&ff); 391 CuAssertPtrNotNull(tc, p); 392 CuAssertStrEquals(tc,"three", p); 393 p = sh_fifo_pop(&ff); 394 CuAssertPtrEquals(tc, NULL, p); 395 396 /* second sequence */ 397 ret = sh_fifo_push(&ff, "one"); 398 CuAssertIntEquals(tc,1,ret); 399 p = sh_fifo_pop(&ff); 400 CuAssertPtrNotNull(tc, p); 401 CuAssertStrEquals(tc,"one", p); 402 ret = sh_fifo_push_tail(&ff, "one"); 403 CuAssertIntEquals(tc,1,ret); 404 p = sh_fifo_pop(&ff); 405 CuAssertPtrNotNull(tc, p); 406 CuAssertStrEquals(tc,"one", p); 407 p = sh_fifo_pop(&ff); 408 CuAssertPtrEquals(tc, NULL, p); 409 410 /* third sequence */ 411 ret = sh_fifo_push(&ff, "one"); 412 CuAssertIntEquals(tc,1,ret); 413 ret = sh_fifo_push(&ff, "two"); 414 CuAssertIntEquals(tc,2,ret); 415 ret = sh_fifo_push(&ff, "three"); 416 CuAssertIntEquals(tc,3,ret); 417 418 p = sh_fifo_pop(&ff); 419 CuAssertPtrNotNull(tc, p); 420 CuAssertStrEquals(tc,"one", p); 421 ret = sh_fifo_push_tail(&ff, p); 422 CuAssertIntEquals(tc,3,ret); 423 424 p = sh_fifo_pop(&ff); 425 CuAssertPtrNotNull(tc, p); 426 CuAssertStrEquals(tc,"one", p); 427 p = sh_fifo_pop(&ff); 428 CuAssertPtrNotNull(tc, p); 429 CuAssertStrEquals(tc,"two", p); 430 p = sh_fifo_pop(&ff); 431 CuAssertPtrNotNull(tc, p); 432 CuAssertStrEquals(tc,"three", p); 433 p = sh_fifo_pop(&ff); 434 CuAssertPtrEquals(tc, NULL, p); 435 } 436 437 #endif 438 439 440 441
Note:
See TracChangeset
for help on using the changeset viewer.