summaryrefslogtreecommitdiff
path: root/src/common/extstr.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-12-29 14:07:38 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-12-29 14:07:38 (GMT)
commit944461f7af1995b08783dc761772908ec7c204a6 (patch)
tree21a50208c650390e9649bb0892f94bab26d5fc8f /src/common/extstr.c
parent11634a93003e7b5dd339bb52f2cde04f29f4c4e4 (diff)
Handled Itanium demangling with C code (first part).
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@361 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/common/extstr.c')
-rw-r--r--src/common/extstr.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/common/extstr.c b/src/common/extstr.c
index 8249515..309f487 100644
--- a/src/common/extstr.c
+++ b/src/common/extstr.c
@@ -47,9 +47,46 @@ char *stradd(char *str1, const char *str2)
{
char *result; /* Chaîne à renvoyer */
- result = (char *)realloc(str1, (strlen(str1) + strlen(str2) + 1) * sizeof(char));
+ if (str1 == NULL)
+ result = strdup(str2);
+
+ else
+ {
+ result = (char *)realloc(str1, (strlen(str1) + strlen(str2) + 1) * sizeof(char));
+ strcat(result, str2);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : str1 = chaîne de caractères à compléter. *
+* str2 = chaîne de caractères à ajouter. *
+* n = taille de la seconde chaîne. *
+* *
+* Description : Complète une chaîne de caractères avec une autre. *
+* *
+* Retour : Chaîne de caractères complétée, à libérer de la mémoire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+char *strnadd(char *str1, const char *str2, size_t n)
+{
+ char *result; /* Chaîne à renvoyer */
- strcat(result, str2);
+ if (str1 == NULL)
+ result = strndup(str2, n);
+
+ else
+ {
+ result = (char *)realloc(str1, (strlen(str1) + n + 1) * sizeof(char));
+ strncat(result, str2, n);
+ }
return result;