This happened to me few years ago. I still get angry at myself for not being confident enough to really say what I think.
It was a small start-up company, not actually looking for a C programmer, but they would potentially hire "a good one". A friend of mine recommended me to them. I got an interview.
The Question: Turns out that in a large (C/C++) software project there is a mistake made; None of the many "malloc" -calls are checked for errors. The source code is so large that it would be too expensive to go through it manually. How would you solve the problem?
I was looking at him speechless. It was so absurd case. I tried to ask some follow up questions. But still, I was baffled.
Finally he described me the "perfect" solution: "You can write a macro that replaces every "malloc"-call with your own "malloc" which includes error checking."
I said "ok." and the inteview was pretty much over..
I kept thinking about the interview.. and the more I thought about it, the more angry I got with my self. If I would have trusted myself, this would've been my answer:
1) I would fire the one who writes so many bad "malloc"-calls that it is "too expensive to fix".
2) Only fix is to go through all the "malloc"-calls and fix them. Good text editor can easily locate all the "mallocs". Even if the total code size is very large.
3) NEVER replace a standard library function with your own implementation. That is a cardinal mistake! I would immediately fire a programmer who does that in a large software project. Or at least remove him from the project.
But there I was with this idiot who after the interview probably thought that I am the stupid one.. What do you think?
It was a small start-up company, not actually looking for a C programmer, but they would potentially hire "a good one". A friend of mine recommended me to them. I got an interview.
The Question: Turns out that in a large (C/C++) software project there is a mistake made; None of the many "malloc" -calls are checked for errors. The source code is so large that it would be too expensive to go through it manually. How would you solve the problem?
I was looking at him speechless. It was so absurd case. I tried to ask some follow up questions. But still, I was baffled.
Finally he described me the "perfect" solution: "You can write a macro that replaces every "malloc"-call with your own "malloc" which includes error checking."
I said "ok." and the inteview was pretty much over..
I kept thinking about the interview.. and the more I thought about it, the more angry I got with my self. If I would have trusted myself, this would've been my answer:
1) I would fire the one who writes so many bad "malloc"-calls that it is "too expensive to fix".
2) Only fix is to go through all the "malloc"-calls and fix them. Good text editor can easily locate all the "mallocs". Even if the total code size is very large.
3) NEVER replace a standard library function with your own implementation. That is a cardinal mistake! I would immediately fire a programmer who does that in a large software project. Or at least remove him from the project.
But there I was with this idiot who after the interview probably thought that I am the stupid one.. What do you think?
Last edited: