~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to memory.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
extern void checkMemoryChain(void* _p);
 
1
//=========================================================
 
2
//  MusE
 
3
//  Linux Music Editor
 
4
//  $Id: memory.h,v 1.1.1.1 2003/10/29 10:05:18 wschweer Exp $
 
5
//
 
6
//  (C) Copyright 2003 Werner Schweer (ws@seh.de)
 
7
//=========================================================
 
8
 
 
9
#ifndef __MEMORY_H__
 
10
#define __MEMORY_H__
 
11
 
 
12
#include <stdio.h>
 
13
#include <map>
 
14
 
 
15
// most of the following code is based on examples
 
16
// from Bjarne Stroustrup: Die C++ Programmiersprache
 
17
 
 
18
//---------------------------------------------------------
 
19
//   Pool
 
20
//---------------------------------------------------------
 
21
 
 
22
class Pool {
 
23
      struct Verweis {
 
24
            Verweis* next;
 
25
            };
 
26
      struct Chunk {
 
27
            enum { size = 4 * 1024 };
 
28
            Chunk* next;
 
29
            char mem[size];
 
30
            };
 
31
      enum { dimension = 8 };
 
32
      Chunk* chunks[dimension];
 
33
      Verweis* head[dimension];
 
34
      Pool(Pool&);
 
35
      void operator=(Pool&);
 
36
      void grow(int idx);
 
37
 
 
38
   public:
 
39
      Pool();
 
40
      ~Pool();
 
41
      void* alloc(size_t n);
 
42
      void free(void* b, size_t n);
 
43
      };
 
44
 
 
45
//---------------------------------------------------------
 
46
//   alloc
 
47
//---------------------------------------------------------
 
48
 
 
49
inline void* Pool::alloc(size_t n)
 
50
      {
 
51
      int idx = ((n + sizeof(int) - 1) / sizeof(int)) - 1;
 
52
      if (idx >= dimension) {
 
53
            printf("panic: alloc %d\n", n);
 
54
            exit(-1);
 
55
            }
 
56
      if (head[idx] == 0)
 
57
            grow(idx);
 
58
      Verweis* p = head[idx];
 
59
      head[idx] = p->next;
 
60
      return p;
 
61
      }
 
62
 
 
63
//---------------------------------------------------------
 
64
//   free
 
65
//---------------------------------------------------------
 
66
 
 
67
inline void Pool::free(void* b, size_t n)
 
68
      {
 
69
      int idx = ((n + sizeof(int) - 1) / sizeof(int)) - 1;
 
70
      if (idx >= dimension) {
 
71
            printf("panic: alloc %d\n", n);
 
72
            exit(-1);
 
73
            }
 
74
      Verweis* p = static_cast<Verweis*>(b);
 
75
      p->next = head[idx];
 
76
      head[idx] = p;
 
77
      }
 
78
 
 
79
extern Pool midiRTmemoryPool;
 
80
 
 
81
//---------------------------------------------------------
 
82
//   RTalloc
 
83
//---------------------------------------------------------
 
84
 
 
85
template <class T> class RTalloc
 
86
      {
 
87
   public:
 
88
      typedef T         value_type;
 
89
      typedef size_t    size_type;
 
90
      typedef ptrdiff_t difference_type;
 
91
 
 
92
      typedef T*        pointer;
 
93
      typedef const T*  const_pointer;
 
94
 
 
95
      typedef T&        reference;
 
96
      typedef const T&  const_reference;
 
97
 
 
98
      pointer address(reference x) const { return &x; }
 
99
      const_pointer address(const_reference x) const { return &x; }
 
100
 
 
101
      RTalloc();
 
102
      template <class U> RTalloc(const RTalloc<U>&) {}
 
103
      ~RTalloc() {}
 
104
 
 
105
      pointer allocate(size_type n, void * = 0) {
 
106
            return static_cast<T*>(midiRTmemoryPool.alloc(n * sizeof(T)));
 
107
            }
 
108
      void deallocate(pointer p, size_type n) {
 
109
            midiRTmemoryPool.free(p, n * sizeof(T));
 
110
            }
 
111
 
 
112
      RTalloc<T>&  operator=(const RTalloc&) { return *this; }
 
113
      void construct(pointer p, const T& val) {
 
114
            new ((T*) p) T(val);
 
115
            }
 
116
      void destroy(pointer p) {
 
117
            p->~T();
 
118
            }
 
119
      size_type max_size() const { return size_t(-1); }
 
120
 
 
121
      template <class U> struct rebind { typedef RTalloc<U> other; };
 
122
      template <class U> RTalloc& operator=(const RTalloc<U>&) { return *this; }
 
123
      };
 
124
 
 
125
template <class T> RTalloc<T>::RTalloc() {}
 
126
 
 
127
#endif
2
128