title: Checking if a pointer is allocated memory or not
body: <p>Can we check whether a pointer passed to a function is allocated with memory or not in C?</p>
  
  <p>I have wriiten my own function in C which accepts a character pointer - <strong>buf</strong> [pointer to a buffer] and size - <strong>buf_siz</strong> [buffer size]. Actually before calling this function user has to create a buffer and allocate it memory of buf_siz. </p>
  
  <p>Since there is a chance that user might forget to do memory allocation and simply pass the pointer to my function I want to check this. So is there any way I can check in my function to see if the pointer passed is really allocated with buf_siz amount of memory .. ??</p>
  
  <p><strong><em>EDIT1:</strong> It seems there is no standard library to check it .. but is there any dirty hack to check it .. ??</em></p>
  
  <p><strong><em>EDIT2:</strong> I do know that my function will be used by a good C programmer ... But I want to know whether can we check or not .. if we can I would like to hear to it ..</em></p>
  
  <p><strong>Conclusion: So it is impossible to check if a particular pointer is allocated with memory or not within a function</strong></p>