[xiph-cvs] cvs commit: ogg/src bitwise.c framing.c
Segher Boessenkool
segher at xiph.org
Mon Oct 1 17:15:05 PDT 2001
segher 01/10/01 17:15:04
Modified: src bitwise.c framing.c
Log:
sizeof() cleanup.
Revision Changes Path
1.8 +4 -4 ogg/src/bitwise.c
Index: bitwise.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/bitwise.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- bitwise.c 2001/03/28 11:45:33 1.7
+++ bitwise.c 2001/10/02 00:15:03 1.8
@@ -11,7 +11,7 @@
********************************************************************
function: packing variable sized words into an octet stream
- last mod: $Id: bitwise.c,v 1.7 2001/03/28 11:45:33 segher Exp $
+ last mod: $Id: bitwise.c,v 1.8 2001/10/02 00:15:03 segher Exp $
********************************************************************/
@@ -34,7 +34,7 @@
0x3fffffff,0x7fffffff,0xffffffff };
void oggpack_writeinit(oggpack_buffer *b){
- memset(b,0,sizeof(oggpack_buffer));
+ memset(b,0,sizeof(*b));
b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
b->buffer[0]='\0';
b->storage=BUFFER_INCREMENT;
@@ -48,11 +48,11 @@
void oggpack_writeclear(oggpack_buffer *b){
_ogg_free(b->buffer);
- memset(b,0,sizeof(oggpack_buffer));
+ memset(b,0,sizeof(*b));
}
void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){
- memset(b,0,sizeof(oggpack_buffer));
+ memset(b,0,sizeof(*b));
b->buffer=b->ptr=buf;
b->storage=bytes;
}
1.15 +18 -19 ogg/src/framing.c
Index: framing.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/framing.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- framing.c 2001/05/24 21:22:52 1.14
+++ framing.c 2001/10/02 00:15:03 1.15
@@ -12,7 +12,7 @@
function: code raw [Vorbis] packets into framed OggSquish stream and
decode Ogg streams back into raw packets
- last mod: $Id: framing.c,v 1.14 2001/05/24 21:22:52 xiphmont Exp $
+ last mod: $Id: framing.c,v 1.15 2001/10/02 00:15:03 segher Exp $
note: The CRC code is directly derived from public domain code by
Ross Williams (ross at guest.adelaide.edu.au). See docs/framing.html
@@ -134,13 +134,13 @@
int ogg_stream_init(ogg_stream_state *os,int serialno){
if(os){
- memset(os,0,sizeof(ogg_stream_state));
+ memset(os,0,sizeof(*os));
os->body_storage=16*1024;
- os->body_data=_ogg_malloc(os->body_storage*sizeof(char));
+ os->body_data=_ogg_malloc(os->body_storage*sizeof(*os->body_data));
os->lacing_storage=1024;
- os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(int));
- os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(ogg_int64_t));
+ os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals));
+ os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals));
/* initialize the crc_lookup table if not done */
_ogg_crc_init();
@@ -159,7 +159,7 @@
if(os->lacing_vals)_ogg_free(os->lacing_vals);
if(os->granule_vals)_ogg_free(os->granule_vals);
- memset(os,0,sizeof(ogg_stream_state));
+ memset(os,0,sizeof(*os));
}
return(0);
}
@@ -178,15 +178,15 @@
static void _os_body_expand(ogg_stream_state *os,int needed){
if(os->body_storage<=os->body_fill+needed){
os->body_storage+=(needed+1024);
- os->body_data=_ogg_realloc(os->body_data,os->body_storage);
+ os->body_data=_ogg_realloc(os->body_data,os->body_storage*sizeof(*os->body_data));
}
}
static void _os_lacing_expand(ogg_stream_state *os,int needed){
if(os->lacing_storage<=os->lacing_fill+needed){
os->lacing_storage+=(needed+32);
- os->lacing_vals=_ogg_realloc(os->lacing_vals,os->lacing_storage*sizeof(int));
- os->granule_vals=_ogg_realloc(os->granule_vals,os->lacing_storage*sizeof(ogg_int64_t));
+ os->lacing_vals=_ogg_realloc(os->lacing_vals,os->lacing_storage*sizeof(*os->lacing_vals));
+ os->granule_vals=_ogg_realloc(os->granule_vals,os->lacing_storage*sizeof(*os->granule_vals));
}
}
@@ -221,7 +221,7 @@
os->body_fill-=os->body_returned;
if(os->body_fill)
memmove(os->body_data,os->body_data+os->body_returned,
- os->body_fill*sizeof(char));
+ os->body_fill);
os->body_returned=0;
}
@@ -368,8 +368,8 @@
/* advance the lacing data and set the body_returned pointer */
os->lacing_fill-=vals;
- memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(int));
- memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(ogg_int64_t));
+ memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals));
+ memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals));
os->body_returned+=bytes;
/* calculate the checksum */
@@ -422,7 +422,7 @@
/* initialize the struct to a known state */
int ogg_sync_init(ogg_sync_state *oy){
if(oy){
- memset(oy,0,sizeof(ogg_sync_state));
+ memset(oy,0,sizeof(*oy));
_ogg_crc_init();
}
return(0);
@@ -451,8 +451,7 @@
if(oy->returned){
oy->fill-=oy->returned;
if(oy->fill>0)
- memmove(oy->data,oy->data+oy->returned,
- (oy->fill)*sizeof(char));
+ memmove(oy->data,oy->data+oy->returned,oy->fill);
oy->returned=0;
}
@@ -646,9 +645,9 @@
/* segment table */
if(os->lacing_fill-lr){
memmove(os->lacing_vals,os->lacing_vals+lr,
- (os->lacing_fill-lr)*sizeof(int));
+ (os->lacing_fill-lr)*sizeof(*os->lacing_vals));
memmove(os->granule_vals,os->granule_vals+lr,
- (os->lacing_fill-lr)*sizeof(ogg_int64_t));
+ (os->lacing_fill-lr)*sizeof(*os->granule_vals));
}
os->lacing_fill-=lr;
os->lacing_packet-=lr;
@@ -830,7 +829,7 @@
void ogg_packet_clear(ogg_packet *op) {
free(op->packet);
- memset(op, 0, sizeof(ogg_packet));
+ memset(op, 0, sizeof(*op));
}
#ifdef _V_SELFTEST
@@ -1210,7 +1209,7 @@
ogg_stream_packetout(&os_de,&op_de); /* just catching them all */
/* verify peek and out match */
- if(memcmp(&op_de,&op_de2,sizeof(ogg_packet))){
+ if(memcmp(&op_de,&op_de2,sizeof(op_de))){
fprintf(stderr,"packetout != packetpeek! pos=%ld\n",
depacket);
exit(1);
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list