ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.361 by root, Sun Oct 24 19:01:01 2010 UTC vs.
Revision 1.365 by root, Sun Oct 31 22:01:20 2010 UTC

591 if (syserr_cb) 591 if (syserr_cb)
592 syserr_cb (msg); 592 syserr_cb (msg);
593 else 593 else
594 { 594 {
595#if EV_AVOID_STDIO 595#if EV_AVOID_STDIO
596 const char *err = strerror (errno);
597
598 ev_printerr (msg); 596 ev_printerr (msg);
599 ev_printerr (": "); 597 ev_printerr (": ");
600 ev_printerr (err); 598 ev_printerr (strerror (errno));
601 ev_printerr ("\n"); 599 ev_printerr ("\n");
602#else 600#else
603 perror (msg); 601 perror (msg);
604#endif 602#endif
605 abort (); 603 abort ();
639 ptr = alloc (ptr, size); 637 ptr = alloc (ptr, size);
640 638
641 if (!ptr && size) 639 if (!ptr && size)
642 { 640 {
643#if EV_AVOID_STDIO 641#if EV_AVOID_STDIO
644 ev_printerr ("libev: memory allocation failed, aborting.\n"); 642 ev_printerr ("(libev) memory allocation failed, aborting.\n");
645#else 643#else
646 fprintf (stderr, "libev: cannot allocate %ld bytes, aborting.", size); 644 fprintf (stderr, "(libev) cannot allocate %ld bytes, aborting.", size);
647#endif 645#endif
648 abort (); 646 abort ();
649 } 647 }
650 648
651 return ptr; 649 return ptr;
1735/* free up a loop structure */ 1733/* free up a loop structure */
1736void 1734void
1737ev_loop_destroy (EV_P) 1735ev_loop_destroy (EV_P)
1738{ 1736{
1739 int i; 1737 int i;
1738
1739#if EV_MULTIPLICITY
1740 /* mimic free (0) */
1741 if (!EV_A)
1742 return;
1743#endif
1740 1744
1741#if EV_CLEANUP_ENABLE 1745#if EV_CLEANUP_ENABLE
1742 /* queue cleanup watchers (and execute them) */ 1746 /* queue cleanup watchers (and execute them) */
1743 if (expect_false (cleanupcnt)) 1747 if (expect_false (cleanupcnt))
1744 { 1748 {
3592 3596
3593 ev_start (EV_A_ (W)w, ++cleanupcnt); 3597 ev_start (EV_A_ (W)w, ++cleanupcnt);
3594 array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2); 3598 array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2);
3595 cleanups [cleanupcnt - 1] = w; 3599 cleanups [cleanupcnt - 1] = w;
3596 3600
3601 /* cleanup watchers should never keep a refcount on the loop */
3602 ev_unref (EV_A);
3597 EV_FREQUENT_CHECK; 3603 EV_FREQUENT_CHECK;
3598} 3604}
3599 3605
3600void 3606void
3601ev_cleanup_stop (EV_P_ ev_cleanup *w) 3607ev_cleanup_stop (EV_P_ ev_cleanup *w)
3603 clear_pending (EV_A_ (W)w); 3609 clear_pending (EV_A_ (W)w);
3604 if (expect_false (!ev_is_active (w))) 3610 if (expect_false (!ev_is_active (w)))
3605 return; 3611 return;
3606 3612
3607 EV_FREQUENT_CHECK; 3613 EV_FREQUENT_CHECK;
3614 ev_ref (EV_A);
3608 3615
3609 { 3616 {
3610 int active = ev_active (w); 3617 int active = ev_active (w);
3611 3618
3612 cleanups [active - 1] = cleanups [--cleanupcnt]; 3619 cleanups [active - 1] = cleanups [--cleanupcnt];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines