From 8286ac511144e4f17d34eac9affb97e50646344a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:25:44 +0200 Subject: Imported Upstream version 4.0.0 --- libcult/cult/mm/buffer.cxx | 140 --------------------------------------------- 1 file changed, 140 deletions(-) delete mode 100644 libcult/cult/mm/buffer.cxx (limited to 'libcult/cult/mm/buffer.cxx') diff --git a/libcult/cult/mm/buffer.cxx b/libcult/cult/mm/buffer.cxx deleted file mode 100644 index c3a28ff..0000000 --- a/libcult/cult/mm/buffer.cxx +++ /dev/null @@ -1,140 +0,0 @@ -// file : cult/mm/buffer.cxx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Boris Kolpackov -// license : GNU GPL v2 + exceptions; see accompanying LICENSE file - -#include - -#include // malloc, realloc, free -#include // memcpy - -namespace Cult -{ - namespace MM - { - Buffer:: - ~Buffer () - { - std::free (b_); - } - - Buffer:: - Buffer (Size capacity, Size size) throw (ZeroCapacity, Bounds, BadAlloc) - : c_ (capacity), s_ (size), p_ (0) - { - if (c_ == 0) throw ZeroCapacity (); - if (s_ > c_) throw Bounds (); - - b_ = std::malloc (c_); - - if (b_ == 0) throw BadAlloc (); - } - - Buffer:: - Buffer (void const* p, size_t s) - : c_ (s), s_ (s), p_ (0) - { - if (c_ == 0) throw ZeroCapacity (); - - b_ = std::malloc (c_); - - if (b_ == 0) throw BadAlloc (); - - std::memcpy (b_, p, s); - } - - - Buffer:: - Buffer (Buffer const& b) - : c_ (b.c_), s_ (b.s_), p_ (b.p_) - { - b_ = std::malloc (c_); - - if (b_ == 0) throw BadAlloc (); - - std::memcpy (b_, b.b_, s_); - } -/* - Buffer& - operator= (Buffer const&) - { - return *this; - } -*/ - - // capacity - // - - Size Buffer:: - capacity () const throw () - { - return c_; - } - - Boolean Buffer:: - capacity (Size c) throw (ZeroCapacity, Bounds, BadAlloc) - { - if (c == 0) throw ZeroCapacity (); - if (s_ > c) throw Bounds (); - - Void* b (std::realloc (b_, c)); - - if (b == 0) throw BadAlloc (); - - c_ = c; - - if (b == b_) return false; - - b_ = b; - - return true; - } - - // size - // - - Size Buffer:: - size () const throw () - { - return s_; - } - - void Buffer:: - size (Size s) throw (Bounds) - { - if (s > c_ || p_ > s) throw Bounds (); - - s_ = s; - } - - // position - // - - Index Buffer:: - position () const throw () - { - return p_; - } - - Void Buffer:: - position (Index p) throw (Bounds) - { - if (p > s_) throw Bounds (); - - p_ = p; - } - - - Char const* Buffer:: - data () const - { - return reinterpret_cast (b_); - } - - Char* Buffer:: - data () - { - return reinterpret_cast (b_); - } - } -} -- cgit v1.2.3