Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blitz.mod] Expose MemSet() or extend MemClear() to allow specific values #290

Open
GWRon opened this issue Aug 15, 2023 · 0 comments
Open

Comments

@GWRon
Copy link
Contributor

GWRon commented Aug 15, 2023

The current implementation of MemClear() is

blitz.mod/blitz.bmx

Rem
bbdoc: Clear a block of memory to 0
End Rem
Function MemClear( mem:Byte Ptr,size:Size_T )="void bbMemClear( void *,size_t )"

blitz.mod/blitz_memory.c:

void bbMemClear( void *dst,size_t size ){
	memset( dst,0,size );
}

In other words it internally already uses "MemSet()" but with a fixed byte value of 0.

I would kindly request to expose "MemSet" too (so bbMemSet or so).
As this is only for "bytes" ("char") I think we would need (most often) a 32bit version too ... or also 64bit?
Inside of BlitzMax we could expose it overloaded

MemSet(mem:Byte Ptr, value:Byte, size:Size_T)
MemSet(mem:Byte Ptr, value:Int, size:Size_T)
MemSet(mem:Byte Ptr, value:Long, size:Size_T)

but would need to care for "left over" bytes (a size which is not a multiple of the value size)
(for now I would prefer a "if it does not fit into anymore, keep it untouched")

Approaches:
https://stackoverflow.com/questions/108866/is-there-memset-that-accepts-integers-larger-than-char

The idea is to allow speeding up eg. "writepixel"-blocks in TPixmap objects.
https://www.syntaxbomb.com/blitzmax-blitzmax-ng/faster-pixmap/new/#new

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant