I have a long (not C ++) structure that is used to control entities in a game , With the situation, some behavioral data, not random, except two strings. The structure is global.
Right now, whenever any object starts, I have omitted all the values one by one,
myobjects [index] .angle = 0; Myobjects [index] .speed = 0; It's not really slow, but I'm thinking that copying a "template" structure with all the values set to the default is faster or more is convenient.
Then, submit two appropriate questions: Is it to manually copy all the data instead of copying a strip? What should I keep in mind about malloc-ed memory for string?
"more convenient" possibly more important part.
Straits vs. [...]; ... // to start each member in "default" // can not be used in normal assignment struts newv = {0}; Vs [...] = new; To hide an init-function (or "initial description" behind the macro), if you dislike the transmitterable code: -)
Code> struct s * init_s (Struct s * v, ...) {/ * and goes on life * /}
Comments
Post a Comment