Files
RedBear-OS/local/recipes/libs/libdisplay-info/source/memory-stream.c
T
vasilito e4a44377fb
redbear-ci / check (push) Has been cancelled
libdisplay-info: replace the stub with upstream 0.4.0
The recipe was not building libdisplay-info. It synthesized its own
meson.build declaring `version: '0.2.3'` and compiled a hand-written
stub: one di.c and four headers, 518 lines, 20 exported functions.

0.2.3 does not exist upstream -- the tags are 0.1.0, 0.1.1, 0.2.0, 0.3.0
and 0.4.0. That fabricated version satisfied kwin's

    pkg_check_modules(libdisplayinfo REQUIRED IMPORTED_TARGET libdisplay-info>=0.2.0)

so kwin configured cleanly and then failed to compile utils/edid.cpp on
di_info_get_default_color_primaries, di_info_get_hdr_static_metadata,
di_info_get_supported_signal_colorimetry and di_edid_display_descriptor.
A version gate satisfied by a declaration rather than an implementation.

Now vendors upstream 0.4.0 (gitlab.freedesktop.org/emersion/libdisplay-info):
14 C files, 10898 lines, 10 headers, 94 exported symbols. 0.4.0 rather than
0.2.0 because the colorimetry and HDR static metadata accessors kwin needs
post-date the 0.2.x series -- and they feed the real colour-primaries and
HDR path of the display stack, so a stub returning NULL would have been
wrong at runtime even if it had compiled.

Red Bear delta is one hunk in source/meson.build: the unconditional
subdir('di-edid-decode') and subdir('test') are commented out. Both build
auxiliary executables and a shell test harness that are not part of the
runtime and do not cross-compile for Redox. Library, headers and
pkg-config are untouched.

Verified: builds clean, stages libdisplay-info.so.0.4.0 with all four
symbols kwin needs, pkg-config reports 0.4.0, and kwin's utils/edid.cpp
now compiles.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 22:19:38 +03:00

37 lines
510 B
C

#include <stdlib.h>
#include "memory-stream.h"
bool
memory_stream_open(struct memory_stream *m)
{
*m = (struct memory_stream){ 0 };
m->fp = open_memstream(&m->str, &m->str_len);
return m->fp != NULL;
}
char *
memory_stream_close(struct memory_stream *m)
{
char *str;
int ret;
ret = fclose(m->fp);
str = m->str;
*m = (struct memory_stream){ 0 };
if (ret != 0) {
free(str);
str = NULL;
}
return str;
}
void
memory_stream_cleanup(struct memory_stream *m)
{
free(memory_stream_close(m));
}