ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Algorithm-FEC/FEC.xs
(Generate patch)

Comparing Algorithm-FEC/FEC.xs (file contents):
Revision 1.1 by root, Tue Sep 9 05:52:49 2003 UTC vs.
Revision 1.2 by root, Tue Sep 9 06:07:28 2003 UTC

67 Newz (0, self->b_sz , self->dp, int); 67 Newz (0, self->b_sz , self->dp, int);
68 Newz (0, self->b_sv , self->dp, SV *); 68 Newz (0, self->b_sv , self->dp, SV *);
69} 69}
70 70
71static void 71static void
72force_addrs (struct state *self) 72force_addrs (struct state *self, int dp)
73{ 73{
74 int i; 74 int i;
75 75
76 for (i = 0; i < self->dp; i++) 76 for (i = 0; i < dp; i++)
77 if (self->b_sv[i]) 77 if (self->b_sv[i])
78 { 78 {
79 STRLEN size; 79 STRLEN size;
80 self->b_addr[i] = SvPV (self->b_sv[i], size); 80 self->b_addr[i] = SvPV (self->b_sv[i], size);
81 81
82 if (size != self->sz) 82 if (size != self->sz)
83 croak ("block #%d (a string) has size %d, not %d", i, (int)size, self->sz); 83 croak ("block #%d (a string) has size %d, not %d", i, (int)size, self->sz);
84 } else if (!self->b_mmap[i]) { 84 } else if (!self->b_mmap[i]) {
85 croak ("block #%d neither string nor file, did set_encode_blocks fail and you ignored it?", i); 85 croak ("block #%d neither string nor file, did set_blocks fail and you ignored it?", i);
86 } 86 }
87} 87}
88 88
89static void 89static void
90open_file (struct state *self, int idx, SV *sv, int rw) 90open_file (struct state *self, int idx, SV *sv, int rw)
179 RETVAL->ep = encoded_packets; 179 RETVAL->ep = encoded_packets;
180 OUTPUT: 180 OUTPUT:
181 RETVAL 181 RETVAL
182 182
183void 183void
184set_encode_blocks (self, blocks) 184set_blocks (self, blocks)
185 Convert::FEC self 185 Convert::FEC self
186 SV * blocks 186 SV * blocks
187 CODE: 187 CODE:
188 188
189 free_files (self); 189 free_files (self);
203 if (block_index < 0 || self->ep <= block_index) 203 if (block_index < 0 || self->ep <= block_index)
204 croak ("encode: block_index %d out of range, must be 0 <= block_index < %d", 204 croak ("encode: block_index %d out of range, must be 0 <= block_index < %d",
205 block_index, self->ep); 205 block_index, self->ep);
206 206
207 if (!self->b_addr) 207 if (!self->b_addr)
208 croak ("no blocks specified by a preceding call to set_encode_blocks"); 208 croak ("no blocks specified by a preceding call to set_blocks");
209 209
210 force_addrs (self); 210 force_addrs (self, self->dp);
211 211
212 RETVAL = newSV (self->sz); 212 RETVAL = newSV (self->sz);
213 if (!RETVAL) 213 if (!RETVAL)
214 croak ("unable to allocate result block (out of memory)"); 214 croak ("unable to allocate result block (out of memory)");
215 SvPOK_only (RETVAL); 215 SvPOK_only (RETVAL);
233 233
234 chk_array (blocks, self->dp, "decode", "blocks"); 234 chk_array (blocks, self->dp, "decode", "blocks");
235 chk_array (indices, self->dp, "decode", "indices"); 235 chk_array (indices, self->dp, "decode", "indices");
236 open_files (self, (AV *)SvRV (blocks), 1); 236 open_files (self, (AV *)SvRV (blocks), 1);
237 237
238 force_addrs (self); 238 force_addrs (self, self->dp);
239 239
240 Newz (0, idx, self->dp, int); 240 Newz (0, idx, self->dp, int);
241 241
242 /* copy and check */ 242 /* copy and check */
243 for (i = 0; i < self->dp; i++) 243 for (i = 0; i < self->dp; i++)
287 287
288 free_files (self); 288 free_files (self);
289} 289}
290 290
291void 291void
292copy_block (srcblock, dstblock) 292copy (self, srcblock, dstblock)
293 Convert::FEC self
293 SV * srcblock 294 SV * srcblock
294 SV * dstblock 295 SV * dstblock
295 CODE: 296 CODE:
296 croak ("urgs"); 297 realloc_files (self);
298 open_file (self, 0, srcblock, 0);
299 open_file (self, 1, dstblock, 1);
300 force_addrs (self, 2);
301 Copy (self->b_addr[0], self->b_addr[1], self->sz, char);
302 free_files (self);
297 303
298void 304void
299DESTROY(self) 305DESTROY(self)
300 Convert::FEC self 306 Convert::FEC self
301 CODE: 307 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines