Exemple #1
0
 def allocate_S(length, size):
     s = rcalloc(1, sizeof(nb_S)).cast(nb_Sp)
     s.data = rcalloc(length, sizeof(nb_Tp)).cast(nb_Tpp)
     s.length = length
     for i in range(length):
         s.data[i] = rcalloc(size, sizeof(nb_T)).cast(nb_Tp)
     s.size = size
     return s
Exemple #2
0
 def viewitem(s, i):
     s1 = rcalloc(1, sizeof(nb_S1)).cast(nb_S1p)
     if i >= 0 and i < s.size:
         s1.size = s.size
         s1.data = s.data[i]
     else:
         s1.size = 0
     return s1
Exemple #3
0
 def resize_S(s, size):
     if s.size == size:
         return
     if s.size != 0:
         rfree(s.data)
         s.size = 0
     if s.size == 0 and size > 0:
         raw = rcalloc(size, sizeof(nb_T))
         s.data = raw
         s.size = size
Exemple #4
0
 def allocate_S(i):
     raw = rcalloc(i, sizeof(nb_S))
     s = cast(raw, nb_Sp)     # cast `void*` to `S*`
     # s = raw.cast(Sp)       # cast `void*` to `S*`
     s.size = 0
     return s
Exemple #5
0
 def sizeof_S(s):
     return sizeof(s)
Exemple #6
0
 def allocate_S(i):
     return rcalloc(i, sizeof(nb_S))