Saturday, December 12, 2009

comp.lang.c - 24 new messages in 8 topics - digest

comp.lang.c
http://groups.google.com/group/comp.lang.c?hl=en

comp.lang.c@googlegroups.com

Today's topics:

* difference between free and delete - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/924adda091d24703?hl=en
* Implicit init to 0 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/d091ed64ca3a054f?hl=en
* Advanced data structures - 10 messages, 5 authors
http://groups.google.com/group/comp.lang.c/t/2edd7d58412b2f69?hl=en
* LG Mobile Phones Pakistan - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/2e737c51d6176056?hl=en
* Nokia Mobile Phones in Pakistan - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/ae7227b2fb23cedd?hl=en
* how to know local port used in an udp client ? - 7 messages, 6 authors
http://groups.google.com/group/comp.lang.c/t/8735d94d5c065a4b?hl=en
* determining alignment of objects - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/bb82906701e2e264?hl=en
* ๑۩๑۩๑free shipping wholesale low price nike shox shoes and ed hardy Jeans
etc (www.ecyaya.com) - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c/t/fd31d3977e5f974b?hl=en

==============================================================================
TOPIC: difference between free and delete
http://groups.google.com/group/comp.lang.c/t/924adda091d24703?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 12 2009 7:43 am
From: Ben Bacarisse


Michael Tsang <miklcct@gmail.com> writes:

> bartc wrote:
>
>> Sometimes for quick throwaway programs, I naughtily use implicit int and
>> just have main()."
>>
> Implicit int has been removed from the language already. A conforming
> compiler won't compile this.

A conforming compiler is entitled to compile it if it wants to,
provided it issues a diagnostic.

--
Ben.

==============================================================================
TOPIC: Implicit init to 0
http://groups.google.com/group/comp.lang.c/t/d091ed64ca3a054f?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 12 2009 7:55 am
From: Ben Bacarisse


Michael Tsang <miklcct@gmail.com> writes:

> Noob wrote:
>
>> Hello,
>>
>> I am aware that, on some platforms, the representation of NULL and 0.0
>> may not be all-bits-zero.
>>
>> On such platforms, does setting all bits to 0 with memset invoke UB?
>
> Null pointer can be converted to and from integer 0.

A null pointer is not guaranteed to convert to 0. The conversion is
implementation defined. Conversions from 0 are also implementation
defined unless the 0 is an integer constant expression. For example,
int null = 0; (void *)null == 0 is not guaranteed to be true (though
I'd lay odds on it being true if I had to bet).

<snip>
--
Ben.

==============================================================================
TOPIC: Advanced data structures
http://groups.google.com/group/comp.lang.c/t/2edd7d58412b2f69?hl=en
==============================================================================

== 1 of 10 ==
Date: Sat, Dec 12 2009 7:55 am
From: Eric Sosman


On 12/12/2009 9:54 AM, Stefan Ram wrote:
> jacob navia<jacob@spamsink.net> writes:
>> What I mean with this sentence is that when reading code about an
>> algorithm, it is easier to read if the error handling code is not
>> shown.
>
> I have another definition of »algorithm«: An algorithm is
> the implementation of some feature using the means of a
> specific target language. [...]

You're free to use words in your own way ("Who's to be
master?" -- H.D.), but your definition of "algorithm" is at
variance with the accepted meaning. That's likely to create
confusion and raise barriers to communication, just as if
you made an appointment to meet someone at noon, using your
own private definition of "noon" as "when the Moon rises."

But back to "algorithm:" Under your definition, there's
one "algorithm" for finding the GCD of two numbers in C,
another for C++, another for Basic, another for Java, ...
As a competent programmer, it seems you must learn a new
"algorithm" for every programming language, perhaps even for
every framework. That seems an awfully heavy cognitive burden.

In fact, under your definition "Euclid's Algorithm" is
an empty fiction, and ought to be something like "Euclid's
Recipe" or "Euclid's Way Of Going About It." There is
clearly an implementation-independent Something about this
GCD-finding approach; what do you call that i-i S, since
you use "algorithm" for something else?

Please answer before "noon." ;-)

