c - How to handle string allocation in output structure -


What is the best way to handle an output straight with some strings in it?

  Structure information {wchar_t * text; Size_t text_len; } Zero Fu (structure information * output);  
  • The user needs to allocate text to themselves

    Output can be recycled in the loop - to know how much memory

  • Allocate text within FU

    To make the user free of output, because before each lesson To be freed (can be made to reduce pain); freestrucks can be made
    Loops

  • Foo

    Foo can embed text within the structure information and the user needs free output only for free is. Good for storage (Fu knows how much to allocate it), but it may be that for many tension modes, if used in the loop as a shortline variable, it can not be recycled.

Windows uses the "User needs to allocate text to yourself" and either you adequately allocate or you need for size Need to call the bar function

Nobody is the best way - all the options you have proposed are used at some time or another The important thing is to document it properly, and keep it consistent in all the functions of a library, where practical.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -