fix_lumps.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * $Id$
  3. *
  4. * here, we delete message lumps which are generated in
  5. * core functions using pkg_malloc and applied to shmem
  6. * requests; not doing so would result ugly memory problems
  7. *
  8. * I admit it is not a nice hack; -jiri
  9. *
  10. * Copyright (C) 2001-2003 Fhg Fokus
  11. *
  12. * This file is part of ser, a free SIP server.
  13. *
  14. * ser is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version
  18. *
  19. * For a license to use the ser software under conditions
  20. * other than those described here, or to purchase support for this
  21. * software, please contact iptel.org by e-mail at the following addresses:
  22. * [email protected]
  23. *
  24. * ser is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program; if not, write to the Free Software
  31. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  32. */
  33. #ifndef _FIX_LUMPS_H
  34. #define _FIX_LUMPS_H
  35. /* used to delete attached via lumps from msg; msg can
  36. be either an original pkg msg, whose Via lump I want
  37. to delete before generating next branch, or a shmem-stored
  38. message processed during on_reply -- then I want to
  39. delete the Via lump for the same reason
  40. the other case when I want to delete them is when a message
  41. is stored in shmem for branch picking, forwarded lated and
  42. Via removal is applied to the shmem-ed message
  43. */
  44. inline static void free_via_lump( struct lump **list )
  45. {
  46. struct lump *prev_lump, *lump, *a, *foo;
  47. prev_lump=0;
  48. for(lump=*list;lump;lump=lump->next) {
  49. if (lump->type==HDR_VIA) {
  50. a=lump->before;
  51. while(a) {
  52. foo=a; a=a->before;
  53. free_lump(foo);
  54. pkg_free(foo);
  55. }
  56. a=lump->after;
  57. while(a) {
  58. foo=a; a=a->after;
  59. free_lump(foo);
  60. pkg_free(foo);
  61. }
  62. if (prev_lump) prev_lump->next = lump->next;
  63. else *list = lump->next;
  64. free_lump(lump);pkg_free(lump);
  65. } else {
  66. /* store previous position */
  67. prev_lump=lump;
  68. }
  69. }
  70. }
  71. #endif