- Main Page
- Related Pages
- Classes
- Files
- Examples

- File List
- File Members

# skype-binary.cpp

Go to the documentation of this file.

    00001
    00002 #include "skype-binary.h"
    00003 #include <stdio.h>
    00004
    00005 void SEBinary::set(const void *buf, unsigned int new_size)
    00006 {
    00007         resize(new_size);
    00008
    00009         if (new_size > 0) {
    00010                 set_at_offset(0, buf, new_size);
    00011         }
    00012 }
    00013
    00014 void SEBinary::resize(unsigned int new_size)
    00015 {
    00016         if (len == new_size) return;
    00017
    00018         if (new_size == 0) {
    00019                 free(buffer);
    00020                 buffer = 0;
    00021         } else {
    00022                 if (buffer != 0) {
    00023                         buffer = (unsigned char*) realloc(buffer, new_size);
    00024                 } else {
    00025                         buffer = (unsigned char*) malloc(new_size);
    00026                 }
    00027         }
    00028
    00029         len = new_size;
    00030 }
    00031
    00032 void SEBinary::set_at_offset(unsigned int offset, const void *buf, unsigned int new_size)
    00033 {
    00034         if (buf && new_size) {
    00035                 if (buf != buffer) {
    00036
    00037                         if (offset + new_size > len) {
    00038                                 resize(offset + new_size);
    00039                         }
    00040
    00041                         memmove(buffer + offset, buf, new_size);
    00042                 }
    00043         }
    00044 }
    00045
    00046 bool SEBinary::operator ==(const SEBinary &b) const
    00047 {
    00048         return (b.len == len && !memcmp(b.buffer, buffer, len));
    00049 }
    00050
    00051 const SEBinary & SEBinary::operator=(const SEBinary &b)
    00052 {
    00053         set(b.buffer, b.len);
    00054
    00055         return *this;
    00056 }
    00057
    00058
    00059

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

(c) Skype Technologies S.A. Confidential/Proprietary

Last updated: Fri Jan 27 2012