an efficient binary archive format
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add bindle_read_uncompressed_direct

zach 58fc65f7 31c1f8c9

+32
+4
bindle.h
··· 40 40 41 41 uint8_t *bindle_read(struct BindleContext *ctx, const char *name, size_t *out_len); 42 42 43 + const uint8_t *bindle_read_uncompressed_direct(struct BindleContext *ctx, 44 + const char *name, 45 + size_t *out_len); 46 + 43 47 void bindle_free_buffer(uint8_t *ptr, size_t len); 44 48 45 49 size_t bindle_length(const struct BindleContext *ctx);
+28
src/ffi.rs
··· 108 108 } 109 109 110 110 #[unsafe(no_mangle)] 111 + pub unsafe extern "C" fn bindle_read_uncompressed_direct( 112 + ctx: *mut BindleContext, 113 + name: *const c_char, 114 + out_len: *mut usize, 115 + ) -> *const u8 { 116 + if ctx.is_null() || name.is_null() || out_len.is_null() { 117 + return std::ptr::null_mut(); 118 + } 119 + 120 + unsafe { 121 + let name_str = match CStr::from_ptr(name).to_str() { 122 + Ok(s) => s, 123 + Err(_) => return std::ptr::null_mut(), 124 + }; 125 + 126 + let b = &(*ctx).inner; 127 + if let Some(data) = b.read(name_str) { 128 + match data { 129 + std::borrow::Cow::Borrowed(bytes) => bytes.as_ptr(), 130 + _ => std::ptr::null_mut(), 131 + } 132 + } else { 133 + std::ptr::null_mut() 134 + } 135 + } 136 + } 137 + 138 + #[unsafe(no_mangle)] 111 139 pub unsafe extern "C" fn bindle_free_buffer(ptr: *mut u8, len: usize) { 112 140 if !ptr.is_null() { 113 141 unsafe {