Friday, October 16, 2009

Why structures need internal padding?

It's for ``alignment''. Many processors can't access 2- and 4-byte quantities (e.g. ints and long ints) if they're crammed in every-which-way.
Suppose you have this structure:
struct {
char a[3];
short int b;
long int c;
char d[3];
};
Now, you might think that it ought to be possible to pack this structure into memory like this:
+-------+-------+-------+-------+
| a | b |
+-------+-------+-------+-------+
| b | c |
+-------+-------+-------+-------+
| c | d |
+-------+-------+-------+-------+
But it's much, much easier on the processor if the compiler arranges it like this:
+-------+-------+-------+
| a |
+-------+-------+-------+
| b |
+-------+-------+-------+-------+
| c |
+-------+-------+-------+-------+
| d |
+-------+-------+-------+
In the ``packed'' version, notice how it's at least a little bit hard for you and me to see how the b and c fields wrap around? In a nutshell, it's hard for the processor, too. Therefore, most compilers will ``pad'' the structure (as if with extra, invisible fields) like this:
+-------+-------+-------+-------+
| a | pad1 |
+-------+-------+-------+-------+
| b | pad2 |
+-------+-------+-------+-------+
| c |
+-------+-------+-------+-------+
| d | pad3 |
+-------+-------+-------+-------+

Size of struct different from the size of its data members

Structs are allowed to "pad" data members out with extra, unused bytes for the sake of alignment. if sizeof(int) and sizeof(float) are both 4 bytes on a system, but sizeof(double) is 8, and you make a struct comprising of an int, float and double, then depending on the platform when you check sizeof(struct) it would either give you 16 or 24(again it depends on the platform)

Padding is entirely platform-dependent. The members of the structure will appear, in memory, in the same order which they're declared. The compiler will often try to ensure that a struct member which is 8 bytes in size (like double) begins at an address evenly divisible by 8, If the previous struct member didn't occupy a number of bytes divisible by 8, then a some unused bytes (known as 'padding') may be included after the end of that struct member.


Something interesting about padding: It is possible for two different structs to have different data members and same total size, and also it is possible for two structs to have exactly same data members and different memory size.

Saturday, March 14, 2009

SEO sins - severe mistakes that would reduce your web page ranking

The following are a list of SEO mistakes can ensure that your site maintains a low ranking with the search engines. Avoid at all costs.

Specifying no title for your page:

I cannot stress how important the title of a web page is. Failing to specify a descriptive, keyword optimized title will do untold damage to your ranking with the search engines. It is the equivalent to owning a shop and boarding up its windows. Ideally each page on your site should have a unique, content-specific title.

Excessive use of images or Flash animation on a page:

If your web page has plenty of nice-looking graphics and eye-popping Flash animation and not a lot of textual content it may indeed look nice but have you ever considered what how the search engines might see it. Search engines thrive on textual content, scavenging as much text as they can but unfortunately they cannot understand images or Flash animations like we can and so will find nothing of real value on your page. Try to balance your page so that the textual content is given priority and that any images or animations are used only when needed. Also it is a good idea to attach some text to an image by using its ALT tag as search engines use this text when determining rank.

Complicated menu systems:

Search engines spiders that crawl through our pages are a relatively primitive bunch. They find in hard to navigate complicated menu systems implemented for example in JavaScript or as a Java applet. Just because it is easy for a human to navigate through the site never assume it will be as easy for a search engine spider. A menu system using simple textual links will be easier for a spider to understand and it will be able to successfully navigate your site. A lot of the time complicated menu systems can be replicated using textual links and CSS.

If you must use a complicated menu system be sure to provide a site map that is clearly accessible from the homepage of your site and contains only textual links to your pages. This ensures that even if the spider cannot understand your menu system that it will be able to find the pages on your site.

Saturday, February 21, 2009

Introducing Search Engine Optimization

Increase traffic to your site with our Search Engine Optimization Masterclass, conducted by SEO expert Ash Nallawalla.

THE SEO REGION

When we talk about improving search engine ranking, what are we talking about? See below. APC Magazine site ranks #1 for “computer magazine” (as it should). SEO concerns the natural (“organic”) search results on the left. Paid (“sponsored”) ads appear on the right.

For complete story Click here . . . . .

Wednesday, February 18, 2009

My First Post - Starting an SEO Resource Blog . .

Hi . . . . . My name is Kashif Umar and I live in Pakistan. I am a .Net C# Developer, Trainer and an SEO(Search Engine Optimization) Professional. I have got a BS & MS degree in Computer Sciences.