/*
* utility.cpp
*
- * Home page of code is: http://smartmontools.sourceforge.net
+ * Home page of code is: http://www.smartmontools.org
*
- * Copyright (C) 2002-12 Bruce Allen <smartmontools-support@lists.sourceforge.net>
- * Copyright (C) 2008-14 Christian Franke <smartmontools-support@lists.sourceforge.net>
+ * Copyright (C) 2002-12 Bruce Allen
+ * Copyright (C) 2008-16 Christian Franke
* Copyright (C) 2000 Michael Cornwell <cornwell@acm.org>
*
* This program is free software; you can redistribute it and/or modify
#include "atacmds.h"
#include "dev_interface.h"
-const char * utility_cpp_cvsid = "$Id: utility.cpp 3937 2014-07-05 17:51:21Z chrfranke $"
+const char * utility_cpp_cvsid = "$Id: utility.cpp 4194 2016-01-01 13:46:00Z chrfranke $"
UTILITY_H_CVSID INT64_H_CVSID;
const char * packet_types[] = {
"(build date " __DATE__ ")" // checkout without expansion of Id keywords
#endif
" [%s] " BUILD_INFO "\n"
- "Copyright (C) 2002-14, Bruce Allen, Christian Franke, www.smartmontools.org\n",
+ "Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org\n",
prog_name, smi()->get_os_version_str().c_str()
);
if (!full)
const char *timezonename;
char datebuffer[DATEANDEPOCHLEN];
int lenm1;
-#ifdef _WIN32
- char tzfixbuf[6+1];
-#endif
FixGlibcTimeZoneBug();
#ifdef _WIN32
// Fix long non-ascii timezone names
+ // cppcheck-suppress variableScope
+ char tzfixbuf[6+1] = "";
if (!getenv("TZ"))
timezonename=fixtzname(tzfixbuf, sizeof(tzfixbuf), timezonename);
#endif
// Helps debugging. If the second argument is non-negative, then
// decrement bytes by that amount. Else decrement bytes by (one plus)
// length of null terminated string.
-void *FreeNonZero1(void *address, int size, int line, const char* file){
+void *FreeNonZero(void *address, int size, int /*line*/, const char* /*file*/){
if (address) {
if (size<0)
bytes-=1+strlen((char*)address);
else
bytes-=size;
- return CheckFree1(address, line, file);
- }
- return NULL;
-}
-
-// To help with memory checking. Use when it is known that address is
-// NOT null.
-void *CheckFree1(void *address, int /*whatline*/, const char* /*file*/){
- if (address){
free(address);
- return NULL;
}
- throw std::runtime_error("Internal error in CheckFree()");
-}
-
-// A custom version of calloc() that tracks memory use
-void *Calloc(size_t nmemb, size_t size) {
- void *ptr=calloc(nmemb, size);
-
- if (ptr)
- bytes+=nmemb*size;
-
- return ptr;
+ return NULL;
}
// A custom version of strdup() that keeps track of how much memory is