Browse Source

Minor utils fix

tags/1.9.7
falkTX 8 years ago
parent
commit
c0075a9571
1 changed files with 6 additions and 3 deletions
  1. +6
    -3
      source/utils/CarlaUtils.hpp

+ 6
- 3
source/utils/CarlaUtils.hpp View File

@@ -1,6 +1,6 @@
/*
* Carla common utils
* Copyright (C) 2011-2015 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2016 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -344,7 +344,7 @@ const char* carla_strdup(const char* const strBuf)
const std::size_t bufferLen = (strBuf != nullptr) ? std::strlen(strBuf) : 0;
char* const buffer = new char[bufferLen+1];

if (strBuf != nullptr && bufferLen > 0)
if (bufferLen > 0)
std::memcpy(buffer, strBuf, bufferLen);

buffer[bufferLen] = '\0';
@@ -382,7 +382,7 @@ const char* carla_strdup_safe(const char* const strBuf) noexcept
buffer = new char[bufferLen+1];
} CARLA_SAFE_EXCEPTION_RETURN("carla_strdup_safe", nullptr);

if (strBuf != nullptr && bufferLen > 0)
if (bufferLen > 0)
std::memcpy(buffer, strBuf, bufferLen);

buffer[bufferLen] = '\0';
@@ -402,6 +402,7 @@ void carla_add(T dest[], const T src[], const std::size_t count) noexcept
{
CARLA_SAFE_ASSERT_RETURN(dest != nullptr,);
CARLA_SAFE_ASSERT_RETURN(src != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dest != src,);
CARLA_SAFE_ASSERT_RETURN(count > 0,);

for (std::size_t i=0; i<count; ++i)
@@ -417,6 +418,7 @@ void carla_copy(T dest[], const T src[], const std::size_t count) noexcept
{
CARLA_SAFE_ASSERT_RETURN(dest != nullptr,);
CARLA_SAFE_ASSERT_RETURN(src != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dest != src,);
CARLA_SAFE_ASSERT_RETURN(count > 0,);

std::memcpy(dest, src, count*sizeof(T));
@@ -522,6 +524,7 @@ void carla_copyStructs(T dest[], const T src[], const std::size_t count) noexcep
{
CARLA_SAFE_ASSERT_RETURN(dest != nullptr,);
CARLA_SAFE_ASSERT_RETURN(src != nullptr,);
CARLA_SAFE_ASSERT_RETURN(dest != src,);
CARLA_SAFE_ASSERT_RETURN(count > 0,);

std::memcpy(dest, src, count*sizeof(T));


Loading…
Cancel
Save