--- a/misc.c Tue Feb 15 18:57:52 2005 +0100 +++ b/misc.c Sat Feb 19 23:23:29 2000 +0100 @@ -15,7 +15,7 @@ #include "include/misc.h" -void *malloczero(int size) +void *malloczero(size_t size) { void *p=malloc(size); @@ -26,7 +26,7 @@ } -void *remalloczero(void *ptr, int oldsize, int newsize) +void *remalloczero(void *ptr, size_t oldsize, size_t newsize) { void *p=NULL; @@ -38,7 +38,10 @@ memset(p, 0, newsize); - if(ptr!=NULL && oldsize<newsize) + if(newsize<oldsize) + oldsize=newsize; + + if(ptr!=NULL) memcpy(p, ptr, oldsize); } @@ -107,6 +110,32 @@ } +char *scatn(const char *s1, ssize_t l1, const char *s2, ssize_t l2) +{ + size_t tlen=1; + char *s; + + if(l1<0) + l1=strlen(s1); + + if(l2<0) + l2=strlen(s2); + + tlen+=l1+l2; + + s=(char*)malloc(tlen); + + if(s==NULL) + return NULL; + + memcpy(s, s1, l1); + memcpy(s+l1, s2, l2); + s[l1+l2]='\0'; + + return s; +} + + /* */