On this page
ctypes.memset
Prev: ctypes.memoryview_at | Up: ctypes | Next: ctypes.pointer
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.memset
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import memset
Signature & Overview
ctypes.memset(*args, **kwargs)
ctypes.memset() function.
Usage
import ctypes
buf = ctypes.create_string_buffer(4)
ctypes.memset(buf, ord("A"), 4)
assert buf.raw == b"AAAA"
Gotchas
- Fills raw bytes: Commonly used to zero out buffers (
ctypes.memset(buf, 0, ctypes.sizeof(buf))).
REPL Inspect
from ctypes import memset
help(memset)
Linked from
Related notes
- tuts/python3/stdlib_module/ctypes/memoryview_at Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/pointer Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ctypes/addressof Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/alignment Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/ArgumentError Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/Array Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianStructure shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianUnion shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/byref shared tags: #ctypes, #stdlib