Merge branch 'development' into LTS_development
# Conflicts: # src/output/output.h
This commit is contained in:
commit
dc8bae8dd3
10 changed files with 80 additions and 30 deletions
|
@ -348,7 +348,7 @@ namespace DTSC {
|
|||
return vod || live;
|
||||
}
|
||||
void reinit(const DTSC::Packet & source);
|
||||
void update(DTSC::Packet & pack, unsigned long segment_size = 5000);
|
||||
void update(const DTSC::Packet & pack, unsigned long segment_size = 5000);
|
||||
void updatePosOverride(DTSC::Packet & pack, uint64_t bpos);
|
||||
void update(JSON::Value & pack, unsigned long segment_size = 5000);
|
||||
/*LTS
|
||||
|
|
|
@ -1495,7 +1495,7 @@ namespace DTSC {
|
|||
}
|
||||
|
||||
///\brief Updates a meta object given a DTSC::Packet
|
||||
void Meta::update(DTSC::Packet & pack, unsigned long segment_size) {
|
||||
void Meta::update(const DTSC::Packet & pack, unsigned long segment_size) {
|
||||
char * data;
|
||||
unsigned int dataLen;
|
||||
pack.getString("data", data, dataLen);
|
||||
|
|
41
lib/util.cpp
41
lib/util.cpp
|
@ -12,6 +12,7 @@
|
|||
#if defined(_WIN32)
|
||||
#include <direct.h> // _mkdir
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
#define RECORD_POINTER p + getOffset() + (getRecordPosition(recordNo) * getRSize()) + fd.offset
|
||||
#define RAXHDR_FIELDOFFSET p[1]
|
||||
|
@ -148,6 +149,46 @@ namespace Util{
|
|||
return fseeko(stream, offset, whence);
|
||||
}
|
||||
|
||||
ResizeablePointer::ResizeablePointer(){
|
||||
currSize = 0;
|
||||
ptr = 0;
|
||||
maxSize = 0;
|
||||
}
|
||||
|
||||
ResizeablePointer::~ResizeablePointer(){
|
||||
if (ptr){free(ptr);}
|
||||
currSize = 0;
|
||||
ptr = 0;
|
||||
maxSize = 0;
|
||||
}
|
||||
|
||||
bool ResizeablePointer::assign(void * p, uint32_t l){
|
||||
if (!allocate(l)){return false;}
|
||||
memcpy(ptr, p, l);
|
||||
currSize = l;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ResizeablePointer::append(void * p, uint32_t l){
|
||||
if (!allocate(l+currSize)){return false;}
|
||||
memcpy(((char*)ptr)+currSize, p, l);
|
||||
currSize += l;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ResizeablePointer::allocate(uint32_t l){
|
||||
if (l > maxSize){
|
||||
void *tmp = realloc(ptr, l);
|
||||
if (!tmp){
|
||||
FAIL_MSG("Could not allocate %lu bytes of memory", l);
|
||||
return false;
|
||||
}
|
||||
ptr = tmp;
|
||||
maxSize = l;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// If waitReady is true (default), waits for isReady() to return true in 50ms sleep increments.
|
||||
RelAccX::RelAccX(char *data, bool waitReady){
|
||||
if (!data){
|
||||
|
|
18
lib/util.h
18
lib/util.h
|
@ -12,6 +12,24 @@ namespace Util{
|
|||
uint64_t ftell(FILE *stream);
|
||||
uint64_t fseek(FILE *stream, uint64_t offset, int whence);
|
||||
|
||||
/// Helper class that maintains a resizeable pointer and will free it upon deletion of the class.
|
||||
class ResizeablePointer{
|
||||
public:
|
||||
ResizeablePointer();
|
||||
~ResizeablePointer();
|
||||
inline uint32_t& size(){return currSize;}
|
||||
bool assign(void * p, uint32_t l);
|
||||
bool append(void * p, uint32_t l);
|
||||
bool allocate(uint32_t l);
|
||||
inline operator char*(){return (char*)ptr;}
|
||||
inline operator void*(){return ptr;}
|
||||
private:
|
||||
void * ptr;
|
||||
uint32_t currSize;
|
||||
uint32_t maxSize;
|
||||
|
||||
};
|
||||
|
||||
/// Holds type, size and offset for RelAccX class internal data fields.
|
||||
class RelAccXFieldData{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue