MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / seed_exported_c_string_value

Function seed_exported_c_string_value

src/pglite/postgres_mod.rs:3148–3173  ·  view source on GitHub ↗
(
    store: &mut Store,
    instance: &Instance,
    env: &WasiFunctionEnv,
    name: &str,
    value: &str,
)

Source from the content-addressed store, hash-verified

3146}
3147
3148fn seed_exported_c_string_value(
3149 store: &mut Store,
3150 instance: &Instance,
3151 env: &WasiFunctionEnv,
3152 name: &str,
3153 value: &str,
3154) -> Result<()> {
3155 let Ok(global) = instance.exports.get_global(name) else {
3156 return Ok(());
3157 };
3158 let wasmer::Value::I32(ptr) = global.get(&mut *store) else {
3159 return Ok(());
3160 };
3161 if ptr <= 0 {
3162 return Ok(());
3163 }
3164 let mut bytes = value.as_bytes().to_vec();
3165 bytes.push(0);
3166 let view = env
3167 .data(&*store)
3168 .try_memory_view(&*store)
3169 .context("get WASIX memory view")?;
3170 view.write(ptr as u64, &bytes)
3171 .with_context(|| format!("seed {name} at 0x{ptr:x}"))?;
3172 Ok(())
3173}
3174
3175fn summarize_protocol(bytes: &[u8]) -> String {
3176 if bytes.is_empty() {

Callers 1

Calls 2

pushMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected