Bug Tracker – Attachment #512: switch memio functions to use the system heap for bug #1103

View | Details | Raw Unified | Return to bug 1103
Collapse All | Expand All

(-)common/m_memio.cpp (-7 / +7 lines)
Lines 59-65 Link Here
59
{
59
{
60
	MEMFILE *file;
60
	MEMFILE *file;
61
61
62
	file = (MEMFILE *)Z_Malloc(sizeof(MEMFILE), PU_STATIC, 0);
62
	file = new MEMFILE;
63
63
64
	file->buf = (unsigned char *) buf;
64
	file->buf = (unsigned char *) buf;
65
	file->buflen = buflen;
65
	file->buflen = buflen;
Lines 107-116 Link Here
107
{
107
{
108
	MEMFILE *file;
108
	MEMFILE *file;
109
109
110
	file = (MEMFILE *)Z_Malloc(sizeof(MEMFILE), PU_STATIC, 0);
110
	file = new MEMFILE;
111
111
112
	file->alloced = 1024;
112
	file->alloced = 1024;
113
	file->buf = (unsigned char *)Z_Malloc(file->alloced, PU_STATIC, 0);
113
	file->buf = new unsigned char[file->alloced];
114
	file->buflen = 0;
114
	file->buflen = 0;
115
	file->position = 0;
115
	file->position = 0;
116
	file->mode = MODE_WRITE;
116
	file->mode = MODE_WRITE;
Lines 138-146 Link Here
138
	{
138
	{
139
		unsigned char *newbuf;
139
		unsigned char *newbuf;
140
140
141
		newbuf = (unsigned char *)Z_Malloc(stream->alloced * 2, PU_STATIC, 0);
141
		newbuf = new unsigned char[stream->alloced * 2];
142
		memcpy(newbuf, stream->buf, stream->alloced);
142
		memcpy(newbuf, stream->buf, stream->alloced);
143
		Z_Free(stream->buf);
143
        delete[] stream->buf;
144
		stream->buf = newbuf;
144
		stream->buf = newbuf;
145
		stream->alloced *= 2;
145
		stream->alloced *= 2;
146
	}
146
	}
Lines 166-175 Link Here
166
{
166
{
167
	if (stream->mode == MODE_WRITE)
167
	if (stream->mode == MODE_WRITE)
168
	{
168
	{
169
		Z_Free(stream->buf);
169
		delete[] stream->buf;
170
	}
170
	}
171
171
172
	Z_Free(stream);
172
	delete stream;
173
}
173
}
174
174
175
long mem_ftell(MEMFILE *stream)
175
long mem_ftell(MEMFILE *stream)

Return to bug 1103