Re: How to read a 8-bit grayscale JPEG image using C?




"Kelsey Bjarnason" <kbjarnason@xxxxxxxxx> wrote in message news:5huun4-lrn.ln1@xxxxxxxxxxxxxxxxxxxxxxx
[snips]

On Thu, 19 Jul 2007 21:20:02 +0100, Malcolm McLean wrote:

Buy my book, Basic Algorithms.

Or not. Let's see:

int strlen(const char *str)

You follow up your example with one that uses size_t and even explains why
you should use size_t... which raises the obvious question why include
such a badly broken example at all?


This is followed up by, among other things, strcount which counts the
number of characters in a string. Problem: it returns an int, which
you've already said, on that very page, is a bad idea, yet here you go
doing it again, apparently oblivious to the notion that the string could
just as easily be longer than the range of an int *and* be filled with a
single character.

int squnch(void *data, int len, void *out)

Er... no. Once again, a complete failure to grasp the concept of size_t
and its reason for existence. One might also ask the utility of
(len & 0xFF000000) >> 24; where len is an int and the code is being
compiled on a 16-bit implementation. One might *also* ask the reasoning
behind using *signed* ints for sizes; do you expect a lot of negative
length buffers to compress?

In fact, the entire example set seems to suggest a serious fetish for
using inappropriate types and inappropriate assumptions on sizes and the
like. How the hell did you get this past a reviewer or editor?

I do most of my programming on parallel hardware.
There is no interface for passing size_ts over the system. You can do so, of course, by hardcoding in the bit size, or converting to integers, or simply passing as a bit buffer. But that sort of thing adds complexity I don't need.

There are good reasons for disliking size_t. That's just one of them. It certainly isn't a case of not being able to grasp the concept. I explain, rightly or wrongly, in the first paragraphs the coding conventions I am using, and the justification for them.
The programs contain operations on integers, characters, and reals. I don't want a zoo of types.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

.



Relevant Pages

  • Re: pid_t data type
    ... "The implementation shall support one or more programming environments ... then it *is* save to store pid_t's in a long. ... is a big reason to use pid_t's. ... Because these usually return ints, ...
    (comp.unix.programmer)
  • Re: Checking for a keypress on Linux ?????
    ... the short delay in kbhit() ... > int getch; ... > * returns the number of characters available to read. ... > static struct termios Otty, ...
    (comp.os.linux.development.apps)
  • Re: [PATCH] Fix console utf8 composing
    ... So, the result is that the result of the composing operation is still taken from the accent_table, and thus cannot be more than "unsigned char" allows. ... in UTF-8 mode, it is possible to generate characters from Latin-1 set by composing, and they are generated correctly. ... +static int use_unicode; ...
    (Linux-Kernel)
  • Re: [PATCH] console UTF-8 fixes
    ... as substitute glyph ... don't ignore zero-width characters (except for a few zero-width spaces ... print an extra space for double-wide characters for the cursor to stand ... int first; ...
    (Linux-Kernel)
  • Re: Get ASCII value for character when higher than 127
    ... The reason I want to store the int-values for the characters in stead ... I also imagined, that if I have the int value, I can perform some ... char timeString; ... strcat; ...
    (microsoft.public.vc.language)