C pointer in free time exception!

Source: Internet
Author: User

The underlying development is generally in C language, which involves the management of memory, the application and release of pointers. <?xml:namespace prefix = o/>

A double buffer queue was recently used, resulting in an exception when it was released. The allocation of memory uses the malloc, the corresponding release using free, feel no problem.

There are two reasons why I feel closest to finding the possible cause on the Internet:

<!--[if!supportlists]-->1. <!--[endif]--> application space is not equal to the space released

<!--[if!supportlists]-->2. <!--when [endif]--> is released, the pointer's address changes, resulting in the process of assigning values.

When I am applying for space, I record the value of the pointer address and then debug it and see if the address has changed when I release it. The result really is that the address has changed. It was me. In the process of assigning a string, you directly assign another pointer to the pointer, and later use the strcpy function to solve the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.