trunk: changeset 1360

Sun, 07 Mar 2004 22:10:48 +0100

author
tuomov
date
Sun, 07 Mar 2004 22:10:48 +0100
changeset 63
5b732dd506d3
parent 62
aae5facf9fc5
child 64
f20d97d852ce

trunk: changeset 1360
Added scopyn.

misc.c file | annotate | diff | comparison | revisions
misc.h file | annotate | diff | comparison | revisions
--- a/misc.c	Mon Feb 16 18:50:28 2004 +0100
+++ b/misc.c	Sun Mar 07 22:10:48 2004 +0100
@@ -43,12 +43,9 @@
 }
 
 
-char *scopy(const char *p)
+char *scopyn(const char *p, size_t l)
 {
-    char*pn;
-    size_t l=strlen(p);
-    
-    pn=(char*)malloc(l+1);
+    char *pn=(char*)malloc(l+1);
     
     if(pn==NULL)
         return NULL;
@@ -57,6 +54,13 @@
     
     return pn;
 }
+
+
+char *scopy(const char *p)
+{
+    size_t l=strlen(p);
+    return scopyn(p, l);
+}
     
     
 char *scat(const char *p1, const char *p2)
--- a/misc.h	Mon Feb 16 18:50:28 2004 +0100
+++ b/misc.h	Sun Mar 07 22:10:48 2004 +0100
@@ -28,6 +28,7 @@
 extern void* remalloczero(void *ptr, size_t oldsize, size_t newsize);
 
 extern char* scopy(const char *p);
+extern char* scopyn(const char *p, size_t n);
 extern char* scat(const char *p1, const char *p2);
 extern char* scatn(const char *p1, ssize_t n1, const char *p2, ssize_t n2);
 extern char* scat3(const char *p1, const char *p2, const char *p3);

mercurial