Click here to Skip to main content
15,923,681 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionFile handling in vc++ Pin
deeps_cute27-Feb-07 16:36
deeps_cute27-Feb-07 16:36 
AnswerRe: File handling in vc++ Pin
Christian Graus27-Feb-07 17:26
protectorChristian Graus27-Feb-07 17:26 
AnswerRe: File handling in vc++ Pin
Eytukan27-Feb-07 17:36
Eytukan27-Feb-07 17:36 
GeneralRe: File handling in vc++ Pin
deeps_cute27-Feb-07 19:42
deeps_cute27-Feb-07 19:42 
QuestionUnhandled exception Pin
apoc8327-Feb-07 15:54
apoc8327-Feb-07 15:54 
AnswerRe: Unhandled exception Pin
Stephen Hewitt27-Feb-07 16:11
Stephen Hewitt27-Feb-07 16:11 
GeneralRe: Unhandled exception Pin
apoc8327-Feb-07 16:27
apoc8327-Feb-07 16:27 
GeneralRe: Unhandled exception Pin
Stephen Hewitt27-Feb-07 16:37
Stephen Hewitt27-Feb-07 16:37 
My earlier suggestion is one problem, however there is another. You must free using the same pointer value returned by malloc.

This code ensures that this doesn't happen (underlined):
for ( y = 0; y < H; y++ ) {
for ( x = 0; x < W; x++ ) {
U8 r = static_cast< U8 >( *Yarray + (1.4075 * (*Varray - 128)) );
U8 g = static_cast< U8 >( *Yarray - (0.3455 * (*Uarray - 128)) - (0.7169 * (*Varray - 128)) );
U8 b = static_cast< U8 >( *Yarray + (1.7790 * (*Uarray - 128)) );

SET_RGB( Dst, x, y, r, g, b );
*Yarray++;
*Uarray++;
*Varray++;
}
}


Alter your freeing code so it looks like this:
Yarray-=H*W;
Uarray-=H*W;
Varray-=H*W;
free(Yarray);
free(Uarray);
free(Varray);


PS: C sucks. If you used C++ and std::vectors such problems would be far less likely to occur. 'static_cast' is not usable in C.


Steve

GeneralRe: Unhandled exception Pin
Stephen Hewitt27-Feb-07 17:40
Stephen Hewitt27-Feb-07 17:40 
GeneralRe: Unhandled exception Pin
apoc8327-Feb-07 18:41
apoc8327-Feb-07 18:41 
GeneralRe: Unhandled exception Pin
Stephen Hewitt27-Feb-07 18:52
Stephen Hewitt27-Feb-07 18:52 
GeneralRe: Unhandled exception Pin
apoc8327-Feb-07 19:13
apoc8327-Feb-07 19:13 
GeneralRe: Unhandled exception Pin
Stephen Hewitt27-Feb-07 19:17
Stephen Hewitt27-Feb-07 19:17 
Generalpre tags please Pin
toxcct27-Feb-07 22:00
toxcct27-Feb-07 22:00 
GeneralRe: pre tags please Pin
apoc8327-Feb-07 22:10
apoc8327-Feb-07 22:10 
GeneralRe: Unhandled exception Pin
Eytukan27-Feb-07 17:53
Eytukan27-Feb-07 17:53 
GeneralRe: Unhandled exception Pin
ThatsAlok27-Feb-07 19:31
ThatsAlok27-Feb-07 19:31 
GeneralRe: Unhandled exception Pin
Eytukan27-Feb-07 19:34
Eytukan27-Feb-07 19:34 
GeneralRe: Unhandled exception Pin
ThatsAlok27-Feb-07 19:50
ThatsAlok27-Feb-07 19:50 
GeneralRe: Unhandled exception Pin
Eytukan27-Feb-07 19:52
Eytukan27-Feb-07 19:52 
GeneralRe: Unhandled exception [modified] Pin
apoc8327-Feb-07 22:09
apoc8327-Feb-07 22:09 
QuestionRe: Unhandled exception Pin
apoc831-Mar-07 21:11
apoc831-Mar-07 21:11 
QuestionGetPixel() help Pin
arunforce27-Feb-07 15:12
arunforce27-Feb-07 15:12 
AnswerRe: GetPixel() help Pin
Eytukan27-Feb-07 16:19
Eytukan27-Feb-07 16:19 
GeneralRe: GetPixel() help Pin
arunforce27-Feb-07 16:28
arunforce27-Feb-07 16:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.