added a way to create an empty string
This commit is contained in:
parent
7f0120f0c8
commit
80331b5c34
2 changed files with 19 additions and 0 deletions
|
|
@ -26,6 +26,17 @@ void ARC_String_CreateWithStrlen(ARC_String **string, char *data){
|
|||
(*string)->data[(*string)->length] = '\0';
|
||||
}
|
||||
|
||||
void ARC_String_CreateEmpty(ARC_String **string, uint64_t length){
|
||||
*string = (ARC_String *)malloc(sizeof(ARC_String));
|
||||
(*string)->data = (char *)malloc(sizeof(char) * (length + 1));
|
||||
(*string)->length = length;
|
||||
|
||||
(*string)->data[0] = '\0';
|
||||
for(uint64_t index = 0; index <= length; index++){
|
||||
(*string)->data[index] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void ARC_String_Destroy(ARC_String *string){
|
||||
if(string->data){
|
||||
free(string->data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue