about summary refs log tree commit diff
path: root/src/libstd/sync/mpsc/sync.rs
diff options
context:
space:
mode:
authorwe <vadim.petrochenkov@gmail.com>2015-01-19 08:27:09 +0300
committerwe <vadim.petrochenkov@gmail.com>2015-01-19 08:27:09 +0300
commit2c2480df5d340f4c7b2deeef0177e4fd22f2b03a (patch)
tree0661dc5e07b8142ad1ca02ff4be9320ceaa6b3ba /src/libstd/sync/mpsc/sync.rs
parent378fb5846d2d8dbc5ab24a5e92794c5c39d492dc (diff)
downloadrust-2c2480df5d340f4c7b2deeef0177e4fd22f2b03a.tar.gz
rust-2c2480df5d340f4c7b2deeef0177e4fd22f2b03a.zip
Replace `0 as *const/mut T` with `ptr::null/null_mut()`
Diffstat (limited to 'src/libstd/sync/mpsc/sync.rs')
-rw-r--r--src/libstd/sync/mpsc/sync.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libstd/sync/mpsc/sync.rs b/src/libstd/sync/mpsc/sync.rs
index 30304dffb75..d38f14a9130 100644
--- a/src/libstd/sync/mpsc/sync.rs
+++ b/src/libstd/sync/mpsc/sync.rs
@@ -40,6 +40,7 @@ use self::Blocker::*;
 
 use vec::Vec;
 use core::mem;
+use core::ptr;
 
 use sync::atomic::{Ordering, AtomicUsize};
 use sync::mpsc::blocking::{self, WaitToken, SignalToken};
@@ -145,8 +146,8 @@ impl<T: Send> Packet<T> {
                 cap: cap,
                 canceled: None,
                 queue: Queue {
-                    head: 0 as *mut Node,
-                    tail: 0 as *mut Node,
+                    head: ptr::null_mut(),
+                    tail: ptr::null_mut(),
                 },
                 buf: Buffer {
                     buf: range(0, cap + if cap == 0 {1} else {0}).map(|_| None).collect(),
@@ -160,7 +161,7 @@ impl<T: Send> Packet<T> {
     // wait until a send slot is available, returning locked access to
     // the channel state.
     fn acquire_send_slot(&self) -> MutexGuard<State<T>> {
-        let mut node = Node { token: None, next: 0 as *mut Node };
+        let mut node = Node { token: None, next: ptr::null_mut() };
         loop {
             let mut guard = self.lock.lock().unwrap();
             // are we ready to go?
@@ -343,8 +344,8 @@ impl<T: Send> Packet<T> {
             Vec::new()
         };
         let mut queue = mem::replace(&mut guard.queue, Queue {
-            head: 0 as *mut Node,
-            tail: 0 as *mut Node,
+            head: ptr::null_mut(),
+            tail: ptr::null_mut(),
         });
 
         let waiter = match mem::replace(&mut guard.blocker, NoneBlocked) {
@@ -453,7 +454,7 @@ impl Queue {
     fn enqueue(&mut self, node: &mut Node) -> WaitToken {
         let (wait_token, signal_token) = blocking::tokens();
         node.token = Some(signal_token);
-        node.next = 0 as *mut Node;
+        node.next = ptr::null_mut();
 
         if self.tail.is_null() {
             self.head = node as *mut Node;
@@ -475,10 +476,10 @@ impl Queue {
         let node = self.head;
         self.head = unsafe { (*node).next };
         if self.head.is_null() {
-            self.tail = 0 as *mut Node;
+            self.tail = ptr::null_mut();
         }
         unsafe {
-            (*node).next = 0 as *mut Node;
+            (*node).next = ptr::null_mut();
             Some((*node).token.take().unwrap())
         }
     }