--
Eric Sosman
esosman@ieee-dot-org.invalid


== 2 of 10 ==
Date: Sat, Dec 12 2009 8:23 am
From: ram@zedat.fu-berlin.de (Stefan Ram)


Eric Sosman <esosman@ieee-dot-org.invalid> writes:
>>I have another definition of »algorithm«: An algorithm is
>>the implementation of some feature using the means of a
>>specific target language. [...]
>one "algorithm" for finding the GCD of two numbers in C,
>another for C++, another for Basic, another for Java, ...

The GCD requires the mod operation. So, when a language
does not have a mod operation, an implementation of the
mod operation becomes part of the implementation of the
GCD, otherwise it don't.

In Haskell, the GCD is very »straightforward«, as it's
fundamental assertions can be written »directly«:

http://en.literateprograms.org/Euclidean_algorithm_(Haskell)

But in Prolog, a »Tricky version« sometimes is needed:

http://en.literateprograms.org/Euclidean_algorithm_%28Prolog%29

, which is another means to calculate the GCD.

The language

http://en.wikipedia.org/wiki/Brain%66%75ck

has yet another set of elementary operations, so someone
who knows how to calculate the GCD using the elementary
operations of C might not be able to calculate it using
the elementary operations of this language »Brain...«.

If you have another definition of »algorithm« than I do,
feel free to post its wording.

== 3 of 10 ==
Date: Sat, Dec 12 2009 8:29 am
From: jacob navia


Stefan Ram a écrit :
>
> If you have another definition of »algorithm« than I do,
> feel free to post its wording.
>

www.dictionary.com:

al⋅go⋅rithm
–noun
A set of rules for solving a problem in a finite number of steps, as for
finding the greatest common divisor.

Origin:
1890–95; var. of algorism, by assoc. with Gk arithmós number. See
arithmetic

Note that no programming language (or language at all) is mentioned.
An algorithm is a set of rules to do something mathematically. The only
condition is that the number of steps should be finite.


== 4 of 10 ==
Date: Sat, Dec 12 2009 8:34 am
From: jacob navia


Stefan Ram a écrit :
> jacob navia <jacob@spamsink.net> writes:
>> In my implementation of the heap I did test for NULL return,
>> and I issue the corresponding error. In a book about advanced
>> data structures that is just a distracting detail.
>
> I would not actually issue from a library function in the
> sense of a side-effect with access to external files or
> consoles or so, but just return 0.

I call the established error function for the container where the error
happens. Depending on the severity of the error, that function
(that the user of the library can replace with a function of
his/her own) the library exists, shows an error message or just returns.
If the library error function returns, then I just pass the error
to the calling function.

jacob


== 5 of 10 ==
Date: Sat, Dec 12 2009 8:37 am
From: ram@zedat.fu-berlin.de (Stefan Ram)


ram@zedat.fu-berlin.de (Stefan Ram) writes:
>In Haskell, the GCD is very »straightforward«, as it's
>fundamental assertions can be written »directly«:

»it's« should be »its« instead.

>But in Prolog, a »Tricky version« sometimes is needed:

And the most obvious example: In a language, where the GCD
can be calculated with the operator »o«, the algorithm for
the GCD of x and y is just »x o y«.

== 6 of 10 ==
Date: Sat, Dec 12 2009 8:40 am
From: ram@zedat.fu-berlin.de (Stefan Ram)


jacob navia <jacob@spamsink.net> writes:
>alâgoârithm
>ânoun
>A set of rules for solving a problem in a finite number of steps, as for
>finding the greatest common divisor.
>Note that no programming language (or language at all) is mentioned.
>An algorithm is a set of rules to do something mathematically. The only
>condition is that the number of steps should be finite.

Those »steps« must assume that some »elementary operations«
are already given. Therefore, the steps depend on those
elementary operations.

