|
Lines 1-87
Link Here
|
| 1 |
--- src/collection.c.orig Mon Dec 20 08:16:25 2004 |
|
|
| 2 |
+++ src/collection.c Sat Dec 25 23:01:11 2004 |
| 3 |
@@ -713,8 +713,8 @@ |
| 4 |
guchar *base; |
| 5 |
guchar *ptr; |
| 6 |
guchar *end; |
| 7 |
- }; |
| 8 |
- }; |
| 9 |
+ } s; |
| 10 |
+ } u; |
| 11 |
}; |
| 12 |
|
| 13 |
static void free_buffer(struct coll_src *source, guchar * buffer) |
| 14 |
@@ -730,16 +730,16 @@ |
| 15 |
|
| 16 |
if (source->is_file) { |
| 17 |
data = g_new(guchar, length); |
| 18 |
- if (fread(data, 1, length, source->file) != length) { |
| 19 |
+ if (fread(data, 1, length, source->u.file) != length) { |
| 20 |
g_free(data); |
| 21 |
return NULL; |
| 22 |
} |
| 23 |
} else { |
| 24 |
- if (source->ptr + length > source->end) |
| 25 |
+ if (source->u.s.ptr + length > source->u.s.end) |
| 26 |
return NULL; |
| 27 |
|
| 28 |
- data = source->ptr; |
| 29 |
- source->ptr += length; |
| 30 |
+ data = source->u.s.ptr; |
| 31 |
+ source->u.s.ptr += length; |
| 32 |
} |
| 33 |
|
| 34 |
if (is_string && data[length - 1] != '\0') { |
| 35 |
@@ -753,12 +753,12 @@ |
| 36 |
static gint read_char(struct coll_src *source) |
| 37 |
{ |
| 38 |
if (source->is_file) |
| 39 |
- return fgetc(source->file); |
| 40 |
+ return fgetc(source->u.file); |
| 41 |
|
| 42 |
- if (source->ptr >= source->end) |
| 43 |
+ if (source->u.s.ptr >= source->u.s.end) |
| 44 |
return EOF; |
| 45 |
|
| 46 |
- return *(source->ptr++); |
| 47 |
+ return *(source->u.s.ptr++); |
| 48 |
} |
| 49 |
|
| 50 |
static GdkPixbufDestroyNotify destroy_func(struct coll_src *source) |
| 51 |
@@ -930,22 +930,22 @@ |
| 52 |
goto no_mmap; |
| 53 |
} |
| 54 |
|
| 55 |
- source->base = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fileno(file), 0); |
| 56 |
- if (source->base == MAP_FAILED) { |
| 57 |
+ source->u.s.base = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fileno(file), 0); |
| 58 |
+ if (source->u.s.base == MAP_FAILED) { |
| 59 |
perror("mmap"); |
| 60 |
goto no_mmap; |
| 61 |
} |
| 62 |
|
| 63 |
source->is_file = FALSE; |
| 64 |
- source->ptr = source->base; |
| 65 |
- source->end = source->base + length; |
| 66 |
+ source->u.s.ptr = source->u.s.base; |
| 67 |
+ source->u.s.end = source->u.s.base + length; |
| 68 |
goto ok; |
| 69 |
|
| 70 |
no_mmap: |
| 71 |
fseeko(file, 0, SEEK_SET); |
| 72 |
|
| 73 |
source->is_file = TRUE; |
| 74 |
- source->file = file; |
| 75 |
+ source->u.file = file; |
| 76 |
|
| 77 |
ok: |
| 78 |
return source; |
| 79 |
@@ -954,7 +954,7 @@ |
| 80 |
static void destroy_source(struct coll_src *source, gboolean ok) |
| 81 |
{ |
| 82 |
if (ok == FALSE && source->is_file == FALSE) |
| 83 |
- if (munmap(source->base, source->end - source->base) < 0) |
| 84 |
+ if (munmap(source->u.s.base, source->u.s.end - source->u.s.base) < 0) |
| 85 |
perror("munmap"); |
| 86 |
} |
| 87 |
|