Fix compile error when --build-e2 option included

- modify byte_array.h in order to avoid conflict for same file names
This commit is contained in:
Teodora
2023-10-02 15:40:36 +02:00
committed by Robert Schmidt
parent 9127258a54
commit 2eaac0351d
3 changed files with 24 additions and 3 deletions
+17
View File
@@ -22,6 +22,7 @@
#include "byte_array.h"
#include "common/utils/assertions.h"
#include <assert.h>
#include <string.h>
byte_array_t copy_byte_array(byte_array_t src)
@@ -56,3 +57,19 @@ bool eq_byte_array(const byte_array_t* m0, const byte_array_t* m1)
return true;
}
byte_array_t cp_str_to_ba(const char* str)
{
assert(str != NULL);
const size_t sz = strlen(str);
byte_array_t dst = {.len = sz};
dst.buf = calloc(sz,sizeof(uint8_t));
assert(dst.buf != NULL && "Memory exhausted");
memcpy(dst.buf, str, sz);
return dst;
}