You can not give any algorithm without this assumption
(of a given set of elementary operations) (just try it).

== 7 of 10 ==
Date: Sat, Dec 12 2009 8:47 am
From: Phil Carmody


ram@zedat.fu-berlin.de (Stefan Ram) writes:
> jacob navia <jacob@spamsink.net> writes:
>>alâgoârithm
>>ânoun
>>A set of rules for solving a problem in a finite number of steps, as for
>>finding the greatest common divisor.
>>Note that no programming language (or language at all) is mentioned.
>>An algorithm is a set of rules to do something mathematically. The only
>>condition is that the number of steps should be finite.
>
> Those »steps« must assume that some »elementary operations«
> are already given. Therefore, the steps depend on those
> elementary operations.
>
> You can not give any algorithm without this assumption
> (of a given set of elementary operations) (just try it).

Yes, but those steps do not need to assume that those
elementary operations are native to the language, merely
implementable in that language.

Phil
--
Any true emperor never needs to wear clothes. -- Devany on r.a.s.f1


== 8 of 10 ==
Date: Sat, Dec 12 2009 9:08 am
From: ram@zedat.fu-berlin.de (Stefan Ram)


Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>>Those �steps� must assume that some �elementary operations�
>>are already given. Therefore, the steps depend on those
>>elementary operations.
>Yes, but those steps do not need to assume that those
>elementary operations are native to the language, merely
>implementable in that language.

For a calculation to be actually executable in a language,
it is not sufficient for those operations to be merely
"implementable". They have to be /actually implemented/. Thus,
their implementation is a necessary part of the implementation
of the calculation.

In Haskell, the calculation the GCD of x and y just seems to be:

gcd x y

http://www.zvon.org/other/haskell/Outputprelude/gcd_f.html

. In C, it might be written instead:

int gcd( int a, int b )
{ int c; while( a ){ c = a; a = b % a; b = c; }return b; }

(...)

gcd( x, y )

. We see now that in C, where there is no elementary �gcd�
operation as in Haskell, we have to write its implementation
using a loop and other elementary operations (such as �%�).
Thus, this implementation becomes part of the code necessary
to perform the calculation in C.

Therefore, a loop with a remainder operation is a part of
the implementation in C, but not part of the implementation
in Haskell.

So there is not much common between those two
implementations to extract a �general course of action� to
calculate the GCD in an arbitrary language when we do not
know its set of elementary operations.

== 9 of 10 ==
Date: Sat, Dec 12 2009 9:32 am
From: Ben Bacarisse


ram@zedat.fu-berlin.de (Stefan Ram) writes:

> Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>>>Those »steps« must assume that some »elementary operations«
>>>are already given. Therefore, the steps depend on those
>>>elementary operations.
>>Yes, but those steps do not need to assume that those
>>elementary operations are native to the language, merely
>>implementable in that language.
>
> For a calculation to be actually executable in a language,
> it is not sufficient for those operations to be merely
> "implementable". They have to be /actually implemented/. Thus,
> their implementation is a necessary part of the implementation
> of the calculation.
>
> In Haskell, the calculation the GCD of x and y just seems to be:
>
> gcd x y
>
> http://www.zvon.org/other/haskell/Outputprelude/gcd_f.html
>
> . In C, it might be written instead:
>
> int gcd( int a, int b )
> { int c; while( a ){ c = a; a = b % a; b = c; }return b; }
>
> (...)
>
> gcd( x, y )

But these are different algorithms in both senses -- i.e. both Eric's
and your use of the term -- so the example is not a good one. Eric's
question is what, if anything, you call the idea shared by these
two functions (one Haskell, the other C):

igcd a 0 = a
igcd a b = igcd b (a `rem` b)

int igcd(int a, int b)
{
return b ? igcd(b, a % b) : a;
}

Most people are happy to say that they embody some common thing -- a
recursive GCD algorithm -- despite the huge differences in form and,
indeed, semantics. Do you not bother to name or talk about this
commonality?

