allocate & free
- Posted by irvm at ellijay.com
Dec 10, 2001
Hi:
I must not be using allocate() and/or free() correctly:
Here's the code, which, if the --// comment is removed, will
fill a list control: (that part works fine)
for i = 1 to db_table_size() do
data = db_record_data(i)
len = length(data)+1
addresses = allocate(len*4)
poke4(addresses,allocate_string(db_record_key(i)))
for j = 1 to length(data) do
if atom(data[j]) then
data[j] = sprintf("%g",data[j]) -- change numeric fields to text
end if
poke4(addresses+j*4,allocate_string(data[j]))
end for
--// ok = gtk_clist_append(list,addresses)
free(addresses)
end for
Problem is, each time this is run, extra memory is used, corresponding to the
length of the data loaded. Eventually, I would run out of menory. It does the
same whether or not the call to gtk_list_append() is made, so that's not the
problem. That leaves free(). Am I not using it correctly?
Thanks for any help,
Irv
|
Not Categorized, Please Help
|
|