Recently, the algorithm is a function that involves converting RGB to YUV data. This common error occurs:
Unsigned char * vline = (New unsigned char [width + 2]); // + 1;
// Uline [-1] = uline [width] = 128; // 16-bit binary representation of-1: 1111 1111 1111 1111
At this time, uline mem points to the address 0xffff.
Delet [] vline;
Result: If you drop the row with a value of 128, the correct result is correct. If you do not stop the row, the heap memory error message is generated;
Cause:
1. The addresses of-1,-2,-3, and-4 represent the allocation header information. Otherwise, free (x) can be released without knowing the size;
2. vline points to the dynamically allocated address, but it is assigned a value, resulting in vline pointing to a constant space address, read-only data segment, rather than the heap region, the memory allocated to the constant address can be automatically released only after the program exits.
: A pointer pointing to a fixed length and fixed content. It does not change, so you do not need to release it. In addition, you cannot release it automatically when the program ends.
Solution:
1.
Point = new char [5];
Point = "FDA"; // if this sentence is canceled, I don't know why.
--------------------------------------------------------------------------
Point = "FDA"
Should be changed:
Memmove (point, "FDA", 3 );
Or:
Strcpy (point, "FDA ");
Add:
# Include "string. H"
2. Point [0] = 'F'; point [1] = 'D'; point [2] = 'a ';
Attached relevant information:
Http://dearymz.blog.163.com/blog/static/205657420062271155250/
Http://bbs.csdn.net/topics/390359048
Http://zhidao.baidu.com/link? Url = o9US18FIs-JuvBOQgNTL1diMNfiyRoGvOGHMlKoDZCGMu1UApWeIVuy-8UO4MV-0Jlryiz05jaKvK4RQfDRh0a
Http://wenku.baidu.com/link? Url = several common errors of KrHpusbOUWu25UK0WbNdP3ZDsBT_jKe4nptbEu8h6cbULhVVHB_R5RLm8zl_oSE6-by5QG3jay9-o8lQOVDDP6Gq3-oNvuCJu2HATkz8Er7 delet
Http://bbs.pediy.com/showthread.php? T = 176091 delet Problems
Http://bbs.csdn.net/topics/300170474 A [-1] Problem
Http://blog.csdn.net/daniel_ice/article/details/6857019 Assembly interpretation array and fetch Array