This repository was archived by the owner on Dec 26, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +69
-0
lines changed Expand file tree Collapse file tree 4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -10,5 +10,6 @@ cc_library(
10
10
visibility = ["//visibility:public" ],
11
11
deps = [
12
12
"@entangled//cclient/types" ,
13
+ "//accelerator:ta_errors" ,
13
14
],
14
15
)
Original file line number Diff line number Diff line change 1
1
#ifndef REQUEST_REQUEST_H_
2
2
#define REQUEST_REQUEST_H_
3
3
4
+ #include "request/ta_send_mam_req.h"
4
5
#include "request/ta_send_transfer.h"
5
6
6
7
/**
Original file line number Diff line number Diff line change
1
+ #include "ta_send_mam_req.h"
2
+
3
+ send_mam_req_t * send_mam_req_new () {
4
+ send_mam_req_t * req = (send_mam_req_t * )malloc (sizeof (send_mam_req_t ));
5
+ if (req ) {
6
+ req -> payload_trytes = NULL ;
7
+ }
8
+
9
+ return req ;
10
+ }
11
+
12
+ status_t send_mam_req_set_payload (send_mam_req_t * req , const tryte_t * payload ) {
13
+ status_t ret = SC_OK ;
14
+ size_t payload_size = sizeof (payload ) / sizeof (tryte_t );
15
+
16
+ if ((!payload ) || (payload_size == 0 ) || ((payload_size * 3 ) > SIZE_MAX )) {
17
+ return SC_MAM_OOM ;
18
+ }
19
+
20
+ req -> payload_trytes = (tryte_t * )malloc (payload_size * sizeof (tryte_t ));
21
+ if (!req -> payload_trytes ) {
22
+ return SC_MAM_OOM ;
23
+ }
24
+ memcpy (req -> payload_trytes , payload , payload_size );
25
+ req -> payload_trytes_size = payload_size ;
26
+
27
+ return ret ;
28
+ }
29
+
30
+ void send_mam_req_free (send_mam_req_t * * req ) {
31
+ if (!req || !(* req )) {
32
+ return ;
33
+ }
34
+ if ((* req )-> payload_trytes ) {
35
+ free ((* req )-> payload_trytes );
36
+ (* req )-> payload_trytes = NULL ;
37
+ }
38
+ free (* req );
39
+ * req = NULL ;
40
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef REQUEST_TA_SEND_MAM_REQ_H_
2
+ #define REQUEST_TA_SEND_MAM_REQ_H_
3
+
4
+ #include < stdint.h>
5
+ #include < stdlib.h>
6
+ #include < string.h>
7
+ #include " accelerator/errors.h"
8
+ #include " cclient/types/types.h"
9
+
10
+ #ifdef __cplusplus
11
+ extern " C" {
12
+ #endif
13
+
14
+ typedef struct send_mam_req_s {
15
+ tryte_t * payload_trytes;
16
+ size_t payload_trytes_size;
17
+ } send_mam_req_t ;
18
+
19
+ send_mam_req_t * send_mam_req_new ();
20
+ status_t send_mam_req_set_payload (send_mam_req_t * req, const tryte_t * payload);
21
+ void send_mam_req_free (send_mam_req_t ** req);
22
+
23
+ #ifdef __cplusplus
24
+ }
25
+ #endif
26
+
27
+ #endif // REQUEST_TA_SEND_MAM_REQ_H_
You can’t perform that action at this time.
0 commit comments