判断野指针,无效指针

时间:2016-09-25 14:25:29   收藏:0   阅读:597

 

该方法仅适用于windows

 1 int is_invalid_ptr(void* memory_pointer)
 2 {
 3     if (NULL == memory_pointer) { 
 4         return 1; 
 5     }
 6 
 7     __try {
 8         return *((int*)memory_pointer) ? 0 : 0;
 9     }
10     __except (1) {
11         return 1; /** exception_code(); STATUS_ACCESS_VIOLATION*/
12     }
13 }

 

原文:http://www.cnblogs.com/baigoogledu/p/5905774.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!