https://github.com/yohhoy/malloc-server
malloc REST Server
https://github.com/yohhoy/malloc-server
go golang jokes-api rest-api
Last synced: 3 months ago
JSON representation
malloc REST Server
- Host: GitHub
- URL: https://github.com/yohhoy/malloc-server
- Owner: yohhoy
- License: mit
- Created: 2025-03-20T16:39:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-28T10:17:20.000Z (about 1 year ago)
- Last Synced: 2025-09-12T19:08:33.113Z (9 months ago)
- Topics: go, golang, jokes-api, rest-api
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# malloc-server
[](https://github.com/yohhoy/malloc-server/actions/workflows/test.yml)
[](LICENSE)
malloc REST Server - A RESTful server that allows you to allocate(`malloc`)/deallocate(`free`) memory blocks, and perform byte-wise read/write operation on memory address via an HTTP interface.
## Demo
```sh
$ go build
$ GIN_MODE=release ./malloc-server
$ ADDR=$(curl -X POST -s http://localhost:8080/memory/malloc -d '{"size":10}' | jq .addr)
$ echo $ADDR
$ curl -X PUT -s http://localhost:8080/memory/$ADDR -d '{"val":123}'
$ curl -X GET -s http://localhost:8080/memory/$ADDR | jq .val
$ curl -X POST -s http://localhost:8080/memory/free -d "{\"addr\":$ADDR}"
```
Try following client implementation.
- [yohhoy/malloc-client-cpp](https://github.com/yohhoy/malloc-client-cpp) - C++
## API
```
POST /memory/malloc
Req {"size": }
Resp {"addr": , "size": }
POST /memory/free
Req {"addr": }
Resp (none)
PUT /memory/:addr
Req {"val": <0-255>}
Resp (none)
GET /memory/:addr
Req (none)
Resp {"val": <0-255>}
```
## Security Considerations
The memory management of this server is sandboxed and utilizes "virtual" addresses to represent memory locations. Therefore, clients can NEVER access arbitrary memory on the host machine.
However, note that if a malicious client makes an excessive number of memory allocation requests, the host system's memory may become exhausted.
# License
MIT License