Skip to content
forked from Snaipe/fmem

A cross-platform library for opening memory-backed libc streams.

License

Notifications You must be signed in to change notification settings

cpp-testing/fmem

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fmem

Unix Build Status Windows Build Status

A cross-platform library for opening memory-backed libc streams.

This library was written for Criterion to implement stringification functions for user-defined types.

Rationale

C doesn't define any way to open "virtual" streams that write to memory rather than a real file. A lot of libc implementations roll their own nonstandard mechanisms to achieve this, namely open_memstream, or fmemopen. Other implementations provide more generic functions to call users functions for various operations on the file, like funopen or fopencookie. Finally, some implementations support none of these nonstandard functions.

fmem tries in sequence the following implementations:

  • open_memstream.
  • fopencookie, with growing dynamic buffer.
  • funopen, with growing dynamic buffer.
  • WinAPI temporary memory-backed file.

When no other mean is available, fmem falls back to tmpfile().

About

A cross-platform library for opening memory-backed libc streams.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 71.2%
  • CMake 28.8%