By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,688 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,688 IT Pros & Developers. It's quick & easy.

Pointer to a Structure to pass to a C function

P: 1
Let me preface this by I am very new to python programming...
I was looking at an old discussion about this that basically showed how to create a pointer to a structure to send to a C function in a DLL, it was...
Expand|Select|Wrap|Line Numbers
  1. from ctypes import *
  2.  
  3. class STUDENT(Structure):
  4.     _fields_ = [('name', c_int), ('id', c_int), ('addition', c_ubyte)]
  5.     buffer = (c_byte * 1024)()
  6.     buffer_p = pointer(buffer)
  7.     student_p = cast(buffer_p, POINTER(STUDENT))
My questions are about the line of code:
"buffer = (c_byte * 1024)()"

1) Is the purpose of the 1024 simply to allocate enough bytes to hold the structure?

2) If so, should there a better way to allocate a buffer of the correct size?
Dec 16 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.