At Tuesday 7/11/2006 17:43, Sheldon wrote:
> And what are those non-static functions used for? The *only* purpose
> of your module should be to provide the Python bindings...
I wrote the C module to do some number crunching. Now I just need to
"connect" it to my python program. Should the initm
Gabriel Genellina skrev:
> At Tuesday 7/11/2006 17:27, Sheldon wrote:
>
> >Here is the file/module name: _msgpps_functions.c
> >Here is the initfunction:
> >
> >PyMODINIT_FUNC init_msgpps_functions(void) {
> > PyObject* m;
> > m=Py_InitModule("_msgpps_functions",_msgpps_functionsMethods);
> >
Hi,
> For a module called foo.c the initialization function must be called
> initfoo (*not* init_foo)
Ok, I fixed this part. Thanks
> And what are those non-static functions used for? The *only* purpose
> of your module should be to provide the Python bindings...
I wrote the C module to do so
At Tuesday 7/11/2006 17:27, Sheldon wrote:
Here is the file/module name: _msgpps_functions.c
Here is the initfunction:
PyMODINIT_FUNC init_msgpps_functions(void) {
PyObject* m;
m=Py_InitModule("_msgpps_functions",_msgpps_functionsMethods);
ErrorObject = PyString_FromString("_msgpps_functi
At Tuesday 7/11/2006 17:10, Sheldon wrote:
> Take a look at the documentation for creating extension modules,
> especially the following page:
>
> http://docs.python.org/ext/methodTable.html
>
> "The initialization function must be named initname(), where name is the
> name of the module, and sh
Robert Kern skrev:
> Sheldon wrote:
>
> > This function is there and is called init_mymodule() but I have other
> > functions that are not static.
>
> Is the module's name "_mymodule"? Or is it "mymodule"?
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harml
Sheldon wrote:
> This function is there and is called init_mymodule() but I have other
> functions that are not static.
Is the module's name "_mymodule"? Or is it "mymodule"?
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by o
Farshid Lashkari skrev:
> Sheldon wrote:
> > Can anyone give me some idea as to what this error means?
> >
> > "ImportError: dynamic module does not define init function "
> >
> > I am new at this and there is still a lot to learn.
> >
> > Any help is appreciated,
>
> Take a look at the documenta
Sheldon wrote:
> Can anyone give me some idea as to what this error means?
>
> "ImportError: dynamic module does not define init function "
>
> I am new at this and there is still a lot to learn.
>
> Any help is appreciated,
Take a look at the documentation for creating extension modules,
espe
In article <[EMAIL PROTECTED]>,
"Java and Swing" <[EMAIL PROTECTED]> wrote:
> one more update...
>
> if I remove PyMem_Free and free(...) ...so no memory clean up...I can
> still only call doStuff 4 times, the 5th attemp crashes Python.
>
> Java and Swing wrote:
> > update:
> > if I use C's fre
Bernhard Herzog wrote:
> "Java and Swing" <[EMAIL PROTECTED]> writes:
>
> > char *foo(const char *in) {
> > char *tmp;
> > tmp = (char *) malloc((strlen(in) * sizeof(char)) + 1);
> > strcpy(tmp, in);
> > ...
> > ...
> > free(tmp);
> > return someValue;
> > }
> >
> > Is
"Java and Swing" <[EMAIL PROTECTED]> writes:
> char *foo(const char *in) {
> char *tmp;
> tmp = (char *) malloc((strlen(in) * sizeof(char)) + 1);
> strcpy(tmp, in);
> ...
> ...
> free(tmp);
> return someValue;
> }
>
> Is that appropriate? I was under the impression tha
As far as my C Wrapper functions are concerned...I no longer have the
need for free(...). I do use PyMem_Free, for structures I allocated by
using PyMem_New(...).
In my C code I do have things such as...
char *foo(const char *in) {
char *tmp;
tmp = (char *) malloc((strlen(in) * sizeof(ch
"Java and Swing" <[EMAIL PROTECTED]> writes:
> thanks for the tip, however even when I do not free aString or bString,
> i'm still crashing at the malloc in the c function, not the wrapper.
Do you have any more places where you use free incorrectly? In my
experience, calling free with invalid va
thanks for the tip, however even when I do not free aString or bString,
i'm still crashing at the malloc in the c function, not the wrapper.
Bernhard Herzog wrote:
> "Java and Swing" <[EMAIL PROTECTED]> writes:
>
> > static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
> [...]
> >
"Java and Swing" <[EMAIL PROTECTED]> writes:
> static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
[...]
> char *aString = 0;
> char *bString = 0;
[...]
> int ok = PyArg_ParseTuple(args, "sss", &in, &aString, &bString);
[...]
> free(aString);
> free(bStrin
ok, further digging...I found that in the C function GetVal...it is
crashing where I try to malloc some memory. Note, I have no problems
when running this from C..just from Python using my wrapper.
GetVal looks something like..
MY_NUM *GetVal(const char *in, const int x) {
MY_NUM *results, *re
Sorry about the double post...
anyhow, after putting in debug statements I found that it was crashing
when it called, free(result)so I removed the free(result).
now it crashes when it gets to, b = GetVal(bString, count(bString,
","));
..any ideas?
Java and Swing wrote:
> Antoon,
>I just
Antoon,
I just saw that to. I updated the code like so...
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
// this will store the result in a Python object
PyObject *finalResult;
// get arguments from Python
char *result = 0;
char *in= 0;
Antoon,
I just saw that to. I updated the code like so...
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
// this will store the result in a Python object
PyObject *finalResult;
// get arguments from Python
char *result = 0;
char *in= 0;
Op 2005-10-12, Java and Swing schreef <[EMAIL PROTECTED]>:
> static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
> // this will store the result in a Python object
> PyObject *finalResult;
>
> // get arguments from Python
> char *result = 0;
> char *in= 0;
one more update...
if I remove PyMem_Free and free(...) ...so no memory clean up...I can
still only call doStuff 4 times, the 5th attemp crashes Python.
Java and Swing wrote:
> update:
> if I use C's free(result), free(a) free(b) instead of PyMem_Free...I
> only get one successfuly use/call of do
update:
if I use C's free(result), free(a) free(b) instead of PyMem_Free...I
only get one successfuly use/call of doStuff.
i.e.
// this works
doStuff(...)
// python crashes here
doStuff(...)
Java and Swing wrote:
> static PyObject *wrap_doStuff(PyObject *self, PyObject *args) {
> // this w
23 matches
Mail list logo