Переглянути джерело

src/lib.rs, README.md: fix leftovers from vectors-to-slices transition

Quentin Monnet 8 роки тому
батько
коміт
a93ae13273
2 змінених файлів з 20 додано та 20 видалено
  1. 12 12
      README.md
  2. 8 8
      src/lib.rs

+ 12 - 12
README.md

@@ -131,18 +131,18 @@ All these structs implement the same public functions:
 
 ```rust
 // called with EbpfVmMbuff:: prefix
-pub fn new(prog: &'a std::vec::Vec<u8>) -> EbpfVmMbuff<'a>
+pub fn new(prog: &'a [u8]) -> EbpfVmMbuff<'a>
 
 // called with EbpfVmFixedMbuff:: prefix
-pub fn new(prog: &'a std::vec::Vec<u8>,
+pub fn new(prog: &'a [u8],
            data_offset: usize,
            data_end_offset: usize) -> EbpfVmFixedMbuff<'a>
 
 // called with EbpfVmRaw:: prefix
-pub fn new(prog: &'a std::vec::Vec<u8>) -> EbpfVmRaw<'a>
+pub fn new(prog: &'a [u8]) -> EbpfVmRaw<'a>
 
 // called with EbpfVmNoData:: prefix
-pub fn new(prog: &'a std::vec::Vec<u8>) -> EbpfVmNoData<'a>
+pub fn new(prog: &'a [u8]) -> EbpfVmNoData<'a>
 ```
 
 This is used to create a new instance of a VM. The return type is dependent of
@@ -160,10 +160,10 @@ do not need those offsets.
 
 ```rust
 // for struct EbpfVmMbuff, struct EbpfVmRaw and struct EbpfVmRawData
-pub fn set_prog(&mut self, prog: &'a std::vec::Vec<u8>)
+pub fn set_prog(&mut self, prog: &'a [u8])
 
 // for struct EbpfVmFixedMbuff
-pub fn set_prog(&mut self, prog: &'a std::vec::Vec<u8>,
+pub fn set_prog(&mut self, prog: &'a [u8],
                 data_offset: usize,
                 data_end_offset: usize)
 ```
@@ -186,12 +186,12 @@ therefore must use specific helper numbers.
 ```rust
 // for struct EbpfVmMbuff
 pub fn prog_exec(&self,
-                 mem: &'a mut std::vec::Vec<u8>,
-                 mbuff: &'a mut std::vec::Vec<u8>) -> u64
+                 mem: &'a mut [u8],
+                 mbuff: &'a mut [u8]) -> u64
 
 // for struct EbpfVmFixedMbuff and struct EbpfVmRaw
 pub fn prog_exec(&self,
-                 mem: &'a mut std::vec::Vec<u8>) -> u64
+                 mem: &'a mut [u8]) -> u64
 
 // for struct EbpfVmNoData
 pub fn prog_exec(&self) -> u64
@@ -212,11 +212,11 @@ is called. The generated assembly function is internally stored in the VM.
 
 ```rust
 // for struct EbpfVmMbuff
-pub unsafe fn prog_exec_jit(&self, mem: &'a mut std::vec::Vec<u8>,
-                            mbuff: &'a mut std::vec::Vec<u8>) -> u64
+pub unsafe fn prog_exec_jit(&self, mem: &'a mut [u8],
+                            mbuff: &'a mut [u8]) -> u64
 
 // for struct EbpfVmFixedMbuff and struct EbpfVmRaw
-pub unsafe fn prog_exec_jit(&self, mem: &'a mut std::vec::Vec<u8>) -> u64
+pub unsafe fn prog_exec_jit(&self, mem: &'a mut [u8]) -> u64
 
 // for struct EbpfVmNoData
 pub unsafe fn prog_exec_jit(&self) -> u64

+ 8 - 8
src/lib.rs

@@ -566,10 +566,10 @@ impl<'a> EbpfVmMbuff<'a> {
     /// }
     /// ```
     pub unsafe fn prog_exec_jit(&self, mem: &mut [u8], mbuff: &'a mut [u8]) -> u64 {
-        // If packet data is empty, do not send the address of an empty vector; send a null
-        // pointer (zero value) as first argument instead, as this is uBPF's behavior (empty
-        // packet should not happen in the kernel; anyway the verifier would prevent the use of
-        // uninitialized registers). See `mul_loop` test.
+        // If packet data is empty, do not send the address of an empty slice; send a null pointer
+        // (zero value) as first argument instead, as this is uBPF's behavior (empty packet should
+        // not happen in the kernel; anyway the verifier would prevent the use of uninitialized
+        // registers). See `mul_loop` test.
         let mem_ptr = match mem.len() {
             0 => 0 as *mut u8,
             _ => mem.as_ptr() as *mut u8
@@ -919,10 +919,10 @@ impl<'a> EbpfVmFixedMbuff<'a> {
     // This struct redefines the `prog_exec_jit()` function, in order to pass the offsets
     // associated with the fixed mbuff.
     pub unsafe fn prog_exec_jit(&mut self, mem: &'a mut [u8]) -> u64 {
-        // If packet data is empty, do not send the address of an empty vector; send a null
-        // pointer (zero value) as first argument instead, as this is uBPF's behavior (empty
-        // packet should not happen in the kernel; anyway the verifier would prevent the use of
-        // uninitialized registers). See `mul_loop` test.
+        // If packet data is empty, do not send the address of an empty slice; send a null pointer
+        // (zero value) as first argument instead, as this is uBPF's behavior (empty packet should
+        // not happen in the kernel; anyway the verifier would prevent the use of uninitialized
+        // registers). See `mul_loop` test.
         let mem_ptr = match mem.len() {
             0 => 0 as *mut u8,
             _ => mem.as_ptr() as *mut u8