-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmmstring.h
More file actions
45 lines (33 loc) · 897 Bytes
/
mmstring.h
File metadata and controls
45 lines (33 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// Created by lisanhu on 5/8/19.
//
#ifndef GACTV2_MSTRING_H
#define GACTV2_MSTRING_H
#include <stdlib.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* The mstring class
*
* @brief A simple string library for personal use
*
* @param l the length of the string
* @param m the memory unit occupied by the object (when the object is borrowing memory from other places, the value should be 0 since it's not taking any particular memory to store the string)
* @param s the memory address of the beginning of the string
*/
typedef struct mmstring {
size_t len, cap;
char *s;
} mmstring;
mmstring ms_from(char *s, bool own);
mmstring ms_own(const char *cstr, size_t l);
#pragma acc routine
mmstring ms_borrow(char *cstr, size_t l);
void ms_destroy(mmstring *ms);
size_t ms_to_cstr(mmstring ms, char *buf);
#ifdef __cplusplus
};
#endif
#endif //GACTV2_MSTRING_H