malloc error for newbie
David
dwarnold45 at suddenlink.net
Sat Jul 7 02:59:22 EDT 2007
Hi,
Very new to python. When I uncomment the line
# self.im.putpalette(mkpalette())
in the following code, I get the error:
python $ ./mandelbrot.py
Python(2860) malloc: *** Deallocation of a pointer not malloced:
0xff000000; This could be a double free(), or free() called with the
middle of an allocated block; Try setting environment variable
MallocHelp to see tools to help debug
I don't have the expertise to get by this error. Can someone help?
Thanks.
#! /usr/local/bin/python
# Filename: mandelbrot.py
import Image, ImagePalette
def mkpalette():
global palette
palette = [0,0,0]
for i in range(256):
palette.extend([i*5%200+55,i*7%200+55,i*11%200+55])
return palette
class Mandelbrot:
def __init__(self,filename='mandelbrot.png',
size=(512,512),
n=64,
box=((-2,1.25), (0.5,-1.25))):
self.filename=filename
self.size=size
self.n=n
self.uleft=box[0]
self.lright=box[1]
self.width=self.lright[0]-self.uleft[0]
self.height=self.uleft[1]-self.lright[1]
def newimage(self):
self.im=Image.new('P', self.size)
# self.im.putpalette(mkpalette())
def compute(self):
self.newimage()
def test():
f=Mandelbrot(filename='mandelbrot.png',
size=(512,512),
n=64,
box=((-2,1.25), (0.5,-1.25)))
f.compute()
if __name__=='__main__':
test()
More information about the Python-list
mailing list