octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #54096] mxCreateStructMatrix with a NULL argum


From: Julien Bect
Subject: [Octave-bug-tracker] [bug #54096] mxCreateStructMatrix with a NULL argument creates a "corrupt" structure
Date: Mon, 11 Jun 2018 13:14:12 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Follow-up Comment #5, bug #54096 (project octave):

> Anyway, I think you mean a NULL argument to mxSetFieldByNumber?

In the title, yes, I meant mxSetFieldByNumber.  Can you please change that?


> I'm pretty sure that mxCreateDoubleMatrix (0, 0, mxREAL)
> does not return NULL.

Of course not.


> But maybe Matlab handles NULL specially in this case?

Yes.  My understanding is that, when a structure is created by
mxCreateStructureArray, or even by struct () in Matlab, the fields are
initialized to NULL, and Matlab treats this as "empty".


> Regardless, we should definitely not be creating invalid
> objects.

They are not invalid from Matlab's point of view...


> However, I'm curious to know whether it is documented
> that Matlab accepts NULL here to mean "empty matrix".

Sort of.  The documentation of mxGetFieldByNumber says that it "returns NULL
in C (0 in Fortran) if passed an invalid argument or if there is no value
assigned to the specified field."

https://www.mathworks.com/help/matlab/apiref/mxgetfieldbynumber.html

The possibility of a NULL pointer there is thus explicitely documented.  What
is not clearly written, however, is the fact that this is interpreted as [] if
the field is read (but what else could it be ?).


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?54096>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]