Update of /cvsroot/monetdb/MonetDB5/src/modules/atoms
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv9932/src/modules/atoms
Modified Files:
Tag: MonetDB_5-2
str.mx
Log Message:
small cleanup of the repeat function
Index: str.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/modules/atoms/str.mx,v
retrieving revision 1.67
retrieving revision 1.67.6.1
diff -u -d -r1.67 -r1.67.6.1
--- str.mx 1 Jun 2007 09:21:39 -0000 1.67
+++ str.mx 30 Nov 2007 22:03:22 -0000 1.67.6.1
@@ -2465,19 +2465,22 @@
}
str
-STRrepeat(str *ret, str *s, int *c){
+STRrepeat(str *ret, str *s, int *c)
+{
str t;
int i;
size_t l;
- if( *c < 0 || strcmp(*s,str_nil)==0 )
- *ret= GDKstrdup(str_nil);
- else {
- l= strlen(*s);
- t= *ret = GDKmalloc( *c * l +1);
+ if (*c < 0 || strcmp(*s, str_nil) == 0) {
+ *ret = GDKstrdup(str_nil);
+ } else {
+ l = strlen(*s);
+ t = *ret = GDKmalloc( *c * l + 1);
+
+ if (!t)
+ throw(MAL, "str.repeat", "Allocation failed");
*t = 0;
-
- for(i= *c; i>0; i--,t+= l)
+ for(i = *c; i>0; i--, t += l)
strcat(t, *s);
}
return MAL_SUCCEED;
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins