diff options
author | wm4 <wm4@nowhere> | 2017-07-24 08:07:32 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-07-24 08:12:42 +0200 |
commit | 24dc91907a039b7a86bf6d5b2a0a914bf1f44c3d (patch) | |
tree | 0aeb8046536a1d2a799d352112418960387cc94d /video/out/opengl/utils.c | |
parent | 3d0f86145ce211eee623b661d558ef3405d75933 (diff) | |
download | mpv-24dc91907a039b7a86bf6d5b2a0a914bf1f44c3d.tar.bz2 mpv-24dc91907a039b7a86bf6d5b2a0a914bf1f44c3d.tar.xz |
common, vo_opengl: add/use helper for formatted strings on the stack
Seems like I really like this C99 idiom. No reason not to generalize it
do snprintf(). Introduce mp_tprintf(), which basically this idiom to
snprintf(). This macro looks like it returns a string that was allocated
with alloca() on the caller site, except it's portable C99/C11. (And
unlike alloca(), the result is valid only within block scope.)
Use it in 2 places in the vo_opengl code. But it has the potential to
make a whole bunch of weird looking code look slightly nicer.
Diffstat (limited to 'video/out/opengl/utils.c')
-rw-r--r-- | video/out/opengl/utils.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index f5c639d98d..2624ad7715 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -919,8 +919,7 @@ static GLuint compile_program(struct gl_shader_cache *sc, const char *vertex, compile_attach_shader(sc, prog, GL_VERTEX_SHADER, vertex); compile_attach_shader(sc, prog, GL_FRAGMENT_SHADER, frag); for (int n = 0; sc->vertex_entries[n].name; n++) { - char vname[80]; - snprintf(vname, sizeof(vname), "vertex_%s", sc->vertex_entries[n].name); + char *vname = mp_tprintf(80, "vertex_%s", sc->vertex_entries[n].name); gl->BindAttribLocation(prog, n, vname); } link_shader(sc, prog); |