Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
void main() {
int x = 5;
int *p = &x;
int *q = &*p;
*q = 6;
printf("%d\n", x);
}
use std::{cmp, mem, ops, ptr, slice};
use std::marker::PhantomData;
/// A growable vector the width of a single pointer.
///
/// `PointerVec<T>` is similar to the standard `Vec<T>` type, but it stores its length and capacity
/// fields in its heap allocation, rather than inline. This means that the `PointerVec` struct
/// itself only has a single field, the pointer to the heap.
pub struct PointerVec<T> {
ptr: *mut Header,
Rust C C++
Initial buffer file size or 1 MB 16 KB file size*
Buffer growth 8 KB doubling n/a
Max read() buffer size 16 KB 128 B
Work unit 2 KB entire sequence 64 KB

* the C++ code crashes if the input is not a file

extern crate crypto;
extern crate rand;
use crypto::aes;
use crypto::buffer::{ReadBuffer, WriteBuffer, RefReadBuffer, RefWriteBuffer, BufferResult};
use crypto::blockmodes::PkcsPadding;
use rand::{Rng, OsRng};
use std::fs::File;
use std::io;
use std::io::prelude::*;
[package]
name = "workspace"
version = "0.1.0"
authors = ["Matt Brubeck <mbrubeck@limpet.net>"]
[lib]
name = "workspace"
crate-type = ["staticlib"]
[dependencies]
@mbrubeck
mbrubeck / rusty_authz.rs
Created January 24, 2017 18:54
rusty authz
#![feature(libc)]
#![feature(test)]
extern crate libc;
extern crate test;
extern crate seahash;
use std::slice;
use std::ffi::CStr;
use std::panic;
use std::str;
@mbrubeck
mbrubeck / rusty_permission_authorization.rs
Last active January 21, 2017 18:51
A working beta of permission authorization, written in Rust, intended to replace the python implementation in Yosai
#![feature(libc)]
#![feature(test)]
extern crate libc;
extern crate test;
use std::slice;
use std::ffi::CStr;
use std::str;
use libc::{size_t, c_char};
use std::collections::HashSet;
@mbrubeck
mbrubeck / Makefile
Last active January 18, 2017 20:46 — forked from Dowwie/main.py
Experimenting with refactoring permission authorization with a Rust implementation (thus far, a Rust integration is slower)
bench: libauthz.so
python2 main.py
libauthz.so: rusty_authz.rs Makefile
rustc -C opt-level=3 -C lto rusty_authz.rs --crate-type cdylib -o libauthz.so
.PHONY: bench
@mbrubeck
mbrubeck / rust-opt-level-measurements.txt
Last active May 2, 2022 22:35
Rust opt-level measurements
test environment
rustc 1.16.0-nightly (5d994d8b7 2017-01-05)
Thinkpad X1 Carbon Touch (2012)
Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz
cpufreq-set -g performance
no other programs running
all results are after one run to warm up the cache
regex
opt-level = 3