Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace csc_set_data with OSQPCscMatrix_new #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions include/OsqpEigen/Compat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,22 @@ inline OSQPCscMatrix* spalloc(OSQPInt m,
OSQPInt n,
OSQPInt nzmax)
{
OSQPCscMatrix* M = static_cast<OSQPCscMatrix*>(calloc(1, sizeof(OSQPCscMatrix))); /* allocate the OSQPCscMatrix struct */
if (!M)
{
return static_cast<OSQPCscMatrix*>(OSQP_NULL);
}

OSQPInt* M_p = static_cast<OSQPInt*>(calloc(n + 1, sizeof(OSQPInt)));
if (!M_p)
{
free(M);
return static_cast<OSQPCscMatrix*>(OSQP_NULL);
}

OSQPInt* M_i = static_cast<OSQPInt*>(calloc(nzmax, sizeof(OSQPInt)));
if (!M_i)
{
free(M);
free(M_p);
return static_cast<OSQPCscMatrix*>(OSQP_NULL);
}

OSQPFloat* M_x = static_cast<OSQPFloat*>(calloc(nzmax, sizeof(OSQPFloat)));
if (!M_x)
{
free(M);
free(M_p);
free(M_i);
return static_cast<OSQPCscMatrix*>(OSQP_NULL);
Expand All @@ -86,7 +77,14 @@ inline OSQPCscMatrix* spalloc(OSQPInt m,
M_nnz = nzmax;
}

csc_set_data(M, m, n, M_nnz, M_x, M_i, M_p);
OSQPCscMatrix* M = OSQPCscMatrix_new(m, n, M_nnz, M_x, M_i, M_p);
if (!M)
{
free(M_p);
free(M_i);
free(M_x);
return static_cast<OSQPCscMatrix*>(OSQP_NULL);
}

return M;
}
Expand Down