1
0
Fork 0

remove unused typedefs and functionality

This commit is contained in:
jsteemann 2016-03-21 22:39:23 +01:00
parent 3dede4a71f
commit f840c2e6bb
6 changed files with 22 additions and 177 deletions

View File

@ -113,7 +113,6 @@ typedef long suseconds_t;
#include <set>
#include <string>
#include <vector>
// C++11!!
#include <unordered_map>
#include <unordered_set>
#include <memory>
@ -263,17 +262,6 @@ struct TRI_AutoOutOfScope {
TRI_DEFER_INTERNAL(Destructor, TOKEN_PASTE(auto_fun, __LINE__), \
TOKEN_PASTE(auto_obj, __LINE__))
// -----------------------------------------------------------------------------
// --SECTIONS-- triagens namespace
// -----------------------------------------------------------------------------
namespace arangodb {
typedef TRI_blob_t blob_t;
typedef TRI_datetime_t datetime_t;
typedef TRI_date_t date_t;
typedef TRI_seconds_t seconds_t;
}
#undef TRI_SHOW_LOCK_TIME
#define TRI_SHOW_LOCK_THRESHOLD 0.000199

View File

@ -207,55 +207,6 @@ namespace arangodb {
namespace basics {
namespace StringUtils {
// .............................................................................
// STRING AND STRING POINTER
// .............................................................................
blob_t duplicateBlob(const blob_t& source) {
blob_t result = {0, 0};
if (source.length == 0 || source.data == 0) {
return result;
}
result.data = new char[source.length];
memcpy(const_cast<char*>(result.data), source.data, source.length);
result.length = source.length;
return result;
}
blob_t duplicateBlob(char const* source, size_t len) {
blob_t result = {0, 0};
if (source == 0 || len == 0) {
return result;
}
result.data = new char[len];
memcpy(const_cast<char*>(result.data), source, len);
result.length = (uint32_t)len;
return result;
}
blob_t duplicateBlob(std::string const& source) {
blob_t result = {0, 0};
if (source.size() == 0) {
return result;
}
result.data = new char[source.size()];
memcpy(const_cast<char*>(result.data), source.c_str(), source.size());
result.length = (uint32_t)source.size();
return result;
}
char* duplicate(std::string const& source) {
size_t len = source.size();
char* result = new char[len + 1];
@ -308,15 +259,6 @@ void destroy(char*& source, size_t length) {
}
}
void destroy(blob_t& source) {
if (source.data != 0) {
::memset(const_cast<char*>(source.data), 0, source.length);
delete[] source.data;
source.data = 0;
source.length = 0;
}
}
void erase(char*& source) {
if (source != 0) {
delete[] source;
@ -324,14 +266,6 @@ void erase(char*& source) {
}
}
void erase(blob_t& source) {
if (source.data != 0) {
delete[] source.data;
source.data = 0;
source.length = 0;
}
}
// .............................................................................
// STRING CONVERSION
// .............................................................................

View File

@ -42,24 +42,6 @@ namespace StringUtils {
// STRING AND STRING POINTER
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a blob using new
////////////////////////////////////////////////////////////////////////////////
blob_t duplicateBlob(const blob_t&);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a blob using new
////////////////////////////////////////////////////////////////////////////////
blob_t duplicateBlob(char const*, size_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a blob using new
////////////////////////////////////////////////////////////////////////////////
blob_t duplicateBlob(std::string const&);
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a C string using new
////////////////////////////////////////////////////////////////////////////////
@ -96,15 +78,6 @@ void destroy(char*&);
void destroy(char*&, size_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief deletes and clears a string
///
/// The string is cleared using memset and then deleted. The pointer is
/// set to 0.
////////////////////////////////////////////////////////////////////////////////
void destroy(blob_t&);
////////////////////////////////////////////////////////////////////////////////
/// @brief deletes but does not clear a character string
///
@ -113,14 +86,6 @@ void destroy(blob_t&);
void erase(char*&);
////////////////////////////////////////////////////////////////////////////////
/// @brief deletes but does not clear a blob
///
/// The data pointer deleted and then set to 0, and the length is set to 0.
////////////////////////////////////////////////////////////////////////////////
void erase(blob_t&);
// -----------------------------------------------------------------------------
// STRING CONVERSION
// -----------------------------------------------------------------------------
@ -543,24 +508,6 @@ float floatDecimal(std::string const& str);
float floatDecimal(char const* value, size_t size);
////////////////////////////////////////////////////////////////////////////////
/// @brief parses a time
////////////////////////////////////////////////////////////////////////////////
seconds_t seconds(std::string const& format, std::string const& str);
////////////////////////////////////////////////////////////////////////////////
/// @brief formats a time using the extended ISO 8601 format
////////////////////////////////////////////////////////////////////////////////
std::string formatSeconds(seconds_t);
////////////////////////////////////////////////////////////////////////////////
/// @brief formats a time using the oracle format string
////////////////////////////////////////////////////////////////////////////////
std::string formatSeconds(std::string const& format, seconds_t);
// -----------------------------------------------------------------------------
// BASE64
// -----------------------------------------------------------------------------

View File

@ -24,28 +24,6 @@
#ifndef LIB_BASICS_STRUCTURES_H
#define LIB_BASICS_STRUCTURES_H 1
#ifndef TRI_WITHIN_COMMON
#error use <Basics/Common.h>
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief type of date-time entries (seconds since 1970-01-01)
////////////////////////////////////////////////////////////////////////////////
typedef double TRI_datetime_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief type of date entries (days since 1970-01-01)
////////////////////////////////////////////////////////////////////////////////
typedef int32_t TRI_date_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief type of duration entries in seconds or seconds since 00:00:00
////////////////////////////////////////////////////////////////////////////////
typedef int32_t TRI_seconds_t;
////////////////////////////////////////////////////////////////////////////////
/// @brief global blob type
///
@ -53,10 +31,10 @@ typedef int32_t TRI_seconds_t;
/// 4 GByte.
////////////////////////////////////////////////////////////////////////////////
typedef struct TRI_blob_s {
struct TRI_blob_t {
char* data;
uint32_t length;
} TRI_blob_t;
};
////////////////////////////////////////////////////////////////////////////////
/// @brief destorys the data of blob, but does not free the pointer

View File

@ -29,14 +29,17 @@
#ifdef TRI_MISSING_MEMRCHR
void* memrchr(const void* block, int c, size_t size) {
const unsigned char* p = static_cast<const unsigned char*>(block);
void* memrchr(void const* block, int c, size_t size) {
unsigned char const* p = static_cast<unsigned char const*>(block);
if (size) {
for (p += size - 1; size; p--, size--)
if (*p == c) return (void*)p;
if (*p == c) {
return (void*)p;
}
}
}
return NULL;
return nullptr;
}
#endif
@ -72,19 +75,16 @@ int gettimeofday(struct timeval* tv, void* tz) {
static int const line_size = 256;
ssize_t getline(char** lineptr, size_t* n, FILE* stream) {
size_t indx = 0;
int c;
// sanity checks
if (lineptr == NULL || n == NULL || stream == NULL) {
if (lineptr == nullptr || n == nullptr || stream == nullptr) {
return -1;
}
// allocate the line the first time
if (*lineptr == NULL) {
if (*lineptr == nullptr) {
*lineptr = (char*)TRI_SystemAllocate(line_size, false);
if (*lineptr == NULL) {
if (*lineptr == nullptr) {
return -1;
}
@ -94,12 +94,14 @@ ssize_t getline(char** lineptr, size_t* n, FILE* stream) {
// clear the line
memset(*lineptr, '\0', *n);
size_t indx = 0;
int c;
while ((c = getc(stream)) != EOF) {
// check if more memory is needed
if (indx >= *n) {
*lineptr = (char*)realloc(*lineptr, *n + line_size);
if (*lineptr == NULL) {
if (*lineptr == nullptr) {
return -1;
}
@ -139,11 +141,9 @@ void TRI_localtime(time_t tt, struct tm* tb) {
#else
struct tm* tp;
struct tm* tp = localtime(&tt);
tp = localtime(&tt);
if (tp != NULL) {
if (tp != nullptr) {
memcpy(tb, tp, sizeof(struct tm));
}
@ -168,11 +168,9 @@ void TRI_gmtime(time_t tt, struct tm* tb) {
#else
struct tm* tp;
struct tm* tp = gmtime(&tt);
tp = gmtime(&tt);
if (tp != NULL) {
if (tp != nullptr) {
memcpy(tb, tp, sizeof(struct tm));
}

View File

@ -33,7 +33,7 @@
////////////////////////////////////////////////////////////////////////////////
#ifdef TRI_MISSING_MEMRCHR
void* memrchr(const void* block, int c, size_t size);
void* memrchr(void const* block, int c, size_t size);
#endif
////////////////////////////////////////////////////////////////////////////////
@ -68,12 +68,12 @@ void TRI_gmtime(time_t, struct tm*);
/// @brief seconds with microsecond resolution
////////////////////////////////////////////////////////////////////////////////
double TRI_microtime(void);
double TRI_microtime();
////////////////////////////////////////////////////////////////////////////////
/// @brief number of processors or 0
////////////////////////////////////////////////////////////////////////////////
size_t TRI_numberProcessors(void);
size_t TRI_numberProcessors();
#endif