{"id":13805452,"url":"https://github.com/jdonnerstag/vlang-mmap","last_synced_at":"2025-05-13T19:31:07.633Z","repository":{"id":139622406,"uuid":"368254011","full_name":"jdonnerstag/vlang-mmap","owner":"jdonnerstag","description":"Provide memory mapping functionality to v-lang","archived":false,"fork":false,"pushed_at":"2021-06-21T06:45:53.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-18T21:47:44.669Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"V","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdonnerstag.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-05-17T16:33:17.000Z","updated_at":"2024-11-14T15:16:17.000Z","dependencies_parsed_at":"2023-04-23T22:30:38.791Z","dependency_job_id":null,"html_url":"https://github.com/jdonnerstag/vlang-mmap","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonnerstag%2Fvlang-mmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonnerstag%2Fvlang-mmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonnerstag%2Fvlang-mmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdonnerstag%2Fvlang-mmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdonnerstag","download_url":"https://codeload.github.com/jdonnerstag/vlang-mmap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254012968,"owners_count":21999346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:01:01.293Z","updated_at":"2025-05-13T19:31:07.303Z","avatar_url":"https://github.com/jdonnerstag.png","language":"V","funding_links":[],"categories":["Libraries"],"sub_categories":["Operating system"],"readme":"# Memory Mapping support for [V-lang](https://vlang.io)\n\nInspired by [mman-win32](https://github.com/alitrack/mman-win32), this module\nprovides [V-lang](https://vlang.io) with easy to use memory mapping support. \n\n## Key Features\n\n- Supports Linux and Windows\n- Consistent public API for Linux and Windows\n- V-lang like error handling\n\n## API\n\n```v\n\tpub fn mmap(args MmapOptions) ?voidptr\n\tpub fn munmap(addr voidptr, len u64) ?\n\tpub fn mprotect(addr voidptr, len u64, prot int) ?\n\tpub fn msync(addr voidptr, len u64, flags int) ?\n\tpub fn mlock(addr voidptr, len u64) ?\n\tpub fn munlock(addr voidptr, len u64) ? \n```\n\nAdditionally\n\n```v\n\t// Cast the memory mapped region to a byte array\n\tpub fn to_byte_array(addr voidptr, len u64) []byte {\n```\n\nand\n```v\n\t// Open a file (binary, read-only) and map its content into memory \n\tpub fn mmap_file(file string) ?MmapInfo {\n\n\t// Release the memory mapped region and close the file\n\tpub fn (mut this MmapInfo) close() {\n```\n\n## Example\n\n```v\nimport mmap\n\nfn main() {\n\tbig_file_path := '../../MY_BIG_FILE.20180119104659.A901'\n\tmut minfo := mmap.mmap_file(big_file_path)?\n\tdefer { minfo.close() }\n\n\tb := minfo.bytes\n\teprintln('src: $minfo.src')\n\teprintln('b.len after: $b.len')\n\teprintln('b starts with:')\n\teprintln(b[0..64].hex())\n\n\tdefer { eprintln('finished') }\n}\n\n/*\nhome: $ ./v run ./mmap_example.v\nsrc: 0000000000B30000\nb.len before: 0\nb.len after: 2096582968\nb starts with:\n20202020203130303031324b64697077696d6c79676f716a6d712038205720202020202020202020202020202020202020202020202020202020202020202020\nfinished\n*/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdonnerstag%2Fvlang-mmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdonnerstag%2Fvlang-mmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdonnerstag%2Fvlang-mmap/lists"}