docs: def spline(x, y, n, yp1, ypn, y2):
      '''
  /*       CALCULATE 2ND DERIVATIVES OF CUBIC SPLINE INTERP FUNCTION
   *       ADAPTED FROM NUMERICAL RECIPES BY PRESS ET AL
   *       X,Y: ARRAYS OF TABULATED FUNCTION IN ASCENDING ORDER BY X
   *       N: SIZE OF ARRAYS X,Y
   *       YP1,YPN: SPECIFIED DERIVATIVES AT X[0] AND X[N-1]; VALUES
   *                >= 1E30 SIGNAL SIGNAL SECOND DERIVATIVE ZERO
   *       Y2: OUTPUT ARRAY OF SECOND DERIVATIVES
   */
   '''
      u = [0.0]*n #I think this is the same as malloc
  
      #no need for the out of memory
  
      if (yp1 > 0.99E30): # pragma: no cover
          y2[0] = 0
          u[0] = 0
      else:
          y2[0]=-0.5
          u[0]=(3.0/(x[1]-x[0]))*((y[1]-y[0])/(x[1]-x[0])-yp1)
  
      for i in range(1, n-1):
          sig = (x[i]-x[i-1])/(x[i+1] - x[i-1])
          p = sig * y2[i-1] + 2.0
          y2[i] = (sig - 1.0) / p
          u[i] = (6.0 * ((y[i+1] - y[i])/(x[i+1] - x[i]) -(y[i] - y[i-1]) / (x[i] - x[i-1]))/(x[i+1] - x[i-1]) - sig * u[i-1])/p;
  
      if (ypn>0.99E30): # pragma: no cover
          qn = 0;
          un = 0
      else:
          qn = 0.5
          un = (3.0 / (x[n-1] - x[n-2])) * (ypn - (y[n-1] - y[n-2])/(x[n-1] - x[n-2]));
  
      y2[n-1] = (un - qn * u[n-2]) / (qn * y2[n-2] + 1.0);
  
      #it uses a for loop here, but its not something python can do (I dont think)
      k = n-2
      while(k >= 0):
          y2[k] = y2[k] * y2[k+1] + u[k]
          k -= 1
      #This for loop might work
      #for k in range(n-2, -1, -1):
      #    y2[k] = y2[k] * y2[k+1] + u[k]
      #no need to free u here
      return