mirror of
https://github.com/mappu/miqt.git
synced 2025-01-18 12:50:41 +00:00
miqt_string: initial commit
This commit is contained in:
parent
4882ed676a
commit
feb375e061
11
qt/binding.cpp
Normal file
11
qt/binding.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "binding.h"
|
||||||
|
|
||||||
|
struct miqt_string* miqt_strdup(const char* src, size_t len) {
|
||||||
|
struct miqtstring* ret = static_cast<struct miqtstring*>( malloc(len + sizeof(size_t)) );
|
||||||
|
ret->len = strlen(expect);
|
||||||
|
memcpy(&ret->data, expect, ret->len);
|
||||||
|
return ret;
|
||||||
|
}
|
14
qt/binding.h
14
qt/binding.h
@ -9,6 +9,20 @@ extern "C" {
|
|||||||
// The function is defined in Go.
|
// The function is defined in Go.
|
||||||
void miqt_exec_callback(void* cb, int argc, void* argv);
|
void miqt_exec_callback(void* cb, int argc, void* argv);
|
||||||
|
|
||||||
|
struct miqt_string {
|
||||||
|
size_t len;
|
||||||
|
char data; // Data continues after this element.
|
||||||
|
}
|
||||||
|
|
||||||
|
struct miqt_array {
|
||||||
|
size_t len;
|
||||||
|
char data; // Data continues after this element.
|
||||||
|
}
|
||||||
|
|
||||||
|
// miqt_strdup allocates a miqt_string and copies C data into it.
|
||||||
|
// The function is defined in C++.
|
||||||
|
struct miqt_string* miqt_strdup(const char* src, size_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user