|
Yea, alot of unneccesary code there.
|
|
|
|
|
I hope you have unit tests with 100% code coverage for each one of those methods.
I can imagine the sinking feeling one would have after ordering my book,
only to find a laughably ridiculous theory with demented logic once the book arrives - Mark McCutcheon
|
|
|
|
|
Previously in the code both flag and fval were malloc'd
flag = NULL;
free(flag);
fval = NULL;
free(fval);
this thing looks like it was written by an epileptic ferret
Dave Kreskowiak
|
|
|
|
|
What is NULL #define d as?
|
|
|
|
|
What's the problem?
1. Remove all references
2. Invoke the GC
|
|
|
|
|
Aaaah, yeah... NULL could be a collection of references to be freed.
|
|
|
|
|
But wouldn't that free NULL twice?
|
|
|
|
|
In an effort to gain more memory by showing negative used space!
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
flag = NULL sets it to point to nothing. This makes the memory location lost.
flag = (data_type*)malloc(sizeof(data_type)); This returns address of the memory allocated by malloc and assignes the address value to flag - something like flag = 0x2345cf. This is a valid address it is pointing to. When you say flag = NULL, flag points to nothing, then you cannot free flag because you cannot free something that does not exist.
So first free(flag); then set flag = NULL;
i.e. just change the sequence to-
free(flag);
flag = NULL;
free(fval);
fval = NULL;
|
|
|
|
|
You didn't take your coffee this morning ? Did you forget to read the title of the forum ?
|
|
|
|
|
I wasn't so sure if I should tell him that
|
|
|
|
|
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
reminds me of the NRA and gun advocacy... it's the shooter not the gun
it's the programmer not the language
David
|
|
|
|
|
"Ray guns don't vaporize Zorbonians. Zorbonians vaporize Zorbonians."
Gary Larson
You know, every time I tried to win a bar-bet about being able to count to 1000 using my fingers I always got punched out when I reached 4....
-- El Corazon
|
|
|
|
|
Oh, great, now I have an opening for something I was thinking yesterday:
A song that was playing used the phrase, "the wrong end of a gun".
Does the anti-gun crew consider both ends of a gun to be "wrong"?
|
|
|
|
|
Too bad 'free()' wasn't defined as returning a (void *). In that case, the code could have been written as:
flag = free(flag);
In case of any error other than a null pointer being passed in, free() could return the passed-in pointer.
Similar behavior could have been used with fclose() [return a (FILE*)] and other such functions that destroy the object whose pointer is passed to them. Oh well, only a few decades too late now.... Where's my time machine?
|
|
|
|
|
Discovered this gem in our code base (C#, but I guess that won't make much difference)...
if (transparent)
pdfDoc.HtmlOptions.HideBackground = true;
pdfDoc.HtmlOptions.HideBackground = true;
Rob
|
|
|
|
|
Well, if opaque then it's true, on the other hand, if transparent then it's so true.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I remember having to do something like that; repainting a dynamic form I think. It was easier to do the repaint twice based on a simple condition then to code a nasty, recursive, snaking, 683 if level method.
But I put a comment in to explain why.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
No, nothing like that. Fortunately, we have a great Refactoring policy here that allowed me to simply fix the code. All is working fine, so I guess it was... well actually I've no idea.
|
|
|
|
|
re-wording a famous Shakespare quote:
To hide, or not to hide...
|
|
|
|
|
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Boss Type: ... Hmmm, do you think this will be a problem?
VB6'er*: Well, the thing is there's no way to get the ID of the rows you've just updated in SQL Server.
[Much later]
VB6'er: The input data must have been invalid - and then the import failed part way through updating twenty odd tables, but I don't know where. This is going to take me hours to sort out!
Boss Type: Well we need this sorted asap! I don't care if you have to work 'til midnight!
Cleaning Lady** [passing by, busy hoovering]: Sounds to me like you should have used a transaction...
[Exeunt stage left martin_hughes, chortling]
* I assume he is, he looks like one, at any rate.
** Added under poetic licence for comedy reasons.
|
|
|
|
|
martin_hughes wrote: * I assume he is, he looks like one, at any rate.
I'm curious, what does a VB6er look like these days?
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|