DynArray, DynString, wgl extensions string
This commit is contained in:
17
src/DynString.c
Normal file
17
src/DynString.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "DynString.h"
|
||||
|
||||
short DynString_alloc(DynString* dstr, const char* str, const size_t len) {
|
||||
dstr->data = (char*) malloc(sizeof(char) * len + 1);
|
||||
if (dstr->data == NULL) {
|
||||
return -1;
|
||||
}
|
||||
dstr->data = memcpy(dstr->data, str, len);
|
||||
dstr->data[len] = '\0';
|
||||
dstr->len = len;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user