Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 1 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


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.