<snip>
--
Ben.


== 10 of 10 ==
Date: Sat, Dec 12 2009 9:36 am
From: Phil Carmody


ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
>>>Those »steps« must assume that some »elementary operations«
>>>are already given. Therefore, the steps depend on those
>>>elementary operations.
>>Yes, but those steps do not need to assume that those
>>elementary operations are native to the language, merely
>>implementable in that language.
>
> For a calculation to be actually executable in a language,
> it is not sufficient for those operations to be merely
> "implementable". They have to be /actually implemented/.

You're obviously not a theorist. Actual executability is pretty
darn irrelevant when it comes to theoretical algorithmics.

> Thus,
> their implementation is a necessary part of the implementation
> of the calculation.

As that depends on what is false to theoretists, it's just as false.

> In Haskell, the calculation the GCD of x and y just seems to be:
>
> gcd x y

No. _A_ calculation of the GCD is that. There's nothing preventing
an explicit Euclidean algorithm.

Phil
--
Any true emperor never needs to wear clothes. -- Devany on r.a.s.f1

==============================================================================
TOPIC: LG Mobile Phones Pakistan
http://groups.google.com/group/comp.lang.c/t/2e737c51d6176056?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 12 2009 7:57 am
From: arsalan


LG Mobile Phones in Pakistan. Compare Latest LG mobile reviews and
Prices.
For more information www.mobilenetworkzone.blogspot.com

==============================================================================
TOPIC: Nokia Mobile Phones in Pakistan
http://groups.google.com/group/comp.lang.c/t/ae7227b2fb23cedd?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 12 2009 7:58 am
From: arsalan


Nokia Mobile Phone Prices Pakistan. Nokia mobile rates reviews and
features in Pakistan.
For more information www.mobilenetworkzone.blogspot.com

==============================================================================
TOPIC: how to know local port used in an udp client ?
http://groups.google.com/group/comp.lang.c/t/8735d94d5c065a4b?hl=en
==============================================================================

== 1 of 7 ==
Date: Sat, Dec 12 2009 8:05 am
From: Greg2fs


On 12 déc, 11:52, gaze...@shell.xmission.com (Kenny McCormack) wrote:
> In article <920a5816-48ea-430a-b1ea-a8c2709f8...@k17g2000yqh.googlegroups.com>,
>
> Greg2fs  <greg...@gmail.com> wrote:
> >Hello, I know the port used by my udp client to forward it using upnp.
> >How to do ?
>
> >Thanks
>
> Off topic.  Not portable.  Cant discuss it here.  Blah, blah, blah.
>
> --
> Useful clc-related links:
>
>    http://en.wikipedia.org/wiki/Aspergers
>    http://en.wikipedia.org/wiki/Clique
>    http://en.wikipedia.org/wiki/C_programming_language

Isn't it a c group ? I don't understand...


== 2 of 7 ==
Date: Sat, Dec 12 2009 8:18 am
From: Richard Heathfield


In
<6ca6c384-697c-450b-990a-857a3e91314d@d20g2000yqh.googlegroups.com>,
Greg2fs wrote:

> On 12 déc, 11:52, gaze...@shell.xmission.com (Kenny McCormack)
> wrote:
>> In article
>>
<920a5816-48ea-430a-b1ea-a8c2709f8...@k17g2000yqh.googlegroups.com>,
>>
>> Greg2fs <greg...@gmail.com> wrote:
>> >Hello, I know the port used by my udp client to forward it using
>> >upnp. How to do ?
>>
>> >Thanks
>>
>> Off topic. Not portable. Cant discuss it here. Blah, blah, blah.
>>
>> --
>> Useful clc-related links:
>>
>> http://en.wikipedia.org/wiki/Aspergers
>> http://en.wikipedia.org/wiki/Clique
>> http://en.wikipedia.org/wiki/C_programming_language
>
> Isn't it a c group ? I don't understand...

What Kenny is trying to tell you in as objectionable a way as possible
is that your question is actually about the Berkeley sockets API
rather than about the C language. He's right - which is a novel
experience for him - but he could have been infinitely more gracious
about it. Your best bet is probably comp.unix.programmer - even if
you're developing under Win32, for a sockets question you're more
likely to get a good answer in c.u.p than elsewhere.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within


== 3 of 7 ==
Date: Sat, Dec 12 2009 8:32 am
From: gazelle@shell.xmission.com (Kenny McCormack)


In article <6ca6c384-697c-450b-990a-857a3e91314d@d20g2000yqh.googlegroups.com>,
Greg2fs <greg2fs@gmail.com> wrote:
>On 12 d�c, 11:52, gaze...@shell.xmission.com (Kenny McCormack) wrote:
>> In article
><920a5816-48ea-430a-b1ea-a8c2709f8...@k17g2000yqh.googlegroups.com>,
>>
>> Greg2fs �<greg...@gmail.com> wrote:
>> >Hello, I know the port used by my udp client to forward it using upnp.
>> >How to do ?
>>
>> >Thanks
>>
>> Off topic. �Not portable. �Cant discuss it here. �Blah, blah, blah.
>>
>> --
>> Useful clc-related links:
>>
>> � �http://en.wikipedia.org/wiki/Aspergers
>> � �http://en.wikipedia.org/wiki/Clique
>> � �http://en.wikipedia.org/wiki/C_programming_language
>
>Isn't it a c group ? I don't understand...

It was a pre-emptive strike. As you will soon find out, this newsgroup
has been taken over by a bunch of buttheads who have this totally weird
notion about what the C language is. They will be along any second now
to tell you the same thing I just told you, but in much more patronizing
and juvenile tones.

In other words, I was joking. They will not be.

And, welcome to CLC. We hope you enjoy your stay!

== 4 of 7 ==
Date: Sat, Dec 12 2009 8:36 am
From: Richard


gazelle@shell.xmission.com (Kenny McCormack) writes:

> In article <6ca6c384-697c-450b-990a-857a3e91314d@d20g2000yqh.googlegroups.com>,
> Greg2fs <greg2fs@gmail.com> wrote:
>>On 12 déc, 11:52, gaze...@shell.xmission.com (Kenny McCormack) wrote:
>>> In article
>><920a5816-48ea-430a-b1ea-a8c2709f8...@k17g2000yqh.googlegroups.com>,
>>>
>>> Greg2fs  <greg...@gmail.com> wrote:
>>> >Hello, I know the port used by my udp client to forward it using upnp.
>>> >How to do ?
>>>
>>> >Thanks
>>>
>>> Off topic.  Not portable.  Cant discuss it here.  Blah, blah, blah.
>>>
>>> --
>>> Useful clc-related links:
>>>
>>>    http://en.wikipedia.org/wiki/Aspergers
>>>    http://en.wikipedia.org/wiki/Clique
>>>    http://en.wikipedia.org/wiki/C_programming_language
>>
>>Isn't it a c group ? I don't understand...
>
> It was a pre-emptive strike. As you will soon find out, this newsgroup
> has been taken over by a bunch of buttheads who have this totally weird
> notion about what the C language is. They will be along any second now
> to tell you the same thing I just told you, but in much more patronizing
> and juvenile tones.
>
> In other words, I was joking. They will not be.
>
> And, welcome to CLC. We hope you enjoy your stay!
>

Indeed.

But first we need to see some of your code using malloc and the
definition of main().

--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c


== 5 of 7 ==
Date: Sat, Dec 12 2009 8:45 am
From: Barry Schwarz


On Sat, 12 Dec 2009 08:05:57 -0800 (PST), Greg2fs <greg2fs@gmail.com>
wrote:

>On 12 déc, 11:52, gaze...@shell.xmission.com (Kenny McCormack) wrote:
>> In article <920a5816-48ea-430a-b1ea-a8c2709f8...@k17g2000yqh.googlegroups.com>,
>>
>> Greg2fs  <greg...@gmail.com> wrote:
>> >Hello, I know the port used by my udp client to forward it using upnp.
>> >How to do ?
>>
>> >Thanks
>>
>> Off topic.  Not portable.  Cant discuss it here.  Blah, blah, blah.
>>
>> --
>> Useful clc-related links:
>>
>>    http://en.wikipedia.org/wiki/Aspergers
>>    http://en.wikipedia.org/wiki/Clique
>>    http://en.wikipedia.org/wiki/C_programming_language
>
>Isn't it a c group ? I don't understand...

If you hang around long enough you will learn two things at least:

Who enjoys being obnoxious and disruptive.

That this is group about the C language, not about how to use
programs written in C or how to use extensions to the language to
perform system specific tasks. Since the C language as defined in the
ISO standard has no support for ports, udp, or upnp, your question
falls into the latter category. You will get much better responses if
you post the question in a group that deals with upnp.

--
Remove del for email


== 6 of 7 ==
Date: Sat, Dec 12 2009 9:36 am
From: Richard


Barry Schwarz <schwarzb@dqel.com> writes:

> On Sat, 12 Dec 2009 08:05:57 -0800 (PST), Greg2fs <greg2fs@gmail.com>
> wrote:
>
>>On 12 déc, 11:52, gaze...@shell.xmission.com (Kenny McCormack) wrote:
>>> In article <920a5816-48ea-430a-b1ea-a8c2709f8...@k17g2000yqh.googlegroups.com>,
>>>
>>> Greg2fs  <greg...@gmail.com> wrote:
>>> >Hello, I know the port used by my udp client to forward it using upnp.
>>> >How to do ?
>>>
>>> >Thanks
>>>
>>> Off topic.  Not portable.  Cant discuss it here.  Blah, blah, blah.
>>>
>>> --
>>> Useful clc-related links:
>>>
>>>    http://en.wikipedia.org/wiki/Aspergers
>>>    http://en.wikipedia.org/wiki/Clique
>>>    http://en.wikipedia.org/wiki/C_programming_language
>>
>>Isn't it a c group ? I don't understand...
>
> If you hang around long enough you will learn two things at least:
>
> Who enjoys being obnoxious and disruptive.
>
> That this is group about the C language, not about how to use
> programs written in C or how to use extensions to the language to

Wrong. This group is about all C related programming as defined in its
founding charter.

There is no better group to learn about using C and assocated tools and
methods : there a many people with cross platform skills here whereas
"specific" groups tend to be filled with pedantic nit pickers with a
very blinkered view.

> perform system specific tasks. Since the C language as defined in the
> ISO standard has no support for ports, udp, or upnp, your question

What nonsense. These things are written in C more often than not and
more often than not are used using C.

> falls into the latter category. You will get much better responses if
> you post the question in a group that deals with upnp.

Would you like to name a few?

To the OP : if its C related post here. If no one knows then you can
look further afield.

--
"Avoid hyperbole at all costs, its the most destructive argument on
the planet" - Mark McIntyre in comp.lang.c


== 7 of 7 ==
Date: Sat, Dec 12 2009 9:36 am
From: Antoninus Twink


On 12 Dec 2009 at 8:12, Greg2fs wrote:
> Hello, I know the port used by my udp client to forward it using upnp.
> How to do ?

Use getsockname(2).

Or, choose which port to bind to yourself instead of letting the socket
layer choose an available ephemeral port.

Please ignore the trolls who seek to disrupt this newsgroup by
restricting discussion of valid C programming topics like networking.


==============================================================================
TOPIC: determining alignment of objects
http://groups.google.com/group/comp.lang.c/t/bb82906701e2e264?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Dec 12 2009 8:27 am
From: mohangupta13


