LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-09-2004, 04:05 AM   #16
elektron
LQ Newbie
 
Registered: Jul 2004
Location: Cave
Distribution: slack, gentoo, debian, roothat
Posts: 8

Rep: Reputation: 0

Quote:
Originally posted by Dark_Helmet

elektron:
Take that code and run with it
Just a pointer: I noticed you swapped some things around a bit; All those "return X" statements for unexpected error conditions were to give a non-zero exit result for the program (just to follow traditional *nix guidelines). In your computeCRC32 function, you return 0 on those same error conditions. The only problem I see is that value gets assigned to the crc value. In theory, 0x00000000 is a valid CRC 32 value. It might be rare (specifically a 1 in about 4 billion chance), but in such a case, you wouldn't be able to distinguish whether it's a legitimate CRC or an error.
sure. the functions return an unsigned long value, which doesn't necesarily support returning negative numbers and as you point out zero and positive numbers are possible crc values. i don't code c to often. in python i could just raise an exception on an error. but i digress, this will of course need to be addressed.

Quote:
Also, you have a slight memory leak... Here's the sequence:
1. The malloc() in generateCRC32() goes off without a hitch
2. Suppose the open() call fails (returns -1)
In that scenario, you return from the generateCRC32() without freeing the memory for file_buffer. If the user supplied more than one filename on the command line, the possibility exists that you could chew through memory quickly.
this is a good point, there is a possibility of that, and it can be remedied easily. coming from more of a scripting background, it's easy to forget to check for such things in a c program. thank you ^_^
 
Old 07-09-2004, 07:10 AM   #17
elektron
LQ Newbie
 
Registered: Jul 2004
Location: Cave
Distribution: slack, gentoo, debian, roothat
Posts: 8

Rep: Reputation: 0
both of the aforementioned bugs should be fixed and avail at : http://kremlor.net/projects/crc32/
 
Old 07-09-2004, 01:15 PM   #18
Apostasy
Member
 
Registered: Jun 2004
Location: Wisconsin
Distribution: Ubuntu
Posts: 31

Original Poster
Rep: Reputation: 15
corruption is not really viable.. seeing how calcchecksum app is giving me the values that correspond to the filenames.. so that is what i'm currently using for files which i do not know the values of.
as for the 'container' format i mentioned.. an .ogm or .mkv video file usually has a video track.. multiple audio tracks (languages) and subtitle text files all in one file.. it is even possible to have multiple video tracks in the same file... although i have not yet seen that yet in any of my files. a compatible media player can switch subs or audio tracks at the users command.. much like watching a dvd in your livingroom. if an avi is also a container format forgive me,, i didn't know that.

bbiaf.. must try that new code

<EDIT>
[root@boojie Puni Puni Poemy]# crc32 Puni.Puni.Poemy.01.Poemi.Is.In.A.Bad.Mood.\[AXP.DVDRip\].\[Dual.Audio\].\[7A9F8C2A\].ogm
Puni.Puni.Poemy.01.Poemi.Is.In.A.Bad.Mood.[AXP.DVDRip].[Dual.Audio].[7A9F8C2A].ogm 0x7A9F8C2A

success! </EDIT>

Last edited by Apostasy; 07-09-2004 at 01:24 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[N00B] Generate filenames from a file! Dee-ehn Programming 12 12-28-2004 11:06 AM
How may I tell gcc to generate an assembly file? LongName Programming 4 08-30-2004 03:31 AM
crc Straterra Slackware - Installation 2 03-05-2004 05:06 PM
Perl Script Reading a txt file and generate html to be published! kofi Linux - Software 1 09-22-2003 06:12 PM
How can I find/generate a kernel .config file? David Reid Linux - Newbie 5 08-08-2002 06:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration