{"id":28282685,"url":"https://github.com/barbell-math/smoothbrain-arena","last_synced_at":"2025-06-17T06:31:36.642Z","repository":{"id":289825145,"uuid":"972347759","full_name":"barbell-math/smoothbrain-arena","owner":"barbell-math","description":"A very simple library that implements an arena allocator in 100% golang.","archived":false,"fork":false,"pushed_at":"2025-05-05T01:47:13.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-10T00:47:21.097Z","etag":null,"topics":["arena","arena-allocator","golang","golang-library","golang-package"],"latest_commit_sha":null,"homepage":"","language":"Go","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/barbell-math.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-24T23:49:06.000Z","updated_at":"2025-05-05T01:47:16.000Z","dependencies_parsed_at":"2025-04-25T09:23:07.914Z","dependency_job_id":"6a29f088-05e3-4a98-a67f-a06d1be95c63","html_url":"https://github.com/barbell-math/smoothbrain-arena","commit_stats":null,"previous_names":["barbell-math/smoothbrain-arena"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/barbell-math/smoothbrain-arena","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbell-math%2Fsmoothbrain-arena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbell-math%2Fsmoothbrain-arena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbell-math%2Fsmoothbrain-arena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbell-math%2Fsmoothbrain-arena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barbell-math","download_url":"https://codeload.github.com/barbell-math/smoothbrain-arena/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barbell-math%2Fsmoothbrain-arena/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260306764,"owners_count":22989658,"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":["arena","arena-allocator","golang","golang-library","golang-package"],"created_at":"2025-05-21T15:19:42.050Z","updated_at":"2025-06-17T06:31:36.630Z","avatar_url":"https://github.com/barbell-math.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- gomarkdoc:embed:start --\u003e\n\n\u003c!-- Code generated by gomarkdoc. DO NOT EDIT --\u003e\n\n# sbarena\n\n```go\nimport \"github.com/barbell-math/smoothbrain-arena\"\n```\n\nA very simple library that implements an arena allocator in 100% golang.\n\n## Index\n\n- [Constants](\u003c#constants\u003e)\n- [Variables](\u003c#variables\u003e)\n- [func Alloc\\[T any\\]\\(a \\*Arena\\) \\(weak.Pointer\\[T\\], error\\)](\u003c#Alloc\u003e)\n- [func BucketSizeBytes\\(a \\*Arena\\) uintptr](\u003c#BucketSizeBytes\u003e)\n- [func Clear\\(a \\*Arena\\)](\u003c#Clear\u003e)\n- [func NumBuckets\\(a \\*Arena\\) int](\u003c#NumBuckets\u003e)\n- [func Reset\\(a \\*Arena\\)](\u003c#Reset\u003e)\n- [func TotalMemBytes\\(a \\*Arena\\) uintptr](\u003c#TotalMemBytes\u003e)\n- [type Arena](\u003c#Arena\u003e)\n  - [func NewArena\\(bucketSizeBytes uintptr\\) Arena](\u003c#NewArena\u003e)\n\n\n## Constants\n\n\u003ca name=\"DefaultBlockSize\"\u003e\u003c/a\u003e\n\n```go\nconst (\n    // 64 Kib. The default bucket size used when a bucket size \u003c=0 is supplied\n    // to [NewArena].\n    DefaultBlockSize uintptr = 65536\n)\n```\n\n## Variables\n\n\u003ca name=\"ValueToLargeErr\"\u003e\u003c/a\u003e\n\n```go\nvar (\n    ValueToLargeErr = errors.New(\n        \"The supplied value was to large to place in the arena\",\n    )\n)\n```\n\n\u003ca name=\"Alloc\"\u003e\u003c/a\u003e\n## func [Alloc](\u003chttps://github.com/barbell-math/smoothbrain-arena/blob/main/arena.go#L107\u003e)\n\n```go\nfunc Alloc[T any](a *Arena) (weak.Pointer[T], error)\n```\n\nAllocates enough space in the arena to hold a value of type T. The size of T must be less than the bucket size the allocator was initialized with, otherwise a [ValueToLargeErr](\u003c#ValueToLargeErr\u003e) will be returned.\n\n\u003ca name=\"BucketSizeBytes\"\u003e\u003c/a\u003e\n## func [BucketSizeBytes](\u003chttps://github.com/barbell-math/smoothbrain-arena/blob/main/arena.go#L89\u003e)\n\n```go\nfunc BucketSizeBytes(a *Arena) uintptr\n```\n\nReturns the bucket size for the given arena.\n\n\u003ca name=\"Clear\"\u003e\u003c/a\u003e\n## func [Clear](\u003chttps://github.com/barbell-math/smoothbrain-arena/blob/main/arena.go#L162\u003e)\n\n```go\nfunc Clear(a *Arena)\n```\n\nFrees all of the memory that the arena allocated. Calling this function will cause all other pointers that reference this arenas memory to be set to nil.\n\nThe arena can still be used after this operation, it will allocate more memory as needed. If this arena is used to allocate more memory the old memory will not be reused.\n\n\u003ca name=\"NumBuckets\"\u003e\u003c/a\u003e\n## func [NumBuckets](\u003chttps://github.com/barbell-math/smoothbrain-arena/blob/main/arena.go#L94\u003e)\n\n```go\nfunc NumBuckets(a *Arena) int\n```\n\nGets the number of buckets that the arena has currently allocated.\n\n\u003ca name=\"Reset\"\u003e\u003c/a\u003e\n## func [Reset](\u003chttps://github.com/barbell-math/smoothbrain-arena/blob/main/arena.go#L146\u003e)\n\n```go\nfunc Reset(a *Arena)\n```\n\nResets the internal state of the arena so that it starts to reuse memory, overwriting the memory it previously used.\n\nNo new memory will be allocated and as such all other pointers that reference this arenas memory can still be used, though they are no longer guaranteed to point to valid values.\n\n\u003ca name=\"TotalMemBytes\"\u003e\u003c/a\u003e\n## func [TotalMemBytes](\u003chttps://github.com/barbell-math/smoothbrain-arena/blob/main/arena.go#L100\u003e)\n\n```go\nfunc TotalMemBytes(a *Arena) uintptr\n```\n\nReturns the total number of bytes the arena has allocated across all buckets.\n\n\u003ca name=\"Arena\"\u003e\u003c/a\u003e\n## type [Arena](\u003chttps://github.com/barbell-math/smoothbrain-arena/blob/main/arena.go#L43-L50\u003e)\n\nA dynamic arena allocator that is backed by buckets. Objects that are larger than the bucket size cannot be stored in the area. The bucket size can be specified when calling [NewArena](\u003c#NewArena\u003e).\n\nAn Arena must \\*not\\* be copied by value, this will invalidate the atomics protecting allocation operations.\n\nGo is a GC'ed language, so you cannot control exactly when the GC will free the arena but when it does all of the objects that it stores will be freed along with it. The GC cleaning up the Arena struct is equivalent to freeing all of the memory.\n\nAn Arena is thread safe for allocations and frees, though once the arena is freed all pointers to the data it contained will be invalidated and set to nil.\n\n```go\ntype Arena struct {\n    // contains filtered or unexported fields\n}\n```\n\n\u003ca name=\"NewArena\"\u003e\u003c/a\u003e\n### func [NewArena](\u003chttps://github.com/barbell-math/smoothbrain-arena/blob/main/arena.go#L75\u003e)\n\n```go\nfunc NewArena(bucketSizeBytes uintptr) Arena\n```\n\nCreates a new [Arena](\u003c#Arena\u003e) allocator, initializing it to use \\`bucketSizeBytes\\` bucket size.\n\nGenerated by [gomarkdoc](\u003chttps://github.com/princjef/gomarkdoc\u003e)\n\n\n\u003c!-- gomarkdoc:embed:end --\u003e\n\n## Helpful Developer Cmds\n\nTo build the build system:\n\n```\ngo build -o ./bs/bs ./bs\n```\n\nThe build system can then be used as usual:\n\n```\n./bs/bs --help\n./bs/bs buildbs # Builds the build system!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarbell-math%2Fsmoothbrain-arena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarbell-math%2Fsmoothbrain-arena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarbell-math%2Fsmoothbrain-arena/lists"}