/[svn]/linuxsampler/trunk/src/common/ConstCapacityArray.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/ConstCapacityArray.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3846 by schoenebeck, Sun Aug 18 00:06:04 2019 UTC revision 3847 by schoenebeck, Thu Jan 7 12:25:59 2021 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014 - 2019 Christian Schoenebeck   * Copyright (c) 2014 - 2021 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 116  namespace LinuxSampler { Line 116  namespace LinuxSampler {
116           * @param count - amount of elements to be removed           * @param count - amount of elements to be removed
117           */           */
118          inline void remove(size_t index, size_t count = 1) {          inline void remove(size_t index, size_t count = 1) {
119              if (index >= m_size || index + count > m_size)              if (index >= m_size)
120                  return;                  return;
121                // special case: no elements behind the removed elements, so nothing
122                // to move
123                if (index + count >= m_size) {
124                    m_size = index;
125                    return;
126                }
127              // don't use memmove() here! Since it is not RT safe with all libc              // don't use memmove() here! Since it is not RT safe with all libc
128              // implementations and on all architectures              // implementations and on all architectures
129              for (size_t i = 0; i < count; ++i)              const size_t n = m_size - index - count;
130                for (size_t i = 0; i < n; ++i)
131                  m_data[index + i] = m_data[index + i + count];                  m_data[index + i] = m_data[index + i + count];
132              m_size -= count;              m_size -= count;
133          }          }

Legend:
Removed from v.3846  
changed lines
  Added in v.3847

  ViewVC Help
Powered by ViewVC