---
name: "SDL_IOFromConstMem"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_IOFromConstMem"
---

# SDL\_IOFromConstMem(3)

Use this function to prepare a read-only memory buffer for use with SDL\_IOStream .

## NAME

SDL\_IOFromConstMem - Use this function to prepare a read-only memory buffer for use with  **SDL\_IOStream** .

## HEADER FILE

Defined in SDL3/SDL\_iostream.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**SDL\_IOStream \* SDL\_IOFromConstMem(const void \*mem, size\_t size);**

## DESCRIPTION

This function sets up an  **SDL\_IOStream**\
  struct based on a memory area of a certain size. It assumes the memory area is not writable.

Attempting to write to this  **SDL\_IOStream**\
  stream will report an error without writing to the memory buffer.

This memory buffer is not copied by the  **SDL\_IOStream** ; the pointer you provide must remain valid until you close the stream. Closing the stream will not free the original buffer.

If you need to write to a memory buffer, you should use

**SDL\_IOFromMem** () with a writable buffer of memory instead.

The following properties will be set at creation time by SDL:

•  **SDL\_PROP\_IOSTREAM\_MEMORY\_POINTER** :\
   this will be the **mem** parameter that was passed to this function.

•  **SDL\_PROP\_IOSTREAM\_MEMORY\_SIZE\_NUMBER** :\
   this will be the **size** parameter that was passed to this function.

## FUNCTION PARAMETERS

- *mem*

  a pointer to a read-only buffer to feed an  **SDL\_IOStream**\
    stream.

- *size*

  the buffer size, in bytes.

## RETURN VALUE

( **SDL\_IOStream**\
  \*) Returns a pointer to a new

**SDL\_IOStream**\
  structure or NULL on failure; call

**SDL\_GetError** () for more information.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_IOFromMem**(3)](/SDL_IOFromMem/3.md), **•**(3), [**SDL\_CloseIO**(3)](/SDL_CloseIO/3.md), **•**(3), [**SDL\_ReadIO**(3)](/SDL_ReadIO/3.md), **•**(3), [**SDL\_SeekIO**(3)](/SDL_SeekIO/3.md), **•**(3), [**SDL\_TellIO**(3)](/SDL_TellIO/3.md)
