Article 6HWBQ Python. NULL a pointer returned from a c funtion.

Python. NULL a pointer returned from a c funtion.

by
jmgibson1981
from LinuxQuestions.org on (#6HWBQ)
I figured out to use the gc library. But I'm still getting a single leak which is only 120bytes. I'm thinking it's the pointer not being NULLed.

How can I do that? Once I've run del var it's got nothing to point to.

That or am I going about this wrong. stuck.

Code:#!/usr/bin/python3
# python bindings for libjmgeneral.so

import ctypes
from ctypes import *
import pathlib
import gc

lib = pathlib.Path().absolute() / "/usr/local/lib/libjmgeneral.so"
libjmgen_lib = ctypes.CDLL(lib)

def random_gen(a, b):
return libjmgen_lib.random_gen(a, b)

def clear_ptr(a):
del a



def prompt_input_getline(a):
prompt_input_getline = libjmgen_lib.prompt_input_getline
prompt_input_getline.argtypes = [c_char_p]
prompt_input_getline.restype = c_char_p
result = prompt_input_getline(a.encode('utf-8'))
return result.decode('utf-8')

y = prompt_input_getline("lol")

print(y)

clear_ptr(y)
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments