Delta Encoding - Sample C Code

Sample C Code

The following C code performs a simple form of delta encoding and decoding:

void delta_encode (char *buffer, const unsigned int length) { char delta = 0; char original; unsigned int i; for (i = 0; i < length; ++i) { original = buffer; buffer -= delta; delta = original; } } void delta_decode (char *buffer, const unsigned int length) { char delta = 0; unsigned int i; for (i = 0; i < length; ++i) { buffer += delta; delta = buffer; } }

Read more about this topic:  Delta Encoding

Famous quotes containing the words sample and/or code:

    As a rule they will refuse even to sample a foreign dish, they regard such things as garlic and olive oil with disgust, life is unliveable to them unless they have tea and puddings.
    George Orwell (1903–1950)

    Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a “sock” in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.
    George Bernard Shaw (1856–1950)