Changeset 88853 in webkit


Ignore:
Timestamp:
Jun 14, 2011 2:39:32 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-06-14 Anders Carlsson <andersca@apple.com>

Reviewed by Darin Adler.

Add functions for encoding/decoding data with a known size and alignment
https://bugs.webkit.org/show_bug.cgi?id=62663

  • Platform/CoreIPC/ArgumentDecoder.cpp: (CoreIPC::ArgumentDecoder::decodeFixedLengthData):
  • Platform/CoreIPC/ArgumentDecoder.h:
  • Platform/CoreIPC/ArgumentEncoder.cpp: (CoreIPC::ArgumentEncoder::encodeFixedLengthData): (CoreIPC::ArgumentEncoder::encodeVariableLengthData):
  • Platform/CoreIPC/ArgumentEncoder.h:
Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r88846 r88853  
     12011-06-14  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Add functions for encoding/decoding data with a known size and alignment
     6        https://bugs.webkit.org/show_bug.cgi?id=62663
     7
     8        * Platform/CoreIPC/ArgumentDecoder.cpp:
     9        (CoreIPC::ArgumentDecoder::decodeFixedLengthData):
     10        * Platform/CoreIPC/ArgumentDecoder.h:
     11        * Platform/CoreIPC/ArgumentEncoder.cpp:
     12        (CoreIPC::ArgumentEncoder::encodeFixedLengthData):
     13        (CoreIPC::ArgumentEncoder::encodeVariableLengthData):
     14        * Platform/CoreIPC/ArgumentEncoder.h:
     15
    1162011-06-14  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp

    r86945 r88853  
    103103}
    104104
     105bool ArgumentDecoder::decodeFixedLengthData(uint8_t* data, size_t size, unsigned alignment)
     106{
     107    if (!alignBufferPosition(size, alignment))
     108        return false;
     109
     110    memcpy(data, m_bufferPos, size);
     111    m_bufferPos += size;
     112
     113    return true;
     114}
     115
    105116bool ArgumentDecoder::decodeBytes(Vector<uint8_t>& buffer)
    106117{
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h

    r85755 r88853  
    4747    bool isInvalid() const { return m_bufferPos > m_bufferEnd; }
    4848    void markInvalid() { m_bufferPos = m_bufferEnd + 1; }
     49
     50    bool decodeFixedLengthData(uint8_t*, size_t, unsigned alignment);
    4951
    5052    bool decodeBytes(Vector<uint8_t>&);
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp

    r86574 r88853  
    8686}
    8787
     88void ArgumentEncoder::encodeFixedLengthData(const uint8_t* data, size_t size, unsigned alignment)
     89{
     90    uint8_t* buffer = grow(alignment, size);
     91    memcpy(buffer, data, size);
     92}
     93
     94void ArgumentEncoder::encodeVariableLengthData(const uint8_t* data, size_t size, unsigned alignment)
     95{
     96    // Encode the size.
     97    encodeUInt64(static_cast<uint64_t>(size));
     98
     99    // Encode the data.
     100    encodeFixedLengthData(data, size, alignment);
     101}
     102
    88103void ArgumentEncoder::encodeBytes(const uint8_t* bytes, size_t size)
    89104{
  • trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h

    r73662 r88853  
    4141    static PassOwnPtr<ArgumentEncoder> create(uint64_t destinationID);
    4242    ~ArgumentEncoder();
     43
     44    void encodeFixedLengthData(const uint8_t*, size_t, unsigned alignment);
     45    void encodeVariableLengthData(const uint8_t*, size_t, unsigned alignment);
    4346
    4447    void encodeBytes(const uint8_t*, size_t);
Note: See TracChangeset for help on using the changeset viewer.