473,698 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

porting non-malloc code to malloc

Hi,
I want to post some code which has defn like

struct AVPicture {
int *data[4];
int linesize[4];
}
the is noe recognised by matlab, so i need to port to some form like
struct AVPicture {
int **data;
int *linesize;
}

Now whatz the best way to go about this process

1. write a wrapper header, but how to initialize the constants ?? like
... **data to *data[]
2. rewrites the source .. [impossible]

-madan

Nov 14 '05 #1
3 1499
mi*********@gma il.com wrote:
Hi,
I want to post some code which has defn like

struct AVPicture {
int *data[4];
int linesize[4];
}
the is noe recognised by matlab, so i need to port to some form like
struct AVPicture {
int **data;
int *linesize;
}
Maybe it is just me but I cannot make much sense out of
this. Why do you want to post code but do not do it?
Matlab offers an interface for C code but this is a Matlab
thing, not a C thing.
What is the problem with the above structures?
That you have to pass only pointers to your data or that
you want to be able to size the arrays as you need them or ...?

Now whatz the best way to go about this process

1. write a wrapper header, but how to initialize the constants ?? like
.. **data to *data[]
What constants? Do you mean macros?
2. rewrites the source .. [impossible]


Please try to state your problem more clearly and provide
a minimal example which exhibits the erroneous behaviour or
shows the difference you need.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 14 '05 #2
Matlab has the ability to load MSVC compliant DLL's, atleast thatz what
they claim.

matlab has a function called loadlibary, which can can load my DLL
for ex: loadlibrary('my lib.dll','mylib .h')
where mylib.h is the interface header file.

the problem with matlab is that, it works perfectly laod the dll as
long as there are pointers to functions , and sized constants (ex. int
linesize[4]) ..

Now my problem, is that the DLL i have already has those sized
constants. I need to write a wrapper, which basically converts the
single or 2D pointers, to the corresponding formats.
for ex. the matlab interface needs int *linesize, but the DLL has int
linesize[4].

-madan

Nov 14 '05 #3
In article <11************ *********@f14g2 000cwb.googlegr oups.com>,
<mi*********@gm ail.com> wrote:
:Now my problem, is that the DLL i have already has those sized
:constants. I need to write a wrapper, which basically converts the
:single or 2D pointers, to the corresponding formats.
:for ex. the matlab interface needs int *linesize, but the DLL has int
:linesize[4].

If you were to pass an arbitrary structure into a C function, by
casting the pointer to void*, then there is no standard way for the
function to be able to figure out what the structure looks like
internally. (Some implimentations might have non-standard ways.) You
will thus not be able to write a C function which can be passed an
arbitrary structure and which will construct the appropriate new
structure.

Similarily, if you try to work it at the preprocessor level, you will
find that the preprocessor has no way to refer to items such as "the
first element of the named parameter". You thus will not be able to do
what you want by a preprocessor macro being passed an arbitrary
structure.

If you were willing to rewrite all your structure definitions, then you
could perhaps [in newer versions of C] write something like a
"DEFINE_STRUCTU RE" macro that took as arguments all the pieces of the
structure, and which emitted both the regular 'struct' definition and
the modified definition you needed. Except that you want more than just
that -- you would also want to emit a pair of function that converted
between the two forms. I don't know if that is possible with a variable
number of arguments even in C99 [I haven't looked at what the C99
preprocessor is capable of.]
What I would suggest to you is that your problem would be most easily
solved outside the C program itself, by using some preprocessing
of your header files. As the preprocessing would be largely
textual, I would suggest that a program such as perl might be
easier to impliment this in than in pure C. The idea would be
to write a program (e.g., perl script) which read your header
files that define your structures, and emitted code that
defined the modified header and defines functions to do the
conversion. If you have lots of code, you could get fancier and
add a script that read through the code, figured out which
structures were referenced, and inserted #include statements
into the code to import the modified structure definitions
and conversion functions.
--
We don't need no side effect-ing
We don't need no scope control
No global variables for execution
Hey! Did you leave those args alone? -- decvax!utzoo!ut csrgv!roderick
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1504
by: Mark Hahn | last post by:
(I apologize in advance if this is not an appropriate posting) I have written a simple windows shareware app, EzPicMailer, in Python 2.3, wxPython 2.4.1, and PIL 1.1.4 that lets computer novices find photo files, edit them, and mail them, all in one simple app. Everyone is encouraged to check out my beta version at http://EzPicMailer.com. I wrote it to be cross-platform except for a small amout of windows code to do the system beep...
2
3367
by: eichin | last post by:
One of my recent projects has involved taking an accretion of sh and perl scripts and "doing them right" - making them modular, improving the error reporting, making it easier to add even more features to them. "Of course," I'm redoing them in python - much of the cut&paste reuse has become common functions, which then get made more robust and have a common style and are callable from other (python) tools directly, instead of having to...
14
3300
by: Wolfgang Keller | last post by:
Hello, as a non-developer I am currently participating in an industrial "research" project to develop a so-called "web application". This application serves at the same time as middleware to connect several other "conventional" enterprise-applications such as ERP, SCADA etc. and to provide a GUI frontend to the users. The developers are into Struts, Enterprise Java Beans and the like, so it will be entirely implemented in Java with all...
4
2004
by: golu | last post by:
Has any body done the porting from oracle to sql server, what were the issues in porting the data bases? Also suggest some resources which can be helpful in the porting project TIA Golu
4
2381
by: Chris Travers | last post by:
Hi all; A few years ago, I set about porting a PHP application from MySQL to PostgreSQL, after realizing that MySQL wasn't going to be able to handle it. In order to do this, I built a light, fast database abstraction layer which conforms to the behavior of the MySQL functions in PHP. This means that a large amount of porting work could be made simple using this porting layer if the application was originally used PHP's native MySQL...
2
1194
by: Theo Harlauch | last post by:
Hi, I'm quite sure if this newsgroup is suitable for my question but I'll give it a try. I'd like to port an application of mine which is currently just curses driven to a guish one. For now, all users ssh(normal login and password) to a linux server and start the app by typing its name on the prompt. So they are all starting the same executable on the server. So I don't have to bother with any remote database connections.
2
1264
by: rawCoder | last post by:
Hi all, I have an application in visual basic 6 which communicates with servers written in ANSI C++ using a C++ ( non COM ) dll by passig data through functions in UDT and receiving data back through events posted back to UI from DLL. I was interested in porting the system to VB.NET and VC.NET / VC ++ with an eye on any possible speed loss.
4
5725
by: r.nikhilk | last post by:
Hi, We are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by including the -q64 option in xlC compiler. But, when we link all these libraries to one of the main applications, we are getting the following errors: ld: 0711-317 ERROR: Undefined symbol: .FxCharFile::good() const ld: 0711-317 ERROR: Undefined symbol:...
5
3026
by: shobhah | last post by:
Hi, We have a complete succsssfully working product on 32bit sparc solaris machine for which compiler used is CC 5.8 Now we are migarting our product from 32 bit to 64bit sparc solaris machine. While porting we need 64 bit compiler issues for our application product which is wriiten in completely C++. We tried with -xarch=v9 and -xport64=full compiler options to find out 64bit porting problems. But we did not find any issues for our...
47
2355
by: =?Utf-8?B?ZW1hdmlzdQ==?= | last post by:
Dear guys, I'm in trouble having to port my project from C++Builder6 to VisualC++. Has anyone of you idea if there are any tools to help my doing this job? My current project is widely using VCL and these 2 IDE (C++Builder and VisualC++) seems to be so far each other that I can hardly think to find out a tool to "automatically" perform something for me. Thank you.
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.