Saturday, March 20, 2010

Difference between malloc and calloc

One of the most basic things a person familiar with programming language 'C' is supposed to know is:
What is the difference between the malloc and the calloc function calls?
Query Google and it'll tell you how many folks are interested in the answer to this question. The reason for that is that it is one of the most commonly asked questions in job interviews at the beginner's level.

Since the readers here may not possess that familiarity, the answer that's usually expected is:
While both the functions allocate memory, calloc() additionally initializes all the locations in the newly allocated memory block to '0'.
That's that. That answer is sufficient for the interview. That's all I knew. Until now.

I was reading The Old New Thing today and there was a mention of Copy-on-Write (CoW) in one of the posts. To understand it better, I decided to read about CoW on Wikipedia. From the Wikipedia page, I found out that calloc can be implemented using CoW:
Another use is in the calloc function. This can be implemented by having a page of physical memory filled with zeroes. When the memory is allocated, the pages returned all refer to the page of zeroes and are all marked as copy-on-write. This way, the amount of physical memory allocated for the process does not increase until data is written.
Nice, I said to myself. Note taken. Thanks TONT, Wikipedia!

Tuesday, February 16, 2010

John Gruber, we expect better posts from you.

On Monday, February 15, 2010, Microsoft announced their new platform for mobile devices, Windows Phone 7 Series. This was at the Mobile World Congress in Barcelona, Spain. The internet, since then, has been full of positive reviews of the platform.

Being one of those guys who got an early preview of the platform, I can tell you that it is a very good effort. Not better than the best out there, but certainly an impressive effort.

However, John Gruber, on his popular blog Daring Fireball, has this to write about it:
What a great product name. Not a mouthful at all.
Yes, we know it is not such a good name, but instead of just saying that, you could have at least said a couple of things about the platform, good or bad. Positive reviews encourage the folks building it and bad reviews highlight the areas to improve. It also makes for an article worth reading.

Over the years you have written lots of good posts; this one isn't one of them. We have come to expect better from you. Please do not let us down.

Saturday, February 06, 2010

Trying out the email interface

blogger.com (or blogspot.com) provides the blog owners with the ability to publish posts to their own blogs by sending an email to an email address, part of which is chosen by the blogger herself.
I know it has been around for a while, but I haven't tried it prior to this.

One of the things I want to try out is its ability to handle rich text, i.e. bold, italics, colors, highlighting.

Then there's quoted text.

How about the following:
  1. Ordered list
  2. ...
What happens if I include unordered list, such as this one:
  • Unordered item #1
Let's find out how good/ugly looking this one turns out to be.

Friday, December 18, 2009

Now that's a deal!

Found this "best" deal while watching a video related to COP15 on NDTV's website:
Get a Secure Government Job today!



I happen to know quite a few folks who are vying to get a government job because it is perceived to be the safest and least demanding job in difficult times for the economy.

I should probably pass on this link to them ;-)

Thursday, December 10, 2009

#FAIL: Never book railway tickets via Cleartrip!

I made a railway reservation from Indore to New Delhi via Cleartrip. The ticket was waitlisted till the preparation of chart, so I did not get to travel. That's fine, I should have made the reservation in time.

So I call up Cleartrip and ask them about the refund after the train has left Indore station. At first, I am told:
We can't tell you about the refund amount since it'll be processed by IRCTC and we don't know about it!
Excuse me, I made a deal with you! If you're in the business, you better know it down to the last detail. If you can't do that, please move out of the trade.

So the lady puts me on hold for a little while and then comes back to give me an "approximate" number. I am told, in a cool, cam, composed manner, that the following fees would be charged:
  1. IRCTC Charges
  2. Cleartrip Charges
  3. Transaction Charges
  4. Reservation Charges
Now this drives me crazy! I am being charged for the reservation I never got!? I'm exasperated, she realizes and says:
The reservation charges are levied by IRCTC, we did not charge you for this.

That's an "Aha!!" moment for me. She means I should argue with IRCTC about it, when I actually made the transaction via Cleartrip? Aha!!

So then next time onwards, why should I make the reservation through Cleartrip, and not go to IRCTC instead? That's what even Cleartrip is doing. The service they provide is certainly not worth my money, no way! Booking through IRCTC is almost the same (pain). If done via IRCTC, I'll know the exact refund amount as well.

I'll tell you what I'll do from now on: Research about the train and availability on Cleartrip and then book through IRCTC. Up yours, Cleartrip!

In case anyone from Cleartrip cares to read this post, here are the trip details, if they want to verify:
Cleartrip ID: 912021268
PNR: 8337869853

PS: Regardless of that, Cleartrip's calendar feature is very well thought-out and done. Give it a try (and leave the site after that). Did I mention that their support forum also does not work?

Sunday, November 22, 2009

When you need something badly, give it your best shot ...

When you need something badly, give it your best shot, keep improving yourself, keep trying, stay focused, stay motivated. Even if you don't get it, you come out a better person and that's more important.

Yeah, that's by me. Please feel free to use it wherever, whenever you see fit. If you do, try to drop me a link to it here although that's completely optional.

Tuesday, October 27, 2009

Super Mario Bros tunes

This post is just so that I do not have to search for the MP3s next time around.

Oh, and I love it! :-)

Thursday, October 01, 2009

Deciding which IT challan you need to fill

If you are unsure which IT challan [280-283] you need to fill while filing income tax (new or revised), take a look at the FAQs section on the IT department's website.

If you don’t know Assessing Officer (Ward / Circle) ...

Here's a handy tip:
If you don’t know Assessing Officer (Ward / Circle), Find it here by submitting your PAN.

Tuesday, September 22, 2009

How could one be loosing his/her data?

One of the blogs I try to read regularly is FavBrowser. No doubt, it has good content. You should follow it if you are interested in news and stuff related to web browsers, though it is, by no means, the source all the interesting news.

Anyway, so I was reading this article today, posted on FavBrowser, and here's something interesting I found (pay close attention), and I quote:
Firefox uses SQLITE databases to store lots of its settings. By the time the databases grow and Firefox starts working slowly. SpeedyFox compacts those databases without loosing any data.
So I said to myself, "Must be just another copying mistake", so I headed over to the source to verify, and I quote again:
Firefox uses SQLITE databases to store lots of its settings. By the time the databases grow and Firefox starts working slowly. SpeedyFox compacts those databases without loosing any data.
Turns out, they had quoted it from their own source, and I quote once again:
Firefox uses SQLITE databases to store lots of its settings. By the time the databases grow and Firefox starts working slowly. SpeedyFox compacts those databases without loosing any data.

The funny thing is, I've also quoted it without any modifications/corrections but I hope the message has been conveyed :-)