- processing of function parameter added (first tests successful)
- next stage -> constructing stub files (.c and .h)
This commit is contained in:
@@ -25,3 +25,49 @@ void* xmalloc(size_t size)
|
||||
memset(value, 0, size);
|
||||
return value;
|
||||
}
|
||||
|
||||
char* xmallocStrlcpy(char **aDest, char *aSource, size_t aSize)
|
||||
{
|
||||
if (NULL == aSource || 0 == aSize)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
*aDest = (char*) realloc(*aDest, aSize + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aDest = (char*) xmalloc(aSize + 1);
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
(void) strlcpy(*aDest, aSource, aSize + 1);
|
||||
}
|
||||
return *aDest;
|
||||
}
|
||||
|
||||
char* xmallocStrlcat(char **aDest, char *aSource, size_t aSize)
|
||||
{
|
||||
size_t newSize = 0;
|
||||
if (NULL == aSource || 0 == aSize)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
newSize = strlen(*aDest) + aSize + 1;
|
||||
*aDest = (char*) realloc(*aDest, newSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
newSize = aSize + 1;
|
||||
*aDest = (char*) xmalloc(newSize);
|
||||
}
|
||||
if (NULL != *aDest)
|
||||
{
|
||||
(void) strlcat(*aDest, aSource, newSize);
|
||||
}
|
||||
return *aDest;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user