File: reassign_typeconstant.c

package info (click to toggle)
python-ltfatpy 1.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,412 kB
  • sloc: ansic: 8,546; python: 6,470; makefile: 15
file content (48 lines) | stat: -rw-r--r-- 1,310 bytes parent folder | download | duplicates (5)
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
#include "ltfat.h"

LTFAT_EXTERN_TOO fbreassOptOut*
fbreassOptOut_init(const ltfatInt l, const ltfatInt inital)
{
   fbreassOptOut* ret = ltfat_calloc( 1, sizeof * ret);
   ret->l = l;
   // This is an array of pointers.
   ret->repos = ltfat_malloc(l * sizeof * ret->repos);
   ret->reposl = ltfat_calloc(l , sizeof * ret->reposl);
   ret->reposlmax = ltfat_malloc(l * sizeof * ret->reposlmax);
   ltfatInt inital2 = imax(1, inital);
   for (ltfatInt ii = 0; ii < l; ii++)
   {
      ret->repos[ii] = ltfat_malloc( inital2 * sizeof * ret->repos[ii]);
      ret->reposlmax[ii] = inital2;
   }

   return ret;
}

LTFAT_EXTERN_TOO void
fbreassOptOut_destroy(fbreassOptOut* oo)
{

   for (ltfatInt ii = 0; ii < oo->l; ii++)
   {
      if (oo->repos[ii] && oo->reposlmax[ii] > 0)
      {
         ltfat_free(oo->repos[ii]);
      }
   }

   LTFAT_SAFEFREEALL(oo->repos, oo->reposl, oo->reposlmax, oo);
   oo = NULL;
}

LTFAT_EXTERN_TOO void
fbreassOptOut_expand(fbreassOptOut* oo, ltfatInt ii)
{
   ltfatInt explmax = (ltfatInt) (fbreassOptOut_EXPANDRAT * oo->reposlmax[ii]);
   oo->repos[ii] = ltfat_realloc_and_copy(
                      oo->repos[ii],
                      oo->reposlmax[ii] * sizeof * oo->repos[ii],
                      explmax * sizeof * oo->repos[ii]);
   oo->reposlmax[ii] = explmax;
}