OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 1:39 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Tue Jun 26, 2007 7:33 pm 
Offline
Member
Member
User avatar

Joined: Tue Oct 17, 2006 6:06 pm
Posts: 1437
Location: Vancouver, BC, Canada
Quote:
That depends how you use the array. If it's an array of bytes used for a buffer or something, then you never initialize it (you just load data into it and keep track of how much data has been loaded in). If it's an array of structures where the structures are used in order it's the same thing (you have a variable that keeps track of how many entries are in use, where entries that aren't in use aren't initialized and don't need to be filled with zero). If it's an array of structures that aren't used in order, then you have some sort of "used/unused" field in the structure and this field does need to be initialized to "unused" (but not necessarily set to zero) while the other fields are left uninitialized (and not filled with zero).


I can think of an example that would be inefficient in terms of initialization: arrays of objects in C++. Each element of such an array is default-constructed when the array is allocated. I'm not sure how common this is in practice (I tend to use vectors of pointers to objects myself).

_________________
Top three reasons why my OS project died:
  1. Too much overtime at work
  2. Got married
  3. My brain got stuck in an infinite loop while trying to design the memory manager
Don't let this happen to you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 75 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group