initial code

master
Daniel Kolesa 2015-04-06 00:05:21 +01:00
parent f5f24bb46d
commit 962f3ff2ff
4 changed files with 103 additions and 1 deletions

30
COPYING.md 100644
View File

@ -0,0 +1,30 @@
OctaSTD is licensed under the University of Illinois/NCSA Open Source License,
a permissive, non-copyleft, BSD style license. The license text goes as follows:
Copyright (c) 2015 Daniel "q66" Kolesa. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
* Neither the names of OctaSTD developers nor any contributors may be
used to endorse or promote products derived from this Software without
specific prior written permission.
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.**

View File

@ -3,4 +3,7 @@
OctaSTD is a collection of C++ utilities to aid the upcoming OctaForge C++
API. It provides containers (dynamic arrays etc) as well as other utilities.
Currently implemented:
Currently implemented:
* new/delete operators
* vector

36
octastd/new.h 100644
View File

@ -0,0 +1,36 @@
/* Default new/delete operator overloads for OctaSTD.
*
* This file is part of OctaSTD. See COPYING.txt for futher information.
*/
#ifndef OCTASTD_NEW_H
#define OCTASTD_NEW_H
#include <stdlib.h>
inline void *operator new(size_t size) {
void *p = malloc(size);
if (!p) abort();
return p;
}
inline void *operator new[](size_t size) {
void *p = malloc(size);
if (!p) abort();
return p;
}
inline void operator delete(void *p) {
free(p);
}
inline void operator delete[](void *p) {
free(p);
}
inline void *operator new (size_t, void *p) { return p; }
inline void *operator new [](size_t, void *p) { return p; }
inline void operator delete (void *, void *) {}
inline void operator delete[](void *, void *) {}
#endif

33
octastd/vector.h 100644
View File

@ -0,0 +1,33 @@
/* Self-expanding dynamic array implementation for OctaSTD.
*
* This file is part of OctaSTD. See COPYING.txt for futher information.
*/
#ifndef OCTASTD_VECTOR_H
#define OCTASTD_VECTOR_H
#include <octastd/new.h>
namespace octastd {
template<typename T>
class vector {
T *buf;
size_t length, capacity;
public:
explicit vector(): buf(NULL), length(0), capacity(0) {}
vector(const vector &v): buf(NULL), length(0), capacity(0) {
*this = v;
}
~vector() {
}
vector<T> &operator=(const vector<T> &v) {
return *this;
}
};
}
#endif