Skip to content

Commit

Permalink
Allow dynamic numbers of numeric and string attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
salcock committed Mar 26, 2021
1 parent cedc051 commit 4e48f03
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/pyavro_stardust/baseavro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ cdef class AvroRecord:
self.attributes_s = NULL

def __init__(self, numeric, strings):
self.attributes_l = <long *>PyMem_Malloc(sizeof(long) * numeric)
self.attributes_s = <char **>PyMem_Malloc(sizeof(char *) * strings)

for i in range(numeric):
self.attributes_l[i] = 0
for i in range(strings):
self.attributes_s[i] = NULL
if (numeric > 0):
self.attributes_l = <long *>PyMem_Malloc(sizeof(long) * numeric)
for i in range(numeric):
self.attributes_l[i] = 0

if (strings > 0):
self.attributes_s = <char **>PyMem_Malloc(sizeof(char *) * strings)
for i in range(strings):
self.attributes_s[i] = NULL
self.sizeinbuf = 0
self.stringcount = strings
self.numcount = numeric
Expand Down

0 comments on commit 4e48f03

Please sign in to comment.