mirror of
https://gitlab.freedesktop.org/emersion/libdisplay-info.git
synced 2024-11-16 19:48:30 +01:00
memory-stream: Add memory_stream_cleanup helper
Signed-off-by: Joshua Ashton <joshua@froggi.es>
This commit is contained in:
parent
a10c478558
commit
c63ca40ef7
2 changed files with 14 additions and 0 deletions
|
@ -21,4 +21,12 @@ memory_stream_open(struct memory_stream *m);
|
||||||
char *
|
char *
|
||||||
memory_stream_close(struct memory_stream *m);
|
memory_stream_close(struct memory_stream *m);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A small cleanup helper that simply
|
||||||
|
* calls free(memory_stream_close(m)) to avoid
|
||||||
|
* any dangling string pointers in cleanup/error paths.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
memory_stream_cleanup(struct memory_stream *m);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,3 +28,9 @@ memory_stream_close(struct memory_stream *m)
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
memory_stream_cleanup(struct memory_stream *m)
|
||||||
|
{
|
||||||
|
free(memory_stream_close(m));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue