0

I am having some problems dynamically declaring a GLfloat array in Objective-C. Here is the c ode i'm using:

GLfloat *m_bindPositions;

@implementation

int nVerts           = [self m_countVertices];
m_bindPositions      = (GLfloat*)malloc((nVerts * 3) * sizeof(GLfloat));

nVerts in this example equals 6704.

if I was to run sizeof(m_bindPositions) it should return 80448.

It currently returns 4.This makes me believe there is an error with the allocation of the

memory and I am not entirely sure why. Any help would be much appreciated.

Thanks

1 Answer 1

3

sizeof in this case is returning the size of the pointer, not the data pointed at by it.

However, the compiler is what handles sizeof, and it will not dynamically return values based on malloc, so you cannot double-check an allocation like that using sizeof (or anything else, other than malloc_size(), which will return a number equal to or greater than the allocation, representing the allocation block size.

Sign up to request clarification or add additional context in comments.

1 Comment

You beat me by one second :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.