My code is as this:
// a function that new a char pointer and return it
Unsigned char* RGB2GS(Unsigned char* pRgb, int nw, int nh, int nbpp) {
    unsigned char* pGs = new unsigned char[nw*nh*nbpp];
    // code for rgb to gs...//
    return pGs;
}
int main() {
    unsigned char* pmyRgb = ReadBmp(filename);//size 1024x1024, RGB
    unsigned char* pMyGs = NULL;
    pMyGs = RGB2GS(pmyRgb, 1024, 1024, 24);
    delete[] pMyGs ;
    delete[] pmyRgb ; // correct typo
I found there is memory leakage(from VS2010 log). I created a pointer inside a function and return it. But I deleted the pointer outside the function. Is that a problem in this usage? thanks
 
     
     
     
    