Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 10-10-2009
Member
 
Join Date: Oct 2009
Posts: 3
memory alignment and structure padding

hi i m wondering what is memory alignment and structure padding i was reading some book on c and got to bitfields structure and talks abt structure padding and its used to align memory i don't even know what's memory alignment means could someone please explain to me there concept ? in details
thanks in advanced.
Reply With Quote
  #2  
Old 10-10-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: memory alignment and structure padding

Data structure alignment is the way data is arranged and accessed in computer memory. It consists of two separate but related issues: data alignment and data structure padding. As size of pointer is 4 bytes, if everything is organized by multiple of 4, that it will be easier and faster to calculate the address and processing them. As structures are used to club different size variables, compiler will align to 4 byte boundaries and for that it needs padding. When you are using C, structure padding is used to pad the data in such a way that it can be sent to external devices. Structure Padding is done to do memory alignment.
Reply With Quote
  #3  
Old 10-10-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: memory alignment and structure padding

Although the compiler (or interpreter) normally allocates individual data items on aligned boundaries, data structures often have members with different alignment requirements. To maintain proper alignment the translator normally inserts additional unnamed data members so that each member is properly aligned. In addition the data structure as a whole may be padded with a final unnamed member. This allows each member of an array of structures to be properly aligned.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags:



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "memory alignment and structure padding"
Thread Thread Starter Forum Replies Last Post
customize Window Border padding in Windows 8 Fella Customize Desktop 4 21-06-2013 10:59 AM
What is Structure Padding in C ? avit Software Development 6 03-05-2012 12:50 AM
Css padding in html klite Software Development 7 31-12-2009 11:00 AM
Html need to know about text wrap padding around an image ComPaCt Software Development 2 09-07-2009 08:30 PM
Problem with width for nested div padding Jaisudha Software Development 3 22-06-2009 12:28 PM


All times are GMT +5.5. The time now is 02:28 AM.