-2001-02-09 Andre Poenitz <poenitz@HTWM.De>
+2001-02-09 André Pönitz <poenitz@htwm.de>
+ * array.h: replace array buffer 'byte bf[]' by 'std::vector<byte> bf'
+ * several files: subsequent changes
* math_iter.h: remove unused prototype
* array.h: ditto.
compiling with lyxstring, but STL sstream).
(Metrics): ditto.
-2001-02-08 Andre Poenitz <poenitz@HTWM.De>
+2001-02-08 André Pönitz <poenitz@htwm.de>
* several files: get rid of reinterpret_cast.
* the GNU General Public Licence version 2 or later.
*/
-#include <string.h>
+#include <vector>
#ifndef byte
#define byte unsigned char
*/
class LyxArrayBase {
public:
+ ///
+ typedef std::vector<byte> buffer_type;
///
enum {
///
///
explicit
LyxArrayBase(int size = ARRAY_STEP);
- ///
- LyxArrayBase(LyxArrayBase const &);
- ///
- ~LyxArrayBase();
-
- /// Constructs a new array with dx elements starting at pos
- LyxArrayBase & operator=(LyxArrayBase const &);
///
int empty() const { return (last == 0); }
///
int Last() { return last; }
- /// Fills with 0 the entire array and set last to 0
- void Init();
-
/// Make the allocated memory fit the needed size
void Fit();
bool Move(int p, int shift);
/// Buffer
- byte * bf;
+ buffer_type bf;
/// Last position inserted.
int last;
/// Max size of the array.
/************************ Inline functions *****************************/
-inline
-void LyxArrayBase::Init()
-{
- memset(bf, 0, maxsize);
- last = 0;
-}
-
inline // Hmmm, Hp-UX's CC can't handle this inline. Asger.
void LyxArrayBase::Resize(int newsize)
{
if (newsize<ARRAY_MIN_SIZE)
newsize = ARRAY_MIN_SIZE;
newsize += ARRAY_STEP - (newsize % ARRAY_STEP);
- byte *nwbf = new byte[newsize];
+ bf.resize(newsize);
if (last >= newsize) last = newsize-1;
maxsize = newsize;
- memcpy(nwbf, bf, last);
- delete[] bf;
- bf = nwbf;
bf[last] = 0;
}
LyxArrayBase::LyxArrayBase(int size)
{
maxsize = (size<ARRAY_MIN_SIZE) ? ARRAY_MIN_SIZE: size;
- bf = new byte[maxsize]; // this leaks
- Init();
-}
-
-inline
-LyxArrayBase::~LyxArrayBase()
-{
- delete[] bf;
-}
-
-inline
-LyxArrayBase::LyxArrayBase(LyxArrayBase const & a)
-{
- maxsize = a.maxsize;
- bf = new byte[maxsize];
- memcpy(&bf[0], &a.bf[0], maxsize);
- last = a.last;
-}
-
-inline
-LyxArrayBase & LyxArrayBase::operator=(LyxArrayBase const & a)
-{
- if (this != &a) {
- Resize(a.maxsize);
- memcpy(&bf[0], &a.bf[0], maxsize);
- }
- return *this;
+ bf.resize(maxsize);
+ last = 0;
}
inline
if (l) {
os << '\\' << l->name << ' ';
} else {
- lyxerr << "Illegal symbol code[" << c
- << " " << str.end() - s << " " << data.FCode() << "]";
+#warning this does not compile on gcc 2.97
+ //lyxerr << "Illegal symbol code[" << c
+ // << " " << str.end() - s << " " << data.FCode() << "]";
}
} else {
// Is there a standard logical XOR?