summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xxdelta1/libedsio/default.c65
-rwxr-xr-xxdelta1/libedsio/edsio.el2
-rwxr-xr-xxdelta1/libedsio/edsio.h15
-rwxr-xr-xxdelta1/libedsio/fh.c5
-rwxr-xr-xxdelta1/libedsio/generic.c11
-rwxr-xr-xxdelta1/xdelta.c6
-rwxr-xr-xxdelta1/xdelta.prj20
7 files changed, 41 insertions, 83 deletions
diff --git a/xdelta1/libedsio/default.c b/xdelta1/libedsio/default.c
index 8c9f347..0da2176 100755
--- a/xdelta1/libedsio/default.c
+++ b/xdelta1/libedsio/default.c
@@ -18,6 +18,7 @@ sink_type_default (SerialSink* sink, SerialType type, guint32 len, gboolean set_
18 if (! sink->next_uint32 (sink, type)) 18 if (! sink->next_uint32 (sink, type))
19 return FALSE; 19 return FALSE;
20 20
21 /* Note: set_allocation is deprecated in 1.1.4 */
21 if (set_allocation && !sink->next_uint32 (sink, len)) 22 if (set_allocation && !sink->next_uint32 (sink, len))
22 return FALSE; 23 return FALSE;
23 24
@@ -146,7 +147,9 @@ source_type_default (SerialSource* source, gboolean set_allocation)
146 147
147 if (set_allocation) 148 if (set_allocation)
148 { 149 {
149 if (! source->next_uint32 (source, &source->alloc_total)) 150 /* Note: set_allocation is deprecated in 1.1.4 */
151 guint32 bogus;
152 if (! source->next_uint32 (source, &bogus))
150 return ST_Error; 153 return ST_Error;
151 } 154 }
152 155
@@ -283,66 +286,27 @@ source_next_bytes_known (SerialSource* source, guint8 *ptr, guint32 len)
283void* 286void*
284serializeio_source_alloc (SerialSource* source, guint32 len) 287serializeio_source_alloc (SerialSource* source, guint32 len)
285{ 288{
289 AllocList *al;
286 void* ret; 290 void* ret;
287 291
288 if (! source->alloc_buf) 292 if (source->salloc_func)
289 { 293 {
290 if (source->salloc_func) 294 ret = source->salloc_func (source, len);
291 source->alloc_buf_orig = source->salloc_func (source, source->alloc_total + 8); 295 al = source->salloc_func (source, sizeof(AllocList));
292 else
293 source->alloc_buf_orig = g_malloc0 (source->alloc_total + 8);
294
295 source->alloc_buf = source->alloc_buf_orig;
296
297 { long x = source->alloc_buf; ALIGN_8 (x); source->alloc_buf = x; }
298
299 } 296 }
300 297 else
301 if (len+source->alloc_pos > source->alloc_total)
302 { 298 {
303 edsio_generate_source_event (EC_EdsioIncorrectAllocation, source); 299 ret = g_malloc0 (len);
304 return NULL; 300 al = g_malloc0 (sizeof(AllocList));
305 } 301 }
306 302
307 ret = ((guint8*)source->alloc_buf) + source->alloc_pos; 303 al->ptr = ret;
308 304 al->next = source->alloc_list;
309 source->alloc_pos += len; 305 source->alloc_list = al;
310
311 ALIGN_8 (source->alloc_pos);
312
313 g_assert (((long)ret) % 8 == 0);
314 g_assert (source->alloc_pos % 8 == 0);
315 306
316 return ret; 307 return ret;
317} 308}
318 309
319gboolean
320serializeio_source_object_received (SerialSource* source)
321{
322 source->alloc_pos = 0;
323 source->alloc_total = 0;
324 source->alloc_buf_orig = NULL;
325 source->alloc_buf = NULL;
326
327 return TRUE;
328}
329
330void
331serializeio_source_reset_allocation (SerialSource* source)
332{
333 source->alloc_pos = 0;
334 source->alloc_total = 0;
335 source->alloc_buf = NULL;
336
337 if (source->alloc_buf_orig)
338 {
339 if (source->sfree_func)
340 source->sfree_func (source, source->alloc_buf_orig);
341 else
342 g_free (source->alloc_buf_orig);
343 }
344}
345
346void 310void
347serializeio_source_init (SerialSource* it, 311serializeio_source_init (SerialSource* it,
348 SerialType (* source_type) (SerialSource* source, 312 SerialType (* source_type) (SerialSource* source,
@@ -357,6 +321,7 @@ serializeio_source_init (SerialSource* it,
357 void (* sfree_func) (SerialSource* source, 321 void (* sfree_func) (SerialSource* source,
358 void* ptr)) 322 void* ptr))
359{ 323{
324 it->alloc_list = NULL;
360 it->next_bytes_known = source_next_bytes_known; 325 it->next_bytes_known = source_next_bytes_known;
361 it->next_bytes = source_next_bytes; 326 it->next_bytes = source_next_bytes;
362 it->next_uint = source_next_uint; 327 it->next_uint = source_next_uint;
diff --git a/xdelta1/libedsio/edsio.el b/xdelta1/libedsio/edsio.el
index b28f623..d8cd91e 100755
--- a/xdelta1/libedsio/edsio.el
+++ b/xdelta1/libedsio/edsio.el
@@ -869,8 +869,6 @@ replacement is as for replace-regexp."
869 869
870 (insert (format " if (! unserialize_%s_internal (source, result)) goto bail;\n" ent-downcase)) 870 (insert (format " if (! unserialize_%s_internal (source, result)) goto bail;\n" ent-downcase))
871 871
872 (insert (format " if (! serializeio_source_object_received (source)) goto bail;\n"))
873
874 (insert (format " return TRUE;\n")) 872 (insert (format " return TRUE;\n"))
875 (insert (format "bail:\n")) 873 (insert (format "bail:\n"))
876 (insert (format " return FALSE;\n")) 874 (insert (format " return FALSE;\n"))
diff --git a/xdelta1/libedsio/edsio.h b/xdelta1/libedsio/edsio.h
index 06b5647..98f899e 100755
--- a/xdelta1/libedsio/edsio.h
+++ b/xdelta1/libedsio/edsio.h
@@ -28,6 +28,7 @@ typedef gint32 SerialType;
28typedef struct _HandleFuncTable HandleFuncTable; 28typedef struct _HandleFuncTable HandleFuncTable;
29typedef struct _PropTest PropTest; 29typedef struct _PropTest PropTest;
30typedef struct _FileHandle FileHandle; 30typedef struct _FileHandle FileHandle;
31typedef struct _AllocList AllocList;
31 32
32struct _FileHandle { 33struct _FileHandle {
33 const HandleFuncTable* table; 34 const HandleFuncTable* table;
@@ -49,7 +50,6 @@ struct _FileHandle {
49#define ALIGN_8(v) if (((v) % 8) != 0) { (v) += 8; (v) &= ~7; } 50#define ALIGN_8(v) if (((v) % 8) != 0) { (v) += 8; (v) &= ~7; }
50 51
51/* This serves as a virtual table for I/O to the FileHandle */ 52/* This serves as a virtual table for I/O to the FileHandle */
52
53struct _HandleFuncTable 53struct _HandleFuncTable
54{ 54{
55 gssize (* table_handle_length) (FileHandle *fh); 55 gssize (* table_handle_length) (FileHandle *fh);
@@ -67,12 +67,14 @@ struct _HandleFuncTable
67 const gchar* (* table_handle_name) (FileHandle *fh); /* user must free */ 67 const gchar* (* table_handle_name) (FileHandle *fh); /* user must free */
68}; 68};
69 69
70struct _AllocList {
71 AllocList *next;
72 void *ptr;
73};
74
70struct _SerialSource { 75struct _SerialSource {
71 /* Internal variables: don't touch. */ 76 /* Internal variables: don't touch. */
72 guint32 alloc_total; 77 AllocList *alloc_list;
73 guint32 alloc_pos;
74 void *alloc_buf;
75 void *alloc_buf_orig;
76 78
77 /* These are setup by init. 79 /* These are setup by init.
78 */ 80 */
@@ -187,8 +189,7 @@ void serializeio_source_init (SerialSource* source,
187 void (* sfree_func) (SerialSource* source, 189 void (* sfree_func) (SerialSource* source,
188 void* ptr)); 190 void* ptr));
189 191
190/* These two functions are internal, don't use. */ 192/* This function is internal, don't use. */
191gboolean serializeio_source_object_received (SerialSource* source);
192void* serializeio_source_alloc (SerialSource* source, 193void* serializeio_source_alloc (SerialSource* source,
193 guint32 len); 194 guint32 len);
194 195
diff --git a/xdelta1/libedsio/fh.c b/xdelta1/libedsio/fh.c
index e93dd77..6b27cbf 100755
--- a/xdelta1/libedsio/fh.c
+++ b/xdelta1/libedsio/fh.c
@@ -90,7 +90,9 @@ handle_source_type (SerialSource* source, gboolean set_allocation)
90 90
91 if (set_allocation) 91 if (set_allocation)
92 { 92 {
93 if (! ssource->fh->table->table_handle_getui (ssource->fh, &source->alloc_total)) 93 /* Note: set_allocation is deprecated in 1.1.4 */
94 guint32 bogus;
95 if (! ssource->fh->table->table_handle_getui (ssource->fh, &bogus))
94 return ST_Error; 96 return ST_Error;
95 } 97 }
96 98
@@ -127,6 +129,7 @@ handle_sink_type (SerialSink* sink, SerialType type, guint len, gboolean set_all
127 if (! ssink->fh->table->table_handle_putui (ssink->fh, type)) 129 if (! ssink->fh->table->table_handle_putui (ssink->fh, type))
128 return FALSE; 130 return FALSE;
129 131
132 /* Note: set_allocation is deprecated in 1.1.4 */
130 if (set_allocation && ! ssink->fh->table->table_handle_putui (ssink->fh, len)) 133 if (set_allocation && ! ssink->fh->table->table_handle_putui (ssink->fh, len))
131 return FALSE; 134 return FALSE;
132 135
diff --git a/xdelta1/libedsio/generic.c b/xdelta1/libedsio/generic.c
index fb96e9a..96d246a 100755
--- a/xdelta1/libedsio/generic.c
+++ b/xdelta1/libedsio/generic.c
@@ -24,8 +24,6 @@ typedef struct {
24static GArray *ser_array; 24static GArray *ser_array;
25static gboolean ser_array_sorted; 25static gboolean ser_array_sorted;
26 26
27void serializeio_source_reset_allocation (SerialSource* source);
28
29void 27void
30serializeio_initialize_type (const char* name, 28serializeio_initialize_type (const char* name,
31 guint32 val, 29 guint32 val,
@@ -127,17 +125,8 @@ serializeio_unserialize_generic_internal (SerialSource *source,
127 if (ent) 125 if (ent)
128 { 126 {
129 res = ent->unserialize_func (source, object); 127 res = ent->unserialize_func (source, object);
130
131 if (set_allocation && res)
132 {
133 if (! serializeio_source_object_received (source))
134 return FALSE;
135 }
136 } 128 }
137 129
138 if (set_allocation)
139 serializeio_source_reset_allocation (source);
140
141 return res; 130 return res;
142} 131}
143 132
diff --git a/xdelta1/xdelta.c b/xdelta1/xdelta.c
index 3012afc..ff9b934 100755
--- a/xdelta1/xdelta.c
+++ b/xdelta1/xdelta.c
@@ -316,6 +316,8 @@ xdp_source_index_read (XdeltaSource *xs,
316 if (! ss) 316 if (! ss)
317 return FALSE; 317 return FALSE;
318 318
319 /* TODO: free ss */
320
319 if (! unserialize_xdeltaindex (ss, &index)) 321 if (! unserialize_xdeltaindex (ss, &index))
320 return FALSE; 322 return FALSE;
321 323
@@ -325,8 +327,6 @@ xdp_source_index_read (XdeltaSource *xs,
325 xs->ck_count = index->index_len; 327 xs->ck_count = index->index_len;
326 xs->cksums = index->index; 328 xs->cksums = index->index;
327 329
328 /* @@@ how to free this? */
329
330 return TRUE; 330 return TRUE;
331} 331}
332 332
@@ -1419,6 +1419,8 @@ xdp_control_read (XdeltaStream *cont_in)
1419 if (! src) 1419 if (! src)
1420 return NULL; 1420 return NULL;
1421 1421
1422 /* TODO: free src */
1423
1422 if (! serializeio_unserialize_generic_acceptable (src, ST_XdeltaControl | ST_Version0Control, & type, (void**) & cont)) 1424 if (! serializeio_unserialize_generic_acceptable (src, ST_XdeltaControl | ST_Version0Control, & type, (void**) & cont))
1423 return NULL; 1425 return NULL;
1424 1426
diff --git a/xdelta1/xdelta.prj b/xdelta1/xdelta.prj
index ff7eee9..cc4b6bb 100755
--- a/xdelta1/xdelta.prj
+++ b/xdelta1/xdelta.prj
@@ -1,11 +1,11 @@
1;; -*- PRCS -*- 1;; -*- PRCS -*-
2(Created-By-Prcs-Version 1 3 4) 2(Created-By-Prcs-Version 1 3 4)
3(Project-Description "") 3(Project-Description "")
4(Project-Version xdelta 1.1-maint 14) 4(Project-Version xdelta 1.1-maint 15)
5(Parent-Version xdelta 1.1-maint 13) 5(Parent-Version xdelta 1.1-maint 14)
6(Version-Log "") 6(Version-Log "fixed the source allocation problem, free() was never being called and still isn't, added 2 TODOs for freeing source/control handles")
7(New-Version-Log "") 7(New-Version-Log "")
8(Checkin-Time "Sun, 28 Jan 2007 11:23:01 -0800") 8(Checkin-Time "Sun, 28 Jan 2007 12:21:11 -0800")
9(Checkin-Login jmacd) 9(Checkin-Login jmacd)
10(Populate-Ignore ("\\.o$" 10(Populate-Ignore ("\\.o$"
11 "\\.deps" 11 "\\.deps"
@@ -60,7 +60,7 @@
60 ;; Library 60 ;; Library
61 (xdelta.h (xdelta/b/8_xdelta.h 1.4.1.8.1.50.1.3 744)) 61 (xdelta.h (xdelta/b/8_xdelta.h 1.4.1.8.1.50.1.3 744))
62 (xdeltapriv.h (xdelta/c/42_xdeltapriv 1.29 744)) 62 (xdeltapriv.h (xdelta/c/42_xdeltapriv 1.29 744))
63 (xdelta.c (xdelta/b/14_xdelta.c 1.4.1.50.1.3 744)) 63 (xdelta.c (xdelta/b/14_xdelta.c 1.4.1.50.1.4 744))
64 (xd.ser (xdelta/d/7_xd.ser 1.12 744)) 64 (xd.ser (xdelta/d/7_xd.ser 1.12 744))
65 (xdrsync.c (xdelta/d/44_xdrsync.c 1.2 744)) 65 (xdrsync.c (xdelta/d/44_xdrsync.c 1.2 744))
66 (xdapply.c (xdelta/e/37_xdapply.c 1.1 744)) 66 (xdapply.c (xdelta/e/37_xdapply.c 1.1 744))
@@ -98,19 +98,19 @@
98 ;; Files added by populate at Sun, 28 Jan 2007 10:01:31 -0800, 98 ;; Files added by populate at Sun, 28 Jan 2007 10:01:31 -0800,
99 ;; to version 1.1-maint.12(w), by jmacd: 99 ;; to version 1.1-maint.12(w), by jmacd:
100 100
101 (libedsio/fh.c (xdelta/i/9_fh.c 1.1 744)) 101 (libedsio/fh.c (xdelta/i/9_fh.c 1.2 744))
102 (libedsio/maketime.c (xdelta/i/10_maketime.c 1.1 744)) 102 (libedsio/maketime.c (xdelta/i/10_maketime.c 1.1 744))
103 (libedsio/simple.c (xdelta/i/11_simple.c 1.1 744)) 103 (libedsio/simple.c (xdelta/i/11_simple.c 1.1 744))
104 (libedsio/md5c.c (xdelta/i/12_md5c.c 1.1 744)) 104 (libedsio/md5c.c (xdelta/i/12_md5c.c 1.1 744))
105 (libedsio/Makefile.am (xdelta/i/13_Makefile.a 1.1 744)) 105 (libedsio/Makefile.am (xdelta/i/13_Makefile.a 1.1 744))
106 (libedsio/base64.c (xdelta/i/15_base64.c 1.1 744)) 106 (libedsio/base64.c (xdelta/i/15_base64.c 1.1 744))
107 (libedsio/default.c (xdelta/i/16_default.c 1.1 744)) 107 (libedsio/default.c (xdelta/i/16_default.c 1.2 744))
108 (libedsio/edsio.el (xdelta/i/18_edsio.el 1.1 744)) 108 (libedsio/edsio.el (xdelta/i/18_edsio.el 1.2 744))
109 (libedsio/edsio-comp (xdelta/i/19_edsio-comp 1.1 744)) 109 (libedsio/edsio-comp (xdelta/i/19_edsio-comp 1.1 744))
110 (libedsio/generic.c (xdelta/i/20_generic.c 1.1 744)) 110 (libedsio/generic.c (xdelta/i/20_generic.c 1.2 744))
111 (libedsio/sha.c (xdelta/i/21_sha.c 1.1 744)) 111 (libedsio/sha.c (xdelta/i/21_sha.c 1.1 744))
112 (libedsio/edsio.ser (xdelta/i/22_edsio.ser 1.1 744)) 112 (libedsio/edsio.ser (xdelta/i/22_edsio.ser 1.1 744))
113 (libedsio/edsio.h (xdelta/i/23_edsio.h 1.1 744)) 113 (libedsio/edsio.h (xdelta/i/23_edsio.h 1.2 744))
114 (libedsio/partime.h (xdelta/i/24_partime.h 1.1 744)) 114 (libedsio/partime.h (xdelta/i/24_partime.h 1.1 744))
115 (libedsio/library.c (xdelta/i/25_library.c 1.1 744)) 115 (libedsio/library.c (xdelta/i/25_library.c 1.1 744))
116 (libedsio/edsio.c (xdelta/i/26_edsio.c 1.1 744)) 116 (libedsio/edsio.c (xdelta/i/26_edsio.c 1.1 744))