~ubuntu-branches/debian/experimental/cuneiform/experimental

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/puma/main/mymem.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-10 17:58:10 UTC
  • Revision ID: james.westby@ubuntu.com-20090710175810-rqc89d2i3tki9m89
Tags: upstream-0.7.0+dfsg
Import upstream version 0.7.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 1993-2008, Cognitive Technologies
 
3
All rights reserved.
 
4
 
 
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
 
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
 
7
 
 
8
      * ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
 
9
        ���� ����������� �� ��������� �����, ���� ������ ������� � �����������
 
10
        ����� �� ��������.
 
11
      * ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
 
12
        ������ ����������, ������������ ��� ���������������, ������ �����������
 
13
        ��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
 
14
        ����������� ����� �� ��������.
 
15
      * �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
 
16
        ���� ������������ � �������� �������� ��������� �/��� �����������
 
17
        ���������, ���������� �� ���� ��, ��� ���������������� �����������
 
18
        ����������.
 
19
 
 
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
 
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
 
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
 
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
 
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
 
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
 
26
������������� ������, ��������� � �������������� ��� ���������� ����������
 
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
 
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
 
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
 
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
 
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
32
 
 
33
Redistribution and use in source and binary forms, with or without modification,
 
34
are permitted provided that the following conditions are met:
 
35
 
 
36
    * Redistributions of source code must retain the above copyright notice,
 
37
      this list of conditions and the following disclaimer.
 
38
    * Redistributions in binary form must reproduce the above copyright notice,
 
39
      this list of conditions and the following disclaimer in the documentation
 
40
      and/or other materials provided with the distribution.
 
41
    * Neither the name of the Cognitive Technologies nor the names of its
 
42
      contributors may be used to endorse or promote products derived from this
 
43
      software without specific prior written permission.
 
44
 
 
45
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
46
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
47
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
48
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 
49
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
50
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
51
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
52
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
53
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
55
*/
 
56
 
 
57
#include <stdio.h>
 
58
#include <stdlib.h>
 
59
 
 
60
#include "resource.h"
 
61
#include "mpuma.h"
 
62
 
 
63
// ��� ������������� ��� CFIO.DLL
 
64
#ifndef _DEBUG
 
65
        #define _DEBUG
 
66
#endif
 
67
 
 
68
 
 
69
//####################################
 
70
void *  myAlloc(size_t stAllocateBlock)
 
71
{
 
72
        char * mem = NULL;
 
73
 
 
74
//#ifdef _DEBUG
 
75
 
 
76
        mem = (char *)malloc(stAllocateBlock);
 
77
        if(!mem)
 
78
                SetReturnCode_puma(IDS_ERR_NO_MEMORY);
 
79
//#endif
 
80
 
 
81
        return mem;
 
82
}
 
83
//####################################
 
84
void    myFree(void * mem)
 
85
{
 
86
//#ifdef _DEBUG
 
87
        free(mem);
 
88
//#endif
 
89
}
 
90
 
 
91
Handle  myOpenSave(char * lpName)
 
92
{
 
93
        Handle rc = NULL;
 
94
//#ifdef _DEBUG
 
95
        rc = (Handle)fopen(lpName,"wb");
 
96
//#endif
 
97
        return rc;
 
98
}
 
99
Handle  myOpenRestore(char * lpName)
 
100
{
 
101
        Handle rc = NULL;
 
102
//#ifdef _DEBUG
 
103
        rc = (Handle)fopen(lpName,"rb");
 
104
//#endif
 
105
        return rc;
 
106
}
 
107
unsigned int  myWrite(Handle h,void * lpdata,unsigned int size)
 
108
{
 
109
        Word32 rc = 0;
 
110
//#ifdef _DEBUG
 
111
        rc = fwrite(lpdata,1,size,(FILE*)h);
 
112
//#endif
 
113
        return rc;
 
114
}
 
115
unsigned int  myRead(Handle h,void * lpdata,unsigned int size)
 
116
{
 
117
        Word32 rc = 0;
 
118
//#ifdef _DEBUG
 
119
        rc = fread(lpdata,1,size,(FILE *)h);
 
120
//#endif
 
121
        return rc;
 
122
}
 
123
void    myClose(Handle h)
 
124
{
 
125
//#ifdef _DEBUG
 
126
        fclose((FILE*)h);
 
127
//#endif
 
128
}
 
129
 
 
130
 
 
131
static Word8* Buffer;
 
132
static Word8* WorkMem;
 
133
 
 
134
void GiveMainBuff (void **vvBuff, int *Size)
 
135
{
 
136
        *vvBuff = Buffer;
 
137
        *Size = BufferSize;
 
138
}
 
139
 
 
140
void GiveWorkBuff (void **vvBuff, int *Size)
 
141
{
 
142
        *vvBuff = WorkMem;
 
143
        *Size = WorkMemSize;
 
144
}
 
145
 
 
146
Bool32 InitMem()
 
147
{
 
148
        Buffer=NULL;
 
149
        Buffer=(Word8*)myAlloc(BufferSize);
 
150
        if(!Buffer)
 
151
                return FALSE;
 
152
        WorkMem=NULL;
 
153
        WorkMem=(Word8*)myAlloc(WorkMemSize);
 
154
        if(!WorkMem)
 
155
                return FALSE;
 
156
        return TRUE;
 
157
}
 
158
 
 
159
void DoneMem()
 
160
{
 
161
        if(Buffer)
 
162
          myFree(Buffer);
 
163
        Buffer=NULL;
 
164
        if(WorkMem)
 
165
          myFree(WorkMem);
 
166
        WorkMem=NULL;
 
167
}