Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102763
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Copying void * string to |
| Date | Wed, 10 Feb 2016 08:30:16 -0700 |
| Lines | 36 |
| Message-ID | <mailman.13.1455118266.22075.python-list@python.org> (permalink) |
| References | <004a01d163fb$aa7d8930$ff789b90$@ladybridge.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de yotlVeE1gG48/+ixN9TytAmWTuIDwqbvCA2GPXEWlPcw== |
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'memory.': 0.05; 'dynamically': 0.07; 'strings.': 0.07; 'terminated': 0.07; 'wrapper': 0.07; 'func': 0.09; 'pointers': 0.09; 'subject:string': 0.09; 'python': 0.10; 'def': 0.13; 'wed,': 0.15; '2016': 0.16; 'func.restype': 0.16; 'item)': 0.16; 'item):': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject: * ': 0.16; 'variable.': 0.16; 'wrote:': 0.16; 'string': 0.17; 'pointer': 0.18; 'string,': 0.18; 'variable': 0.18; 'library': 0.20; 'martin': 0.22; 'am,': 0.23; 'feb': 0.23; 'sets': 0.23; 'header :In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'allocated': 0.27; 'function': 0.28; 'code': 0.30; 'problem': 0.33; 'null': 0.33; 'received:google.com': 0.35; 'library.': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'several': 0.38; 'test': 0.39; 'does': 0.39; 'unable': 0.39; 'to:addr:python.org': 0.40; 'searches.': 0.84; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=P/m4lEWZoggnKBChEgNaED4dQQ+zsnK+aBIxMBTmFlg=; b=ppFqirv8pHVpDT3woKpfzFXNAGp8OQtu24mWcKGSCtrJqkeCKYleE3lPSkBrN+mpHQ a7SYvX9qkXHYolNfrBtxE9VQ5tOd09THiBGnKndljFs+qAgdXInxLf4aa3sqZFUQcHgy 46xY3tizUF/KraP8wNp87/2c3Fng6CRmWA/fdBbnsioQmbgur1guZVzg7FmLfkVd0ezU B0Z7VTyqWaW1bMM0+5LJwKU9yYRVO7GDb5oqy0mSAbi5HT3+2rMTSAHZdHrIH4asIzGG 6VEHFvwEaG96j+pnyOb835mGM6LFJCN2bPMHLx5CAUWfRVVT1nFQ8wLiqriMTHINMkJQ nu/A== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=P/m4lEWZoggnKBChEgNaED4dQQ+zsnK+aBIxMBTmFlg=; b=mvM60g4DBYJhoE9UUn3IsdunAgisXhsNxg7t+wKbKNaMiasIxTx3IbfGxgUmcg/epi R0iynrNlUsGnB5RtRFNNsaf1ToFc8zJYBkk+4QNSgpRHL2B9vVu0PJN1SkGUoajFR6rM buLnoWxXo5OPicbomBsBoklk6PpTkx7n+oupJJH4Xy6iM7FOASp4KKcSfJe/slBKfDkb RLqd7Y24n8p3r2hd8aaoTxuqYJhPROqJIb6q6EYsfdxY+DOkjy9gDwrZwdXaUwdP8uxV CvA/fEd48TRAAq0QRUneYjtnnFTX1rc5Mnc1nADyuoKs1A/MkuN/CiQnRr4a1+u+mvcZ 9s/Q== |
| X-Gm-Message-State | AG10YOT1LSQc8dSA6BCs/bBVqgJ1G0R9vFlgxXu2ZiNHG3Fr9mK7dwVquzQbzD7MH5gqne2EmbnPUKcvn1mKUg== |
| X-Received | by 10.50.131.201 with SMTP id oo9mr10447500igb.68.1455118255746; Wed, 10 Feb 2016 07:30:55 -0800 (PST) |
| In-Reply-To | <004a01d163fb$aa7d8930$ff789b90$@ladybridge.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:102763 |
Show key headers only | View raw
On Wed, Feb 10, 2016 at 5:07 AM, Martin Phillips <martinphillips@ladybridge.com> wrote: > I am writing a Python wrapper to go around a C library. I have encountered a problem that I have been unable to resolve with > countless web searches. > > > > Several functions in the C library return pointers to dynamically allocated w_char null terminated strings. I need to copy the > string to a Python variable and call an existing library function that will free the dynamically allocate memory. > > > > My test code for this is > > > > def Test(fno, item): > > func = mylib. MyFunc > > func.restype = ct.c_void_p > > s = func(fno, item) > > result = s > > mylib.free(s) > > return result > > > > The problem is with the line that sets the result variable. I need this to make a copy of the dynamically allocated string, not the > pointer to it. Does ctypes.wstring_at(s) do what you want?
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Copying void * string to Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-10 08:30 -0700
csiph-web