~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/xpdflib/array.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2005-02-24 22:09:16 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050224220916-9vxiiqjz066r5489
Tags: 6.0pre23-2
debian/control: Ipe should depend on exact version of libipe.
Closes: #296771.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//========================================================================
2
 
//
3
 
// Array.cc
4
 
//
5
 
// Copyright 1996-2002 Glyph & Cog, LLC
6
 
//
7
 
//========================================================================
8
 
 
9
 
#include "aconf.h"
10
 
 
11
 
#ifdef USE_GCC_PRAGMAS
12
 
#pragma implementation
13
 
#endif
14
 
 
15
 
#include <stddef.h>
16
 
#include "gmem.h"
17
 
#include "object.h"
18
 
#include "array.h"
19
 
 
20
 
//------------------------------------------------------------------------
21
 
// Array
22
 
//------------------------------------------------------------------------
23
 
 
24
 
Array::Array(XRef *xrefA) {
25
 
  xref = xrefA;
26
 
  elems = NULL;
27
 
  size = length = 0;
28
 
  ref = 1;
29
 
}
30
 
 
31
 
Array::~Array() {
32
 
  int i;
33
 
 
34
 
  for (i = 0; i < length; ++i)
35
 
    elems[i].free();
36
 
  gfree(elems);
37
 
}
38
 
 
39
 
void Array::add(Object *elem) {
40
 
  if (length + 1 > size) {
41
 
    size += 8;
42
 
    elems = (Object *)grealloc(elems, size * sizeof(Object));
43
 
  }
44
 
  elems[length] = *elem;
45
 
  ++length;
46
 
}
47
 
 
48
 
Object *Array::get(int i, Object *obj) {
49
 
  return elems[i].fetch(xref, obj);
50
 
}
51
 
 
52
 
Object *Array::getNF(int i, Object *obj) {
53
 
  return elems[i].copy(obj);
54
 
}