Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In certain functions in GSL (GNU Scientific Library), some functions take a "workspace" environment as an argument. For example, gsl_poly_dd_taylor from this page. Why? Wouldn't it be easier for the function to allocate its own memory, or at least the same difficulty? I suppose that this allows the caller to specify where the function works, but I don't see how it helps.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Efficiency. GSL is designed to be both time and memory efficient and it makes more sense to pass around the same workspace than have each and every function allocate and free its own.

share|improve this answer
    
Makes sense. Hadn't thought about reusing the same workspace. Thanks! –  David Millard Oct 31 '12 at 17:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.