printers 2.3.0

Get printers and print files on unix and windows
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use libc::c_ulong;
use std::alloc::{Layout, alloc, dealloc};

fn _ptr_layout<T>(size: usize) -> Layout {
    unsafe { Layout::from_size_align_unchecked(size, align_of::<T>()) }
}

pub fn alloc_s<T>(size: c_ulong) -> *mut T {
    unsafe { alloc(_ptr_layout::<T>(size as usize)) as *mut T }
}

pub fn dealloc_s<T>(ptr: *const T) {
    let layout = _ptr_layout::<T>(size_of::<T>());
    unsafe { dealloc(ptr as *mut u8, layout) };
}