Qualcomm Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

would wrapper structure , and wrapper allocation, access and delete functions work?

struct hold
{
void *ptr;
size_t sz;
}
wrap_malloc(size_t sz)
{

struct hold* h=(struct hold*) malloc(sizeof(struct hold));
h->ptr=malloc(sz)
h->sz=sz
return hold;
}

int wrapper_write(struct hold*h,size_t offset,void * val)
{

if(h->sz <=offset && h->sz+offset+sizeof(val)<h->sz)
{

*( (h->sz)+offset)=val ;
return 1;
}
else
{
return 0;
}
}


wrapper_free(struct hold* h )
{

free( hold->ptr);
free(hold);

}

- django October 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you please explain your code?

- Anonymous October 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Redzone protection for buffers is fairly common.
For a buffer of 16 bytes, there could be redzone patterns at the end, for example

- S.M October 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

hey desi grad i think this is ur second onsite of qualcomm for which position was it ?

- destiny October 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

actually i was also interviewed last month in onsite but was not able to clear so was curious

- destiny October 22, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@destiny..is it for fulltime or inter position

- Newbie October 26, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it was for fultime

- destiny November 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The question is just to detect the memory correction and not prevent. Hence when allocating memory of say 'x' bytes, write some pre-determined pattern in (x+1)byte. When this memory is freed, we can check the x+1 th byte to see if the pattern is still there or it is been over written. This can help to find the memory corruption.

- GK November 06, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

When you ask the system for 10 bytes of memory, the systems removes 10 bytes from the list of free bytes in the heap and gives it to you.
If you write in the 11 bytes, according to me this byte should still be in the list of free bytes. So there is a chance the system might give this byte to some body else. So your program will say memory corruption has occurred even when it has not. Some body else wrote data into the (x+1) byte

- abhimanipal January 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Are you brain dead?

- buster March 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

GK is right. Thats the right answer [according to the interviewer at least].

- DesiGrad March 25, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

"predetermined pattern" in (x+1)th byte won't work with a probability 1/256... i'm not sure if its a robust thing to do. whatsay?

- i agree, but... April 18, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

AS GK said we can store the predetermined pattern in the n+1th position, and modify free to check.We should also modify malloc so that we actually allocate one extra location.

- Anonymous September 20, 2011 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More