1 /*! 2 * \file src/mymem.h 3 * 4 * \brief Prototypes for memory routines. 5 * 6 * <hr> 7 * 8 * <h1><b>Copyright.</b></h1>\n 9 * 10 * PCB, interactive printed circuit board design 11 * 12 * Copyright (C) 1994,1995,1996 Thomas Nau 13 * 14 * This program 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 * This program is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU General Public License along 25 * with this program; if not, write to the Free Software Foundation, Inc., 26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 27 * 28 * Contact addresses for paper mail and Email: 29 * 30 * Thomas Nau, Schlehenweg 15, 88471 Baustetten, Germany 31 * 32 * Thomas.Nau@rz.uni-ulm.de 33 */ 34 35 #ifndef PCB_MYMEM_H 36 #define PCB_MYMEM_H 37 38 #ifdef HAVE_CONFIG_H 39 #include "config.h" 40 #endif 41 42 #include <stdlib.h> 43 #include "global.h" 44 45 /* --------------------------------------------------------------------------- 46 * number of additional objects that are allocated with one system call 47 */ 48 #define STEP_ELEMENT 50 49 #define STEP_DRILL 30 50 #define STEP_POINT 100 51 #define STEP_SYMBOLLINE 10 52 #define STEP_SELECTORENTRY 128 53 #define STEP_REMOVELIST 500 54 #define STEP_UNDOLIST 500 55 #define STEP_POLYGONPOINT 10 56 #define STEP_POLYGONHOLEINDEX 10 57 #define STEP_LIBRARYMENU 10 58 #define STEP_LIBRARYENTRY 20 59 #define STEP_RUBBERBAND 100 60 61 #define STRDUP(x) (((x) != NULL) ? strdup (x) : NULL) 62 63 /*! 64 * \brief Dynamic string type. 65 */ 66 typedef struct 67 { 68 size_t MaxLength; 69 char *Data; 70 } DynamicStringType; 71 72 RubberbandType * GetRubberbandMemory (void); 73 PinType * GetPinMemory (ElementType *); 74 PadType * GetPadMemory (ElementType *); 75 PinType * GetViaMemory (DataType *); 76 LineType * GetLineMemory (LayerType *); 77 ArcType * GetArcMemory (LayerType *); 78 RatType * GetRatMemory (DataType *); 79 TextType * GetTextMemory (LayerType *); 80 PolygonType * GetPolygonMemory (LayerType *); 81 PointType * GetPointMemoryInPolygon (PolygonType *); 82 Cardinal *GetHoleIndexMemoryInPolygon (PolygonType *); 83 ElementType * GetElementMemory (DataType *); 84 BoxType * GetBoxMemory (BoxListType *); 85 ConnectionType * GetConnectionMemory (NetType *); 86 NetType * GetNetMemory (NetListType *); 87 NetListType * GetNetListMemory (NetListListType *); 88 LibraryMenuType * GetLibraryMenuMemory (LibraryType *); 89 LibraryEntryType * GetLibraryEntryMemory (LibraryMenuType *); 90 ElementType **GetDrillElementMemory (DrillType *); 91 PinType ** GetDrillPinMemory (DrillType *); 92 DrillType * GetDrillInfoDrillMemory (DrillInfoType *); 93 void **GetPointerMemory (PointerListType *); 94 void FreePolygonMemory (PolygonType *); 95 void FreeElementMemory (ElementType *); 96 void FreePCBMemory (PCBType *); 97 void FreeBoxListMemory (BoxListType *); 98 void FreeNetListListMemory (NetListListType *); 99 void FreeNetListMemory (NetListType *); 100 void FreeNetMemory (NetType *); 101 void FreeDataMemory (DataType *); 102 void FreeLibraryMemory (LibraryType *); 103 void FreePointerListMemory (PointerListType *); 104 void DSAddCharacter (DynamicStringType *, char); 105 void DSAddString (DynamicStringType *, const char *); 106 void DSClearString (DynamicStringType *); 107 char *StripWhiteSpaceAndDup (const char *); 108 109 #ifdef NEED_STRDUP 110 char *strdup (const char *); 111 #endif 112 113 #ifndef HAVE_LIBDMALLOC 114 #define malloc(x) calloc(1,(x)) 115 #endif 116 117 #endif 118