User Breakpoint called from Code at * * *

Source: Internet
Author: User

Reprint user breakpoint called from code at * * *

New and delete are not necessarily paired.

At runtime, delete "User breakpoint called from Code at * * *". Think it should be a pointer before the delete, here again delete once, find an afternoon ... Both the new and the delete are paired and there is no problem. But it was a mistake.

Later on the Internet, it is possible that some kind of destructor, the invisible Delete. I don't know if this is understood here. But I also checked, still do not think there is any problem.

After a piece of code a code comment, and then see which section has a problem, found a function call, used to:

void Cdlgcurveanalys::D istanceradius (int num, double *pdistance, int *pobjradius, int *precradius)
{
if (Pobjradius)
{
memset (pobjradius,0,sizeof (double) *num);
}

***************************

}

It was found that, as a result of the need, the definition of Pobjradius was defined as double*, so memset was also used by sizeof (double), but later changed to int, and did not notice that the assignment exceeded the bounds of the pointer. Delete when the error.

This check also reminds me that after the pointer delete to remember to assign null, convenient later use, to determine whether the pointer was used. This question before asked seniors, but only know that when not assigned to NULL, will be a wild pointer, but do not know why. It's been a tough time. Next time Remember ~

So in general, the delete report "User breakpoint called from Code at * * * * * *", the first time to consider the points

1. New and delete corresponding

2. Be careful about the destruction of classes (stealth delete)

3. Pointer assignment is to pay attention to the size of the pointer request, do not cross

4. After delete, remember null.

Another problem to be solved is: delete[]pdis; how does the compiler know how many pointers to delete? In this case, I suspect that when the assignment crosses the line, the delete[] should be the place where the delete crosses the boundary. I don't know, look at other books.

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.