On Dec 12, 4:35 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> mohangupta13 <mohangupt...@gmail.com> writes:
> > hello all ,
>
> I can't recall if you've had answers.  Forgive the noise if you
> have...
>
>
>
> > in the paper "engineering a sort function ", the author has used a
> > code fragment like:
> > typedef long WORD
> > #define W sizeof(WORD)
> > #define SWAPINIT(a,es) swaptype= \
> > (a-(char*)0 | es) % W? 2 : es>W?: 1:0
>
> > They actually have an array a of objects of size es and what they do
> > with this code is determine what type of swapping they will be doing
> > depending upon the alignment of the object , 'a' is an array of. So if
> > 'a' is not *appropriately aligned* they swap byte by byte else world
> > by word.
>
> > Now i had two questions on the above code .
>
> > 1. How does it determine if the object is not appropriately aligned
> > ( means the case when it sets swaptype=2)?
>
> That's the '(a-(char *)0) % W' bit.  a is already a char * pointing at
> the object(s) to be swapped.  The subtraction is intended to get the
> address converted to an integer type so that the mod operation can
> determine if the address is aligned.
>
> They don't convert directly to an integer type because (a) at the time
> there was no obvious type to use and (b) the conversion of a pointer
> to an integer is implementation defined and a footnote suggests that
> at least one implementation was, at the time, unhelpful when doing
> this conversion (high order bits were used to store byte offsets on a
> words addressed Cray).
>
> The '| es' part is unrelated to the alignment test, but it cleverly
> adds in the other criterion that requires a byte-by-byte swap -- that
> the element size is not a multiple of W.
>
> > 2. Isn't it illegal to subtract pointers belonging to two different
> > areas  (and also two different types here as 'a' is not a (char*) its
> > actually a array of type 'object') as 'a' and (char*)0 doesn't point
> > to the same memory area (as we normally would do for two pointers
> > pointing inside the same array)?
>
> Yes, it is, but Bentley and McIlroy are practical people.  They had no
> better way to find out the alignment of a pointer so they used a
> method that they knew worked on a wide range of implementations.  It's
> why the talk about "engineering" a sort function and why the paper was
> published in "Software, Practise and Experience" (one of my favourite
> journals).
>
> I can't think of an implementation I've ever seen that would cause
> problems for this code.  Theoretically, an implementation can decree
> that a - (char *)0 is any value it likes (or none at all).  One in
> which a null pointer was no all bits zero could decree that the
> difference is from its non-zero (and possibly very oddly aligned) null
> pointer, but C implementations are not malicious in practise.
>
> --
> Ben.

Thanks all for your detailed explanations. Thanks a lot.
Mohan

==============================================================================
TOPIC: ๑۩๑۩๑free shipping wholesale low price nike shox shoes and ed hardy
Jeans etc (www.ecyaya.com)
http://groups.google.com/group/comp.lang.c/t/fd31d3977e5f974b?hl=en
==============================================================================

== 1 of 2 ==
Date: Sat, Dec 12 2009 8:35 am
From: hero


๑۩๑۩๑free shipping wholesale low price nike shox shoes and ed hardy
Jeans etc (www.ecyaya.com)


Footwear (paypal payment)( www.ecyaya.com )

Paul Smith shoes

Jordan shoes

Bape shoes (paypal payment)( www.ecyaya.com )

Chanel shoes (paypal payment)( www.ecyaya.com )

D&G shoes

Dior shoes (paypal payment)( www.ecyaya.com )

ED hardy shoes

Evisu shoes

Fendi shoes

Gucci shoe (paypal payment)( www.ecyaya.com )

Hogan shoes (paypal payment)( www.ecyaya.com )

Lv shoes

Prada shoes (paypal payment)( www.ecyaya.com )

Timberland shoes

Tous shoes (paypal payment)( www.ecyaya.com )

Ugg shoes

Ice cream shoes (paypal payment)( www.ecyaya.com )
Sebago shoes (paypal payment)( www.ecyaya.com )

Lacoste shoes

Air force one shoes (paypal payment)( www.ecyaya.com )

TODS shoes

AF shoes (paypal payment)( www.ecyaya.com )

cheap EVISU jeans wholesale www.ecyaya.com

