/usr/include/dcmtk/ofstd/ofbmanip.h is in libdcmtk-dev 3.6.1~20150924-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | /*
*
* Copyright (C) 1997-2014, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: ofstd
*
* Author: Joerg Riesmeier
*
* Purpose: Template class for bit manipulations (Header)
*
*/
#ifndef OFBMANIP_H
#define OFBMANIP_H
#include "dcmtk/config/osconfig.h"
#include "dcmtk/ofstd/ofcast.h"
#include "dcmtk/ofstd/ofdefine.h"
#define INCLUDE_CSTRING
#include "dcmtk/ofstd/ofstdinc.h"
/*---------------------*
* class declaration *
*---------------------*/
/** A template class for bit manipulations.
* This class is used to perform platform independent operations on typed memory areas.
*/
template<class T>
class OFBitmanipTemplate
{
public:
/** copies specified number of elements from source to destination.
* Both src and dest must be aligned according to T's align requirements.
* These memory areas must not overlap!
*
** @param src pointer to source memory
* @param dest pointer to destination memory
* @param count number of elements to be copied
*/
static void copyMem(const T *src,
T *dest,
const size_t count)
{
#ifdef HAVE_MEMCPY
memcpy(OFstatic_cast(void *, dest), OFstatic_cast(const void *, src), count * sizeof(T));
#else
register size_t i;
register const T *p = src;
register T *q = dest;
for (i = count; i != 0; --i)
*q++ = *p++;
#endif
}
/** moves specified number of elements from source to destination.
* Both src and dest must be aligned according to T's align requirements.
* If src and dest are not equal, they must be at least sizeof(T) bytes
* apart. These memory areas may overlap.
*
** @param src pointer to source memory
* @param dest pointer to destination memory
* @param count number of elements to be moved
*/
static void moveMem(const T *src,
T *dest,
const size_t count)
{
#ifdef HAVE_MEMMOVE
memmove(OFstatic_cast(void *, dest), OFstatic_cast(const void *, src), OFstatic_cast(size_t, count) * sizeof(T));
#else
if (src == dest)
return;
register size_t i;
register const T *p = src;
register T *q = dest;
if (src > dest)
{
// src is above dest in memory, we start copying from the start
for (i = count; i != 0; --i)
*q++ = *p++;
}
else
{
// src is below dest in memory, we start copying from the end
q += count - 1;
p += count - 1;
for (i = count; i != 0; --i)
*q-- = *p--;
}
#endif
}
/** sets specified number of elements in destination memory to a defined value
*
** @param dest pointer to destination memory
* @param value value to be set
* @param count number of elements to be set
*/
static void setMem(T *dest,
const T value,
const size_t count)
{
#ifdef HAVE_MEMSET
if ((value == 0) || (sizeof(T) == sizeof(unsigned char)))
memset(OFstatic_cast(void *, dest), OFstatic_cast(int, value), OFstatic_cast(size_t, count) * sizeof(T));
else
#endif
{
register size_t i;
register T *q = dest;
for (i = count; i != 0; --i)
*q++ = value;
}
}
/** sets specified number of elements in destination memory to zero
*
** @param dest pointer to destination memory
* @param count number of elements to be set to zero
*/
static void zeroMem(T *dest,
const size_t count)
{
#ifdef HAVE_MEMZERO
memzero(dest, OFstatic_cast(size_t, count) * sizeof(T));
#else
register size_t i;
register T *q = dest;
for (i = count; i != 0; --i)
*q++ = 0;
#endif
}
};
#endif
|