Updating changelog, Adding test case for issue #5309
[cabal.git] / cabal-testsuite / PackageTests / Regression / T5309 / memoized-tcm / dynamicCharacterOperations.c
blob26b1b418c59ae124c3f6b2d4fd0bf6e47a1b6c84
1 #include <inttypes.h>
2 #include <stdint.h>
3 #include <stdio.h>
4 #include <stdlib.h>
6 #include "dynamicCharacterOperations.h"
8 #define __STDC_FORMAT_MACROS
10 size_t dynCharSize(size_t alphSize, size_t numElems) { return 1; }
12 size_t dcElemSize(size_t alphSize) { return 1; }
14 packedChar *allocatePackedChar( size_t alphSize, size_t numElems ) {
15 packedChar *outChar = (packedChar*) calloc( dynCharSize(alphSize, numElems), sizeof(packedChar) );
16 if (outChar == NULL) {
17 printf("Out of memory.\n");
18 fflush(stdout);
19 exit(1);
21 return outChar;
24 packedChar *makePackedCharCopy( packedChar *inChar, size_t alphSize, size_t numElems) {
25 packedChar *outChar = allocatePackedChar(alphSize, numElems);
26 size_t length = dynCharSize(alphSize, numElems);
27 for (size_t i = 0; i < length; i++) {
28 outChar[i] = inChar[i];
30 return outChar;
33 void freeDynChar( dynChar_t *p ) { free( p->dynChar ); }
35 void freeDCElem( const dcElement_t *p ) { free( p->element ); }