Repository navigation
Conversation
avoiding unnecessary memory allocations and string copying
| ffStrbufInit(&result.version); | ||
| ffStrbufInit(&result.renderer); | ||
| ffStrbufInit(&result.vendor); | ||
| ffStrbufInit(&result.slv); |
There was a problem hiding this comment.
If the strbufs aren't initialized, ffDetectOpenGL will write data in random memory places, which most probably will cause a seg fault
There was a problem hiding this comment.
The reason that the pipeline doesn't fail is that the GitHub VMs don't have OpenGL support
| FFformatarg formatArgs[FF_OPENGL_NUM_FORMAT_ARGS] = { | ||
| { FF_FORMAT_ARG_TYPE_STRBUF, &result.version }, | ||
| { FF_FORMAT_ARG_TYPE_STRBUF, &result.renderer }, | ||
| { FF_FORMAT_ARG_TYPE_STRBUF, &result.vendor }, | ||
| { FF_FORMAT_ARG_TYPE_STRBUF, &result.slv } | ||
| }; | ||
|
|
||
| ffStrbufDestroy(&result.version); | ||
| ffStrbufDestroy(&result.renderer); | ||
| ffStrbufDestroy(&result.vendor); | ||
| ffStrbufDestroy(&result.slv); | ||
| ffPrintFormat(instance, FF_OPENGL_MODULE_NAME, 0, &instance->config.openGL, FF_OPENGL_NUM_FORMAT_ARGS, formatArgs); |
There was a problem hiding this comment.
Why? The compiled assembly will be the same
There was a problem hiding this comment.
Again - did not mean to submit to you - the "why" is just "this is what I have been learning w/o a class and w/o a university and wanted to apply a small change based on best practice"
I guess so maybe what you are saying is that "it does not matter which path is taken, so long as the destination is reached?" Whereas that is the opposite of what I had bothered to learn, which is why this change had been made.
"Conformance is performance" was one of the small sayings.
There was a problem hiding this comment.
The example is similar to the following:
void do_something(int);
//My Version
do_something(5);
//Your version
int a = 5;
do_something(a);Compiled they are the same, so lets only talk about the code style. Mine is more simple, and still readable, so it is the better solution here. (In my opionion, we are at a point where personal opionion does make the difference)
There was a problem hiding this comment.
And experience! Your experience makes it make sense! Thank you!!! As they say "real world experience" makes a difference over "textbook experience" :) :) (time to add to my notes here...)
Sorry for the panic attack.....
Again I am very new with this. Only reading C99 books when young, and then 2 months of a course + textbook.
avoiding unnecessary memory allocations and string copying