forked from enlightenment/efl
memfile abstraction for the solaris/bsd weenies :) :) :)
SVN revision: 6651
This commit is contained in:
parent
c969e9a7c9
commit
37fbcbf7d7
|
@ -15,6 +15,9 @@ AC_C_CONST
|
||||||
AM_ENABLE_SHARED
|
AM_ENABLE_SHARED
|
||||||
AM_PROG_LIBTOOL
|
AM_PROG_LIBTOOL
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS(fmemopen)
|
||||||
|
AC_CHECK_FUNCS(open_memstream)
|
||||||
|
|
||||||
if test "x${exec_prefix}" = "xNONE"; then
|
if test "x${exec_prefix}" = "xNONE"; then
|
||||||
if test "x${prefix}" = "xNONE"; then
|
if test "x${prefix}" = "xNONE"; then
|
||||||
bindir="${ac_default_prefix}/bin";
|
bindir="${ac_default_prefix}/bin";
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef _EET_PRIVATE_H
|
||||||
|
#define _EET_PRIVATE_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#define _GNU_SOURCE /* need this for fmemopen & open_memstream */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <fnmatch.h>
|
||||||
|
#include <jpeglib.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
|
FILE *_eet_memfile_read_open(void *data, size_t size);
|
||||||
|
void _eet_memfile_read_close(FILE *f);
|
||||||
|
FILE *_eet_memfile_write_open(void **data, size_t *size);
|
||||||
|
void _eet_memfile_write_close(FILE *f);
|
||||||
|
|
||||||
|
#endif
|
|
@ -13,7 +13,9 @@ lib_LTLIBRARIES = libeet.la
|
||||||
include_HEADERS = Eet.h
|
include_HEADERS = Eet.h
|
||||||
libeet_la_SOURCES = \
|
libeet_la_SOURCES = \
|
||||||
eet_lib.c \
|
eet_lib.c \
|
||||||
eet_data.c
|
eet_data.c \
|
||||||
|
eet_memfile.c \
|
||||||
|
Eet_private.h
|
||||||
|
|
||||||
libeet_la_LIBADD = $(LDFLAGS) -lz -ljpeg
|
libeet_la_LIBADD = $(LDFLAGS) -lz -ljpeg
|
||||||
libeet_la_DEPENDENCIES = $(top_builddir)/config.h
|
libeet_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||||
|
|
|
@ -1,21 +1,5 @@
|
||||||
#include "Eet.h"
|
#include "Eet.h"
|
||||||
#define _GNU_SOURCE /* need this for fmemopen & open_memstream */
|
#include "Eet_private.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <zlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <fnmatch.h>
|
|
||||||
#include <jpeglib.h>
|
|
||||||
#include <setjmp.h>
|
|
||||||
#include <zlib.h>
|
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rotuines for doing data -> struct and struct -> data conversion
|
* rotuines for doing data -> struct and struct -> data conversion
|
||||||
|
@ -252,7 +236,7 @@ eet_data_image_jpeg_rgb_decode(void *data, int size, int *w, int *h)
|
||||||
int x, y, l, i, scans, count, prevy;
|
int x, y, l, i, scans, count, prevy;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fmemopen(data, (size_t)size, "r");
|
f = _eet_memfile_read_open(data, (size_t)size);
|
||||||
if (!f) return NULL;
|
if (!f) return NULL;
|
||||||
cinfo.err = jpeg_std_error(&(jerr.pub));
|
cinfo.err = jpeg_std_error(&(jerr.pub));
|
||||||
jerr.pub.error_exit = _JPEGFatalErrorHandler;
|
jerr.pub.error_exit = _JPEGFatalErrorHandler;
|
||||||
|
@ -261,7 +245,7 @@ eet_data_image_jpeg_rgb_decode(void *data, int size, int *w, int *h)
|
||||||
if (setjmp(jerr.setjmp_buffer))
|
if (setjmp(jerr.setjmp_buffer))
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
jpeg_create_decompress(&cinfo);
|
jpeg_create_decompress(&cinfo);
|
||||||
|
@ -279,14 +263,14 @@ eet_data_image_jpeg_rgb_decode(void *data, int size, int *w, int *h)
|
||||||
if (cinfo.rec_outbuf_height > 16)
|
if (cinfo.rec_outbuf_height > 16)
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tdata = malloc((*w) * 16 * 3);
|
tdata = malloc((*w) * 16 * 3);
|
||||||
if (!tdata)
|
if (!tdata)
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
d = malloc((*w) * (*h) * 4);
|
d = malloc((*w) * (*h) * 4);
|
||||||
|
@ -294,7 +278,7 @@ eet_data_image_jpeg_rgb_decode(void *data, int size, int *w, int *h)
|
||||||
{
|
{
|
||||||
free(tdata);
|
free(tdata);
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ptr2 = d;
|
ptr2 = d;
|
||||||
|
@ -345,7 +329,7 @@ eet_data_image_jpeg_rgb_decode(void *data, int size, int *w, int *h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(tdata);
|
free(tdata);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
/* end data decoding */
|
/* end data decoding */
|
||||||
jpeg_finish_decompress(&cinfo);
|
jpeg_finish_decompress(&cinfo);
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
|
@ -362,7 +346,7 @@ eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, int *w,
|
||||||
int x, y, l, i, scans, count, prevy;
|
int x, y, l, i, scans, count, prevy;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fmemopen(data, (size_t)size, "r");
|
f = _eet_memfile_read_open(data, (size_t)size);
|
||||||
if (!f) return NULL;
|
if (!f) return NULL;
|
||||||
cinfo.err = jpeg_std_error(&(jerr.pub));
|
cinfo.err = jpeg_std_error(&(jerr.pub));
|
||||||
jerr.pub.error_exit = _JPEGFatalErrorHandler;
|
jerr.pub.error_exit = _JPEGFatalErrorHandler;
|
||||||
|
@ -371,7 +355,7 @@ eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, int *w,
|
||||||
if (setjmp(jerr.setjmp_buffer))
|
if (setjmp(jerr.setjmp_buffer))
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
jpeg_create_decompress(&cinfo);
|
jpeg_create_decompress(&cinfo);
|
||||||
|
@ -385,13 +369,13 @@ eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, int *w,
|
||||||
if ((*w) != cinfo.output_width)
|
if ((*w) != cinfo.output_width)
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if ((*h) != cinfo.output_height)
|
if ((*h) != cinfo.output_height)
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*w = cinfo.output_width;
|
*w = cinfo.output_width;
|
||||||
|
@ -401,14 +385,14 @@ eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, int *w,
|
||||||
if (cinfo.rec_outbuf_height > 16)
|
if (cinfo.rec_outbuf_height > 16)
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tdata = malloc((*w) * 16 * 3);
|
tdata = malloc((*w) * 16 * 3);
|
||||||
if (!tdata)
|
if (!tdata)
|
||||||
{
|
{
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ptr2 = d;
|
ptr2 = d;
|
||||||
|
@ -461,7 +445,7 @@ eet_data_image_jpeg_alpha_decode(void *data, int size, unsigned int *d, int *w,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(tdata);
|
free(tdata);
|
||||||
fclose(f);
|
_eet_memfile_read_close(f);
|
||||||
/* end data decoding */
|
/* end data decoding */
|
||||||
jpeg_finish_decompress(&cinfo);
|
jpeg_finish_decompress(&cinfo);
|
||||||
jpeg_destroy_decompress(&cinfo);
|
jpeg_destroy_decompress(&cinfo);
|
||||||
|
@ -567,7 +551,7 @@ static void *
|
||||||
eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int quality)
|
eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int quality)
|
||||||
{
|
{
|
||||||
int *ptr;
|
int *ptr;
|
||||||
char *d = NULL;
|
void *d = NULL;
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
struct _JPEG_error_mgr jerr;
|
struct _JPEG_error_mgr jerr;
|
||||||
JSAMPROW *jbuf;
|
JSAMPROW *jbuf;
|
||||||
|
@ -575,13 +559,13 @@ eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int
|
||||||
FILE *f;
|
FILE *f;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
f = open_memstream(&d, &sz);
|
f =_eet_memfile_write_open(&d, &sz);
|
||||||
if (!f) return NULL;
|
if (!f) return NULL;
|
||||||
|
|
||||||
buf = malloc(3 * w);
|
buf = malloc(3 * w);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
if (d) free(d);
|
if (d) free(d);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -594,7 +578,7 @@ eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int
|
||||||
{
|
{
|
||||||
jpeg_destroy_compress(&cinfo);
|
jpeg_destroy_compress(&cinfo);
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
if (d) free(d);
|
if (d) free(d);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -630,7 +614,7 @@ eet_data_image_jpeg_convert(int *size, void *data, int w, int h, int alpha, int
|
||||||
|
|
||||||
*size = sz;
|
*size = sz;
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +637,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
|
||||||
|
|
||||||
{
|
{
|
||||||
int *ptr;
|
int *ptr;
|
||||||
char *d = NULL;
|
void *d = NULL;
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
struct _JPEG_error_mgr jerr;
|
struct _JPEG_error_mgr jerr;
|
||||||
JSAMPROW *jbuf;
|
JSAMPROW *jbuf;
|
||||||
|
@ -661,13 +645,13 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
|
||||||
FILE *f;
|
FILE *f;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
f = open_memstream(&d, &sz);
|
f = _eet_memfile_write_open(&d, &sz);
|
||||||
if (!f) return NULL;
|
if (!f) return NULL;
|
||||||
|
|
||||||
buf = malloc(3 * w);
|
buf = malloc(3 * w);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
if (d) free(d);
|
if (d) free(d);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -680,7 +664,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
|
||||||
{
|
{
|
||||||
jpeg_destroy_compress(&cinfo);
|
jpeg_destroy_compress(&cinfo);
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
if (d) free(d);
|
if (d) free(d);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -715,13 +699,13 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
|
||||||
jpeg_destroy_compress(&cinfo);
|
jpeg_destroy_compress(&cinfo);
|
||||||
|
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
d1 = d;
|
d1 = d;
|
||||||
sz1 = sz;
|
sz1 = sz;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
int *ptr;
|
int *ptr;
|
||||||
char *d = NULL;
|
void *d = NULL;
|
||||||
size_t sz = 0;
|
size_t sz = 0;
|
||||||
struct _JPEG_error_mgr jerr;
|
struct _JPEG_error_mgr jerr;
|
||||||
JSAMPROW *jbuf;
|
JSAMPROW *jbuf;
|
||||||
|
@ -729,7 +713,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
|
||||||
FILE *f;
|
FILE *f;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
f = open_memstream(&d, &sz);
|
f = _eet_memfile_write_open(&d, &sz);
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
free(d1);
|
free(d1);
|
||||||
|
@ -739,7 +723,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
|
||||||
buf = malloc(3 * w);
|
buf = malloc(3 * w);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
if (d) free(d);
|
if (d) free(d);
|
||||||
free(d1);
|
free(d1);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -753,7 +737,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
|
||||||
{
|
{
|
||||||
jpeg_destroy_compress(&cinfo);
|
jpeg_destroy_compress(&cinfo);
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
if (d) free(d);
|
if (d) free(d);
|
||||||
free(d1);
|
free(d1);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -787,7 +771,7 @@ eet_data_image_jpeg_alpha_convert(int *size, void *data, int w, int h, int alpha
|
||||||
jpeg_destroy_compress(&cinfo);
|
jpeg_destroy_compress(&cinfo);
|
||||||
|
|
||||||
if (buf) free(buf);
|
if (buf) free(buf);
|
||||||
fclose(f);
|
_eet_memfile_write_close(f);
|
||||||
d2 = d;
|
d2 = d;
|
||||||
sz2 = sz;
|
sz2 = sz;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
#include "Eet.h"
|
#include "Eet.h"
|
||||||
#include <stdio.h>
|
#include "Eet_private.h"
|
||||||
#include <unistd.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <zlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <fnmatch.h>
|
|
||||||
|
|
||||||
#define EET_MAGIC_FILE 0x1ee7ff00
|
#define EET_MAGIC_FILE 0x1ee7ff00
|
||||||
#define EET_MAGIC_FILE_HEADER 0x1ee7ff01
|
#define EET_MAGIC_FILE_HEADER 0x1ee7ff01
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
#include "Eet.h"
|
||||||
|
#include "Eet_private.h"
|
||||||
|
|
||||||
|
FILE *
|
||||||
|
_eet_memfile_read_open(void *data, size_t size)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_FMEMOPEN
|
||||||
|
return fmemopen(data, size, "r");
|
||||||
|
#else
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
f = tmpfile();
|
||||||
|
if (!f) return NULL;
|
||||||
|
fwrite(data, size, 1, f);
|
||||||
|
rewind(f);
|
||||||
|
return f;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_eet_memfile_read_close(FILE *f)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_FMEMOPEN
|
||||||
|
fclose(f);
|
||||||
|
#else
|
||||||
|
fclose(f);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _Eet_Memfile_Write_Info Eet_Memfile_Write_Info;
|
||||||
|
struct _Eet_Memfile_Write_Info
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
void **data;
|
||||||
|
size_t *size;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int _eet_memfile_info_alloc_num = 0;
|
||||||
|
static int _eet_memfile_info_num = 0;
|
||||||
|
static Eet_Memfile_Write_Info *_eet_memfile_info = NULL;
|
||||||
|
|
||||||
|
FILE *
|
||||||
|
_eet_memfile_write_open(void **data, size_t *size)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_OPEN_MEMSTREAM
|
||||||
|
return open_memstream((char **)data, size);
|
||||||
|
#else
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
_eet_memfile_info_num++;
|
||||||
|
if (_eet_memfile_info_num > _eet_memfile_info_alloc_num)
|
||||||
|
{
|
||||||
|
Eet_Memfile_Write_Info *tmp;
|
||||||
|
|
||||||
|
_eet_memfile_info_alloc_num += 16;
|
||||||
|
tmp = realloc(_eet_memfile_info,
|
||||||
|
_eet_memfile_info_alloc_num *
|
||||||
|
sizeof(Eet_Memfile_Write_Info));
|
||||||
|
if (!tmp)
|
||||||
|
{
|
||||||
|
_eet_memfile_info_alloc_num -= 16;
|
||||||
|
_eet_memfile_info_num--;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
_eet_memfile_info = tmp;
|
||||||
|
}
|
||||||
|
f = tmpfile();
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
_eet_memfile_info_num--;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
_eet_memfile_info[_eet_memfile_info_num - 1].f = f;
|
||||||
|
_eet_memfile_info[_eet_memfile_info_num - 1].data = data;
|
||||||
|
_eet_memfile_info[_eet_memfile_info_num - 1].size = size;
|
||||||
|
return f;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_eet_memfile_write_close(FILE *f)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_OPEN_MEMSTREAM
|
||||||
|
fclose(f);
|
||||||
|
#else
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < _eet_memfile_info_num; i++)
|
||||||
|
{
|
||||||
|
if (_eet_memfile_info[i].f == f)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
(*(_eet_memfile_info[i].size)) = fseek(f, 0, SEEK_END);
|
||||||
|
rewind(f);
|
||||||
|
(*(_eet_memfile_info[i].data)) = malloc(*(_eet_memfile_info[i].size));
|
||||||
|
if (!(*(_eet_memfile_info[i].data)))
|
||||||
|
{
|
||||||
|
fclose(f);
|
||||||
|
(*(_eet_memfile_info[i].size)) = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fread((*(_eet_memfile_info[i].data)), (*(_eet_memfile_info[i].size)), 1, f);
|
||||||
|
for (j = i + 1; j < _eet_memfile_info_num; j++)
|
||||||
|
_eet_memfile_info[j - 1] = _eet_memfile_info[j];
|
||||||
|
_eet_memfile_info_num--;
|
||||||
|
fclose(f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
#endif
|
||||||
|
}
|
Loading…
Reference in New Issue