cheap ED hardy jeans wholesale

cheap COOGI jeans wholesale www.ecyaya.com

cheap GINO GREEN GLOBAL jeans wholesale

cheap LACOSTE jeans wholesale www.ecyaya.com

cheap G-STAR jeans wholesale www.ecyaya.com

cheap KED ROBOT jeans wholesale

cheap RED MONKEY jeans wholesale www.ecyaya.com

cheap ADIDAS jeans wholesale www.ecyaya.com

cheap BBC jeans wholesale

cheap BOSS jeans wholesale www.ecyaya.com

cheap LRG jeans wholesale

cheap HELEN jeans wholesale www.ecyaya.com

cheap JUICY jeans wholesale

cheap THE CROUN HOLDER jeans wholesale www.ecyaya.com

cheap SMET jeans wholesale www.ecyaya.com

cheap SEVEN jeans wholesale www.ecyaya.com

cheap TRUN NORTH FACE jeans wholesale

cheap children jeans wholesale www.ecyaya.com

cheap ARMANI jeans wholesale www.ecyaya.com

cheap BAPE jeans wholesale

cheap LEVIS jeans wholesale www.ecyaya.com

cheap ANTIK jeans wholesale www.ecyaya.com

cheap true religion jeans wholesale www.ecyaya.com

== 2 of 2 ==
Date: Sat, Dec 12 2009 8:35 am
From: hero


๑۩๑۩๑free shipping wholesale low price nike shox shoes and ed hardy
Jeans etc (www.ecyaya.com)


Footwear (paypal payment)( www.ecyaya.com )

Paul Smith shoes

Jordan shoes

Bape shoes (paypal payment)( www.ecyaya.com )

Chanel shoes (paypal payment)( www.ecyaya.com )

D&G shoes

Dior shoes (paypal payment)( www.ecyaya.com )

ED hardy shoes

Evisu shoes

Fendi shoes

Gucci shoe (paypal payment)( www.ecyaya.com )

Hogan shoes (paypal payment)( www.ecyaya.com )

Lv shoes

Prada shoes (paypal payment)( www.ecyaya.com )

Timberland shoes

Tous shoes (paypal payment)( www.ecyaya.com )

Ugg shoes

Ice cream shoes (paypal payment)( www.ecyaya.com )
Sebago shoes (paypal payment)( www.ecyaya.com )

Lacoste shoes

Air force one shoes (paypal payment)( www.ecyaya.com )

TODS shoes

AF shoes (paypal payment)( www.ecyaya.com )

cheap EVISU jeans wholesale www.ecyaya.com

cheap ED hardy jeans wholesale

cheap COOGI jeans wholesale www.ecyaya.com

cheap GINO GREEN GLOBAL jeans wholesale

cheap LACOSTE jeans wholesale www.ecyaya.com

cheap G-STAR jeans wholesale www.ecyaya.com

cheap KED ROBOT jeans wholesale

cheap RED MONKEY jeans wholesale www.ecyaya.com

cheap ADIDAS jeans wholesale www.ecyaya.com

cheap BBC jeans wholesale

cheap BOSS jeans wholesale www.ecyaya.com

cheap LRG jeans wholesale

cheap HELEN jeans wholesale www.ecyaya.com

cheap JUICY jeans wholesale

cheap THE CROUN HOLDER jeans wholesale www.ecyaya.com

cheap SMET jeans wholesale www.ecyaya.com

cheap SEVEN jeans wholesale www.ecyaya.com

cheap TRUN NORTH FACE jeans wholesale

cheap children jeans wholesale www.ecyaya.com

cheap ARMANI jeans wholesale www.ecyaya.com

cheap BAPE jeans wholesale

cheap LEVIS jeans wholesale www.ecyaya.com

cheap ANTIK jeans wholesale www.ecyaya.com

cheap true religion jeans wholesale www.ecyaya.com

==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c?hl=en

To unsubscribe from this group, send email to comp.lang.c+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate