memory: replace most of memory.c with Rust mem #1

Closed
cross wants to merge 0 commits from cross/wmaker:refactor/riir into refactor/riir
Member

Replace wmalloc et al with wrappers around the Rust allocation
library.

Replace `wmalloc` et al with wrappers around the Rust allocation library.
cross added 1 commit 2025-10-14 07:24:21 -04:00
Replace `wmalloc` et al with wrappers around the Rust allocation
library.
Owner

Thank you!

(We're already talking about this elsewhere, but commenting for posterity.)

I had already taken a different approach to writing an allocator (adding a header to each alloc'd chunk) but had not pushed it yet. You have taken the time to locate calls to malloc/free/XFree/etc. that need to be fixed, though, and that's quite helpful. If there's a handy way for me to cherry-pick lines from this patch, I'll try to do that.

Thank you! (We're already talking about this elsewhere, but commenting for posterity.) I had already taken a different approach to writing an allocator (adding a header to each alloc'd chunk) but had not pushed it yet. You have taken the time to locate calls to malloc/free/XFree/etc. that need to be fixed, though, and that's quite helpful. If there's a handy way for me to cherry-pick lines from this patch, I'll try to do that.
Owner

I'm merging this into another branch and will open a PR for that to the main repo, under refactor/wutil-rs.

When you went in and updated calls to malloc/free, did you also look at XFree? That seems to delegate to the stdlib free under the hood.

I'm merging this into another branch and will open a PR for that to the main repo, under refactor/wutil-rs. When you went in and updated calls to malloc/free, did you also look at `XFree`? That seems to delegate to the stdlib `free` under the hood.
Owner

I merged this into another branch to get all the wmalloc/wfree fixes and pulled it in with #2. Thanks again!

I merged this into another branch to get all the `wmalloc`/`wfree` fixes and pulled it in with #2. Thanks again!
trurl closed this pull request 2025-10-25 12:58:01 -04:00
Author
Member

I'm merging this into another branch and will open a PR for that to the main repo, under refactor/wutil-rs.

When you went in and updated calls to malloc/free, did you also look at XFree? That seems to delegate to the stdlib free under the hood.

Oops, sorry; just saw this: I don't think gitea sends email when updates happen.

I did not touch XFree; my theory there is that the X library does its own memory management and wraps around malloc/free, and I don't think we should interpose on that.

> I'm merging this into another branch and will open a PR for that to the main repo, under refactor/wutil-rs. > > When you went in and updated calls to malloc/free, did you also look at `XFree`? That seems to delegate to the stdlib `free` under the hood. Oops, sorry; just saw this: I don't think `gitea` sends email when updates happen. I did not touch XFree; my theory there is that the X library does its own memory management and wraps around `malloc`/`free`, and I don't think we should interpose on that.
Owner

RE calls to XFree: there are definite instances of (w)malloc'd pointers being passed to XFree. I'm cleaning them up as I find them.

RE calls to `XFree`: there are definite instances of (w)malloc'd pointers being passed to `XFree`. I'm cleaning them up as I find them.

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitrine/wmaker#1