Re: gobject clarification regards to instance memory initialisation



On Mon, 25 Oct 2004, Stefan Kost wrote:

hi hi,

I am currently updating the gobject tutorial from mathieu lacage again.
One question for the gurus' (I was scanning the code, but are not sure about
this). Frim the viewpoint of a class writer, do I have to initialise fields in
my object instance that should be 0/NULL or is the memory cleared?
In other words in my class_init/instance_init methods can I expect that
instance->XX
object->>XX
fields are 0 (except the parent fields of course)?

new class structures are zero initialized and pre-filled with the contents
of the parent class. instance structures and instance private data is
zero initialized.

however, it is a good habit to initialize all fields explicitely, getting used to this
comes in handy if you switch to other languages like C++ which don't do automatic
zero initialization.


Stefan
--

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]