| 1 |
/* 'checkit_tiff' is a conformance checker for baseline TIFFs |
| 2 |
* |
| 3 |
* author: Andreas Romeyke, 2015-2025 |
| 4 |
* licensed under conditions of libtiff |
| 5 |
* (see http://libtiff.maptools.org/misc.html) |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
#include <assert.h> |
| 10 |
#include "strcopy.h" |
| 11 |
#include <string.h> |
| 12 |
|
| 13 |
void cit_strcopy(char *dest, size_t dsize, const char *src, size_t slen) { |
| 14 |
/* assert slen has enough space in dsize */ |
| 15 |
assert(dsize > slen); |
| 16 |
assert(dest != NULL); |
| 17 |
if (dest) dest[0] = 0; /* if dest is not empty */ |
| 18 |
if (slen <dsize) { /* if enough space, copy */ |
| 19 |
memcpy(dest, src, slen); |
| 20 |
dest[slen] = 0; /* set null terminator at end */ |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
|