-
Notifications
You must be signed in to change notification settings - Fork 8
/
OSCArg.cpp
70 lines (42 loc) · 1.2 KB
/
OSCArg.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
ArdOSC 2.1 - OSC Library for Arduino.
-------- Lisence -----------------------------------------------------------
ArdOSC
The MIT License
Copyright (c) 2009 - 2011 recotana( http://recotana.com ) All right reserved
*/
#include "OSCcommon/OSCArg.h"
#include "OSCCommon/OSCMessage.h"
#include <stdlib.h>
#include <string.h>
OSCArg::OSCArg(void){
_typeTag = 0;
_argData = 0;
_dataSize = 0;
_alignmentSize = 0;
}
OSCArg::OSCArg(char _tag){
_typeTag = _tag;
_argData = 0;
_dataSize = 0;
_alignmentSize = 0;
}
OSCArg::OSCArg( char _tag , void *_data , uint16_t _size , bool _packSizeCulc ) {
_typeTag = _tag;
if( _typeTag == kTagBlob ) _typeTag = _size+4;
else _dataSize = _size;
if( _packSizeCulc ) _alignmentSize = CULC_ALIGNMENT(_size);
else _alignmentSize = _size;
if( _size == 0 ) return;
_argData = calloc( 1, _alignmentSize );
memcpy( (uint8_t*)_argData , _data , _size );
}
OSCArg::~OSCArg(void){
if( _typeTag != 0 ) flush();
}
void OSCArg::flush(void){
if( _dataSize > 0 ) free(_argData);
_dataSize = 0;
_alignmentSize = 0;
_typeTag = 0;
}