Skip to content

Commit 7d93cc7

Browse files
committed
Add docs
1 parent ace3416 commit 7d93cc7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/shims/env.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use crate::*;
77

88
#[derive(Default)]
99
pub struct EnvVars {
10+
/// Stores pointers to the environment variables. These variables must be stored as
11+
/// null-terminated C strings with the `"{name}={value}"` format.
1012
map: HashMap<Vec<u8>, Pointer<Tag>>,
1113
}
1214

@@ -59,6 +61,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
5961
let name_ptr = this.read_scalar(name_op)?.not_undef()?;
6062
let name = this.memory().read_c_str(name_ptr)?;
6163
Ok(match this.machine.env_vars.map.get(name) {
64+
// The offset is used to strip the "{name}=" part of the string.
6265
Some(var_ptr) => Scalar::Ptr(var_ptr.offset(Size::from_bytes(name.len() as u64 + 1), this)?),
6366
None => Scalar::ptr_null(&*this.tcx),
6467
})

0 commit comments

Comments
 (0)