[PD-cvs] externals/zexy/src z_strings.c,1.6,1.7
IOhannes m zmölnig
zmoelnig at users.sourceforge.net
Thu Jul 22 14:19:23 CEST 2004
Update of /cvsroot/pure-data/externals/zexy/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31775
Modified Files:
z_strings.c
Log Message:
fixed a memory-leak in [l2s] (thanks to ix at replic.net)
Index: z_strings.c
===================================================================
RCS file: /cvsroot/pure-data/externals/zexy/src/z_strings.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** z_strings.c 30 Dec 2003 12:07:09 -0000 1.6
--- z_strings.c 22 Jul 2004 12:19:20 -0000 1.7
***************
*** 4,13 ****
#ifdef NT
! #pragma warning( disable : 4244 )
! #pragma warning( disable : 4305 )
! #define sqrtf sqrt
! #define STATIC_INLINE
! #else
! #define STATIC_INLINE static
#endif
--- 4,13 ----
#ifdef NT
! # pragma warning( disable : 4244 )
! # pragma warning( disable : 4305 )
! # define sqrtf sqrt
! # define STATIC_INLINE
! #else
! # define STATIC_INLINE static
#endif
***************
*** 192,228 ****
int argc=x->ac;
char *result = 0;
! char string[MAXPDSTRING];
! int length = 0;
int i= argc;
if (x->s){
char *buf = x->s->s_name;
! int newlen = length + strlen(buf);
! strcpy(string+length, buf);
! length = newlen;
! if(i && x->connector){
! char *buf = x->connector->s_name;
! newlen = length + strlen(buf);
! strcpy(string+length, buf);
! length = newlen;
}
}
while(i--){
char buffer[MAXPDSTRING];
- int newlen;
atom_string(argv++, buffer, MAXPDSTRING);
! newlen = length + strlen(buffer);
! strcpy(string+length, buffer);
! length = newlen;
! if(i && x->connector){
! char *buf = x->connector->s_name;
! newlen = length + strlen(buf);
! strcpy(string+length, buf);
! length = newlen;
}
}
- length = strlen(string);
- result = (char*)getbytes((length+1)*sizeof(char));
- strcpy(result, string);
result[length]=0;
outlet_symbol(x->x_obj.ob_outlet, gensym(result));
--- 192,243 ----
int argc=x->ac;
char *result = 0;
! int length = 0, len=0;
int i= argc;
+ char *connector=0;
+ char connlen=0;
+ if(x->connector)connector=x->connector->s_name;
+ if(connector)connlen=strlen(connector);
+ /* 1st get the length of the symbol */
+ if(x->s)length+=strlen(x->s->s_name);
+ else length-=connlen;
+
+ length+=i*connlen;
+
+ while(i--){
+ char buffer[MAXPDSTRING];
+ atom_string(argv++, buffer, MAXPDSTRING);
+ length+=strlen(buffer);
+ }
+
+ if (length<0){
+ outlet_symbol(x->x_obj.ob_outlet, gensym(""));
+ return;
+ }
+
+ result = (char*)getbytes((length+1)*sizeof(char));
+
+ /* 2nd create the symbol */
if (x->s){
char *buf = x->s->s_name;
! strcpy(result+len, buf);
! len+=strlen(buf);
! if(i && connector){
! strcpy(result+len, connector);
! len += connlen;
}
}
+ i=argc;
+ argv=x->ap;
while(i--){
char buffer[MAXPDSTRING];
atom_string(argv++, buffer, MAXPDSTRING);
! strcpy(result+len, buffer);
! len += strlen(buffer);
! if(i && connector){
! strcpy(result+len, connector);
! len += connlen;
}
}
result[length]=0;
outlet_symbol(x->x_obj.ob_outlet, gensym(result));
***************
*** 336,345 ****
dell=strlen(deli);
/* get the number of tokens */
while((d=strstr(cp, deli))){
! if (d!=NULL && d!=cp)i++;
cp=d+dell;
}
!
/* resize the list-buffer if necessary */
if(x->argnum<i){
--- 351,363 ----
dell=strlen(deli);
+
/* get the number of tokens */
while((d=strstr(cp, deli))){
! if (d!=NULL && d!=cp){
! i++;
! }
cp=d+dell;
}
!
/* resize the list-buffer if necessary */
if(x->argnum<i){
More information about the Pd-cvs
mailing list