STATIC struct Image *ImageDupPooled(APTR pool, struct Image *src) { struct Image *dest; if (!src) return NULL; dest = (struct Image*)AllocPooled(pool,sizeof(struct Image)); if (dest) { int data_size = 0; int plane_size; int i; int plane_pick = src->PlanePick; *dest = *src; dest->NextImage = NULL; /* Calc the size all used planes */ plane_size = RASSIZE(src->Width,src->Height); for (i=0;i<8;i++) { if (plane_pick & 1) data_size += plane_size; plane_pick >>= 1; } if ((dest->ImageData = AllocPooled(pool,data_size))) { memcpy(dest->ImageData,src->ImageData,data_size); #ifdef OUTPUT_DATA kprintf("plane_pick = %ld\n",src->PlanePick); kprintf("width = %ld\n",src->Width); kprintf("height = %ld\n",src->Height); for (i=0;i<data_size;i++) { kprintf("0x%02lx,",((unsigned char*)src->ImageData)[i]); if (i%16 == 15) kprintf("\n"); } kprintf("\n"); #endif return dest; } /* Something failed so we fail also */ FreePooled(pool,dest,sizeof(struct Image)); } return NULL; }
STRPTR ScanToken( BPTR File ) { STRPTR Anchor, Ptr = AllocPooled( Memory, sizeof( BYTE ) * 64 ); if( Anchor = Ptr ) { while( isspace( *Ptr = FGetC( File ))); if( *Ptr == '"' ) { *Ptr = ( BYTE )FGetC( File ); while( *Ptr != '"' ) *(++Ptr) = ( BYTE )FGetC( File ); } else { do *(++Ptr) = ( BYTE )FGetC( File ); while( !isspace( *Ptr )); } *Ptr = '\0'; } return Anchor; }
ULONG PUBLIC IFFStreamHook(REG(a0, struct Hook *h), REG(a2, struct IFFHandle *iff), REG(a1, struct IFFStreamCmd *sc)) { struct IFFStreamHookData *is = h->h_Data; switch(sc->sc_Command) { case IFFCMD_INIT: if (!is) return(-1L); is->is_Position = 0; break; case IFFCMD_CLEANUP: break; case IFFCMD_READ: CopyMem(is->is_Buffer+is->is_Position,sc->sc_Buf,sc->sc_NBytes); is->is_Position += sc->sc_NBytes; break; case IFFCMD_WRITE: if (is->is_Position+sc->sc_NBytes > is->is_Size) { APTR temp; ULONG size = is->is_Size; for(;sc->sc_NBytes+is->is_Position > size;size += BUFFERSIZE); if (is->is_Pool) temp = AllocPooled(is->is_Pool,size); else temp = AllocMem(size,0L); if (!temp) return(-1); if (is->is_Buffer) { if (is->is_Position) CopyMem(is->is_Buffer,temp,is->is_Position); if (is->is_Pool) FreePooled(is->is_Pool,is->is_Buffer,is->is_Size); else FreeMem(is->is_Buffer,is->is_Size); is->is_Buffer = temp; is->is_Size = size; } } CopyMem(sc->sc_Buf,is->is_Buffer+is->is_Position,sc->sc_NBytes); is->is_Position += sc->sc_NBytes; break; case IFFCMD_SEEK: is->is_Position += sc->sc_NBytes; break; } if (is->is_Position < 0 || is->is_Position > is->is_Size) return(-1L); return(0L); }
APTR ami_misc_itempool_alloc(APTR pool, int size) { #ifdef __amigaos4__ return ItemPoolAlloc(pool); #else return AllocPooled(pool, size); #endif }
PtrT AtomNew(AtomPoolT *atomPool) { PtrT ptr = AllocPooled(atomPool->pool, atomPool->atomSize); if (!ptr) PANIC("AllocPooled(%p, %ld) failed.", atomPool->pool, atomPool->atomSize); return ptr; }
STATIC STRPTR StrDupPooled(APTR pool, STRPTR str) { char *newstr; if (!str) return NULL; newstr = AllocPooled(pool,strlen(str)+1); if (newstr) strcpy(newstr,str); return newstr; }
STATIC UBYTE *MemDupPooled(APTR pool, UBYTE *src, ULONG size) { UBYTE *newmem; newmem = AllocPooled(pool, size); if (newmem) memcpy(newmem, src, size); return newmem; }
BOOL fire_message(struct Window *w,ULONG Class, UWORD Code, APTR IAddress, struct IntuitionBase *IntuitionBase) { struct ExtIntuiMessage *imsg; BOOL result = FALSE; if ((w->IDCMPFlags & Class) && (w->UserPort)) { if ((imsg = (struct ExtIntuiMessage *)alloc_intuimessage(w, IntuitionBase))) { struct IIHData *iihdata = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data; imsg->eim_IntuiMessage.Class = Class; imsg->eim_IntuiMessage.Code = Code; imsg->eim_IntuiMessage.Qualifier = iihdata->ActQualifier; if (Class == IDCMP_RAWKEY) { INT_INTUIMESSAGE(imsg)->prevCodeQuals = IAddress; imsg->eim_IntuiMessage.IAddress = &INT_INTUIMESSAGE(imsg)->prevCodeQuals; } else { imsg->eim_IntuiMessage.IAddress = IAddress; } if (iihdata->ActEventTablet && (w->MoreFlags & WMFLG_TABLETMESSAGES)) { if ((imsg->eim_TabletData = AllocPooled(GetPrivIBase(IntuitionBase)->IDCMPPool,sizeof (struct TabletData)))) { memclr(imsg->eim_TabletData,sizeof (struct TabletData)); imsg->eim_TabletData->td_XFraction = iihdata->ActEventTablet->ient_ScaledXFraction; imsg->eim_TabletData->td_YFraction = iihdata->ActEventTablet->ient_ScaledYFraction; imsg->eim_TabletData->td_TabletX = iihdata->ActEventTablet->ient_TabletX; imsg->eim_TabletData->td_TabletY = iihdata->ActEventTablet->ient_TabletY; imsg->eim_TabletData->td_RangeX = iihdata->ActEventTablet->ient_RangeX; imsg->eim_TabletData->td_RangeY = iihdata->ActEventTablet->ient_RangeY; imsg->eim_TabletData->td_TagList = CloneTagItems(iihdata->ActEventTablet->ient_TagList); } } send_intuimessage(imsg, w, IntuitionBase); result = TRUE; } else { DEBUG_FIREINTUIMSG(dprintf("fire_intuimessage: can't alloc imsg\n")); } } else { DEBUG_FIREINTUIMSG(dprintf("fire_intuimessage: no Userport or masked out idcmpflags\n")); } return result; }
STRPTR *ScanTokenArray( BPTR File ) { LONG NumTokens = ScanDigit( File ), i; STRPTR *Tokens; if( Tokens = AllocPooled( Memory, sizeof( STRPTR ) * ( NumTokens + 1 ))) for( i = 0; i < NumTokens; i++ ) Tokens[i] = ScanToken( File ); return Tokens; }
struct line_node *AllocLine(struct InstData *data) { struct line_node *newline; ENTER(); newline = AllocPooled(data->mypool, sizeof(struct line_node)); RETURN(newline); return newline; }
static STRPTR mkcstr(APTR pool, BSTR bstr) { UBYTE *str = BADDR(bstr); UBYTE *buf; UBYTE len = str[0]; buf = AllocPooled(pool, len + 1); CopyMem(&(str[1]), buf, len); buf[len] = 0; return buf; }
/* C implementation of AllocVecPooled (see autodoc exec/AllocPooled) */ APTR Alloc_VecPooled( APTR poolHeader, ULONG memSize ) { ULONG newSize = memSize + sizeof ( ULONG ); ULONG *mem = AllocPooled( poolHeader, newSize ); if ( !mem ) return NULL; *mem = newSize; return mem + 1; }
static BSTR mkbstr(APTR pool, CONST_STRPTR str) { UBYTE *buf; UBYTE len; len = strlen(str) & 0xff; buf = AllocPooled(pool, len + 1); CopyMem(str, &(buf[1]), len); buf[0] = len; return (BSTR) MKBADDR(buf); }
APTR allocVecPooled(APTR pool,ULONG size) { ULONG *mem; ENTER(); size += sizeof(ULONG); if((mem = AllocPooled(pool, size))) *mem++ = size; RETURN(mem); return mem; }
int main() { struct timeval tv_start, tv_end; int count = 100000000; double elapsed = 0.0; int i; APTR pool; APTR memory; pool = CreatePool(MEMF_ANY, 4 * 100, 100); AllocPooled(pool, 100); // Avoid bad behaviour of FreePooled() gettimeofday(&tv_start, NULL); for(i = 0; i < count; i++) { memory = AllocPooled(pool, 100); if (memory) FreePooled(pool, memory, 100); } gettimeofday(&tv_end, NULL); DeletePool(pool); elapsed = ((double)(((tv_end.tv_sec * 1000000) + tv_end.tv_usec) - ((tv_start.tv_sec * 1000000) + tv_start.tv_usec)))/1000000.; printf ( "Elapsed time: %f seconds\n" "Number of allocations: %d\n" "Allocations per second: %f\n" "Seconds per allocation: %f\n", elapsed, count, (double) count / elapsed, (double) elapsed / count ); return 0; }
struct testnode *newnode() { struct testnode *node = AllocPooled(mempool, sizeof(struct testnode)); if (node == NULL) { fprintf(stdout, "AllocPooled failed\n"); fflush(stdout); DeletePool(mempool); free(shuffle); exit(EXIT_FAILURE); } return node; }
void* operator new(size_t sz) { size_t *p; // malloc(0) is unpredictable, avoid it if (!sz) sz = 1; // allocate shareable public memory if (!(p = (size_t *)AllocPooled(MemPool, sz + sizeof(size_t)))) Alert(AT_DeadEnd|AN_Unknown|AG_NoMemory); *p++ = sz; return p; }
APTR MyAllocPooled(APTR pool, ULONG length) { ULONG *mem; ENTER(); length += sizeof(ULONG); if((mem = AllocPooled(pool, length))) { *mem = length; mem += 1; } RETURN(mem); return(mem); }
/* * Create a string copy (mempool version). */ LPTSTR CopyStringPool( POOL pMemPool, LPCTSTR pszString ) { LPTSTR pszCopy; /* * Allocate copy. */ size_t len = REAL_SIZE( _tcslen( pszString ) + 1 ); if (( pszCopy = AllocPooled( pMemPool, len )) != NULL ) /* * Copy the string. */ _tcscpy_s( pszCopy, len, pszString ); return pszCopy; }
// TetiSoft: C implementation of AllocVecPooled (see autodoc exec/AllocPooled) APTR AllocVecPooled( APTR poolHeader, ULONG memSize ) { ULONG newSize = memSize + sizeof ( ULONG ); #ifdef __GNUC__ ULONG *mem = AllocPooled( poolHeader, newSize ); #else ULONG *mem = AsmAllocPooled( poolHeader, newSize, SysBase ); #endif if ( !mem ) return NULL; *mem = newSize; return mem + 1; }
PINT SetString(struct Handler *handler, TEXT **field, const TEXT *new_str) { LONG error = 0; UPINT size; TEXT *str_copy = NULL, *old_str; PINT block_diff = 0; /* Allocate new string */ size = StrSize(new_str); if(size > 1) { str_copy = AllocPooled(handler->muddy_pool, size); if(str_copy != NULL) { CopyMem(new_str, str_copy, size); } else error = ERROR_DISK_FULL; } else size = 0; if(error == 0) { /* Deallocate old string */ if(size > 0) block_diff = MEMBLOCKS(size); old_str = *field; if(old_str != NULL) { size = StrSize(old_str); FreePooled(handler->muddy_pool, old_str, size); block_diff -= MEMBLOCKS(size); } /* Store new string */ *field = str_copy; } /* Store error and return difference in block utilisation */ SetIoErr(error); return block_diff; }
static struct ph_packet *packet_alloc(void) { APTR pool; struct ph_packet *pkt; pool = CreatePool(MEMF_PUBLIC | MEMF_CLEAR, 1024, 256); if (pool == NULL) { SetIoErr(ERROR_NO_FREE_STORE); return NULL; } pkt = AllocPooled(pool, sizeof(struct ph_packet)); pkt->dp.dp_Link = (struct Message *) pkt; pkt->msg.mn_Node.ln_Name = (char *) &(pkt->dp); pkt->pool = pool; return pkt; }
APTR PM_AllocVecPooled(LONG size) { #if defined(__AROS__) || defined(__MORPHOS__) ULONG *p; // To Do: Add Semaphore protection to the pool!!! // stegerg: MOS and AROS have MEMF_SEM_PROTECTED. See pminit.c size += sizeof(ULONG); p = AllocPooled(MemPool, size); if(p) { *p++ = size; return (APTR)p; } return NULL; #else return AllocVec(size, MEMF_CLEAR); #endif }
BOOL NamesToList ( Object *list, struct TagItem *tags, struct AboutWindow_DATA *data ) { const struct TagItem *tstate = tags; struct TagItem *tag = NULL; BOOL success = TRUE; IPTR section = SID_NONE; CONST_STRPTR sectionName = NULL; BOOL sectionFirst = TRUE; STRPTR name; STRPTR buffer; ULONG length = 0; if (tags == NULL) return FALSE; while ((tag = NextTagItem(&tstate)) != NULL && success == TRUE) { switch (tag->ti_Tag) { case SECTION_ID: section = tag->ti_Data; sectionName = Section2Name(data->awd_Catalog, section); if (sectionName != NULL) { sectionFirst ? sectionFirst = FALSE : DoMethod(list, MUIM_List_InsertSingle, (IPTR) ""); length = strlen(MUIX_B) + strlen(sectionName) + 1; buffer = AllocPooled(data->awd_Pool, length); if (buffer != NULL) { buffer[0] = '\0'; strcat(buffer, MUIX_B); strcat(buffer, sectionName); DoMethod ( list, MUIM_List_InsertSingle, (IPTR) buffer, MUIV_List_Insert_Bottom ); } else { success = FALSE; break; } } break; case NAME_STRING: name = (STRPTR) tag->ti_Data; length = strlen(name) + 1; if (sectionName != NULL) length += 4; buffer = AllocPooled(data->awd_Pool, length); if (buffer != NULL) { buffer[0] = '\0'; if (sectionName != NULL) strcat(buffer, " "); strcat(buffer, name); DoMethod ( list, MUIM_List_InsertSingle, (IPTR) buffer, MUIV_List_Insert_Bottom ); } else { success = FALSE; break; } break; } } return success; }
/* * Obtain the hyperlink located at the * mouse position. If there is no hyperlink * at the mouse position return NULL. */ TCHAR *GetHyperlink( LPCLASSDATA lpcd ) { POINT ptStart, ptEnd, ptMousePos; /* * Are we parsing hyperlinks? */ if ( Parser->bParseHyperLinks ) { /* * Get mouse position and convert * to client coordinates. */ GetCursorPos( &ptMousePos ); ScreenToClient( lpcd->hWnd, &ptMousePos ); /* * Skip selection margin. */ ptMousePos.x -= ( GetMarginWidth( lpcd ) + GetLineMarginWidth( lpcd )); /* * Convert the coordinates to the character * position. */ if ( MouseToCaret( lpcd, ptMousePos.x, ptMousePos.y, &ptMousePos )) { /* * Check if the character is located inside * a hyperlink. */ if ( CheckForHyperlink( lpcd, &ptMousePos, &ptStart, &ptEnd, FALSE )) { /* * Allocate memory to store the * hyperlink text. */ TCHAR *pszUrl = AllocPooled( lpcd->pMemPool, REAL_SIZE( ptEnd.x - ptStart.x + 2 )); if ( pszUrl ) { /* * Copy the hyperlink text into the * allocated buffer. */ LPLINE lpLine = ( LPLINE )ArrayGetAt( lpcd->lpLines, ptStart.y ); memcpy( pszUrl, &lpLine->pcText[ ptStart.x ], ptEnd.x - ptStart.x + 1 ); /* * 0-terminate to be on the safe side. */ pszUrl[ ptEnd.x - ptStart.x + 1 ] = 0; return pszUrl; } } } } /* * No hyperlink or memory failure... */ return NULL; }
IPTR Ascii__DTM_ASYNCLAYOUT(Class *cl, Object *o, struct gpLayout *gpl) { struct DTSpecialInfo *si = (struct DTSpecialInfo *) G (o)->SpecialInfo; struct AsciiData *data = INST_DATA (cl, o); ULONG visible = 0, total = 0; struct RastPort trp; ULONG hunit = 1; ULONG bsig = 0; /* Switches */ BOOL linefeed = FALSE; BOOL newseg = FALSE; BOOL abort = FALSE; /* Attributes obtained from super-class */ struct TextAttr *tattr; struct TextFont *font; struct List *linelist; struct IBox *domain; IPTR wrap = FALSE; IPTR bufferlen; STRPTR buffer; STRPTR title; /* Line information */ ULONG num, offset, swidth; ULONG anchor = 0, newanchor; ULONG style = FS_NORMAL; struct Line *line; ULONG yoffset = 0; ULONG linelength, max_linelength = 0; UBYTE fgpen = 1; UBYTE bgpen = 0; ULONG tabspace; ULONG numtabs; ULONG i; ULONG nomwidth, nomheight; D(bug("AsciiDataType_AsyncLayout\n")); /* Get all the attributes that we are going to need for a successful layout */ if (GetDTAttrs (o, DTA_TextAttr , (IPTR) &tattr , DTA_TextFont , (IPTR) &font , DTA_Domain , (IPTR) &domain , DTA_ObjName , (IPTR) &title , TDTA_Buffer , (IPTR) &buffer , TDTA_BufferLen , (IPTR) &bufferlen , TDTA_LineList , (IPTR) &linelist , TDTA_WordWrap , (IPTR) &wrap , TAG_DONE) == 8) { D(bug("AsciiDataType_AsyncLayout: Got all attrs\n")); /* Lock the global object data so that nobody else can manipulate it */ ObtainSemaphore (&(si->si_Lock)); /* Make sure we have a buffer */ if (buffer) { D(bug("AsciiDataType_AsyncLayout: Got buffer\n")); /* Initialize the temporary RastPort */ InitRastPort (&trp); SetFont (&trp, font); D(bug("AsciiDataType_AsyncLayout: Temp RastPort initialized\n")); /* Calculate the nominal size */ nomheight = (ULONG) (24 * font->tf_YSize); nomwidth = (ULONG) (80 * font->tf_XSize); /* Calculate the tab space */ tabspace = font->tf_XSize * 8; /* We only need to perform layout if we are doing word wrap, or this * is the initial layout call */ D(bug("AsciiDataType_AsyncLayout: Checking if layout is needed\n")); if (wrap || gpl->gpl_Initial) { D(bug("AsciiDataType_AsyncLayout: Layout IS needed. Freeing old LineList\n")); /* Delete the old line list */ while ((line = (struct Line *) RemHead (linelist))) FreePooled (data->Pool, line, sizeof (struct Line)); D(bug("AsciiDataType_AsyncLayout. Old LineList freed\n")); /* Step through the text buffer */ for (i = offset = num = numtabs = 0; (i < bufferlen) && (bsig == 0) && !abort; i++) { /* Convert DOS and Mac line endings */ if (buffer[i] == '\r') { if (buffer[i + 1] == '\n') i++; else buffer[i] = '\n'; } /* Check for end of line */ if (buffer[i] == '\n') { newseg = linefeed = TRUE; newanchor = i + 1; } /* Check for end of page */ else if (buffer[i] == 12) { newseg = linefeed = TRUE; newanchor = i + 1; } /* Check for tab */ else if (buffer[i] == '\t') { /* See if we need to terminate a line segment */ if ((numtabs == 0) && num) { newseg = TRUE; } numtabs++; } else { /* See if we have any TABs that we need to finish out */ if (numtabs) { offset += (((offset / tabspace) + 1) * tabspace) - offset; num = numtabs = 0; anchor = i; } /* Compute the width of the line. */ swidth = TextLength(&trp, &buffer[anchor], num + 1); num++; } if (i == bufferlen - 1) newseg = TRUE; /* Time for a new text segment yet? */ if (newseg) { /* Allocate a new line segment from our memory pool */ if ((line = AllocPooled(data->Pool, sizeof(struct Line)))) { swidth = TextLength(&trp, &buffer[anchor], num); line->ln_Text = &buffer[anchor]; line->ln_TextLen = num; line->ln_XOffset = offset; line->ln_YOffset = yoffset + font->tf_Baseline; line->ln_Width = swidth; line->ln_Height = font->tf_YSize; line->ln_Flags = (linefeed) ? LNF_LF : 0; line->ln_FgPen = fgpen; line->ln_BgPen = bgpen; line->ln_Style = style; line->ln_Data = NULL; linelength = line->ln_Width + line->ln_XOffset; if (linelength > max_linelength) { max_linelength = linelength; } /* Add the line to the list */ AddTail(linelist, (struct Node *) line); /* Increment the line count */ if (linefeed) { yoffset += font->tf_YSize; offset = 0; total++; } else { /* Increment the offset */ offset += swidth; } } else { abort = TRUE; } /* Clear the variables */ newseg = linefeed = FALSE; anchor = newanchor; num = 0; /* Check to see if layout has been aborted */ bsig = CheckSignal (SIGBREAKF_CTRL_C); } /* if (newseg) */ } /* * check for last line */ D(bug("AsciiDataType_AsyncLayout: end textloop, anchor %ld\n",anchor)); #if 0 if (buffer[anchor]) { linefeed=TRUE; D(bug("AsciiDataType_AsyncLayout: add last line <%s>\n", &buffer[anchor])); /* Allocate a new line segment from our memory pool */ if ((line = AllocPooled(data->Pool, sizeof(struct Line)))) { swidth = TextLength(&trp, &buffer[anchor], num); line->ln_Text = &buffer[anchor]; line->ln_TextLen = num; line->ln_XOffset = offset; line->ln_YOffset = yoffset + font->tf_Baseline; line->ln_Width = swidth; line->ln_Height = font->tf_YSize; line->ln_Flags = (linefeed) ? LNF_LF : 0; line->ln_FgPen = fgpen; line->ln_BgPen = bgpen; line->ln_Style = style; line->ln_Data = NULL; linelength = line->ln_Width + line->ln_XOffset; if (linelength > max_linelength) { max_linelength = linelength; } /* Add the line to the list */ AddTail(linelist, (struct Node *) line); /* Increment the line count */ if (linefeed) { yoffset += font->tf_YSize; offset = 0; total++; } else { /* Increment the offset */ offset += swidth; } } else { abort = TRUE; } } #endif } /* if (wrap || gpl->gpl_Initial) */ else { /* No layout to perform */ total = si->si_TotVert; max_linelength = si->si_TotHoriz * si->si_HorizUnit; } DeinitRastPort(&trp); } /* if (buffer) */ /* Compute the lines and columns type information */ si->si_VertUnit = font->tf_YSize; si->si_VisVert = visible = domain->Height / si->si_VertUnit; si->si_TotVert = total; /* si->si_HorizUnit = hunit = 1; si->si_VisHoriz = (LONG) domain->Width / hunit; si->si_TotHoriz = domain->Width;*/ si->si_HorizUnit = hunit = font->tf_XSize; si->si_VisHoriz = domain->Width / hunit; si->si_TotHoriz = max_linelength / hunit; /* Release the global data lock */ ReleaseSemaphore (&si->si_Lock); /* Were we aborted? */ if (bsig == 0) { /* Not aborted, so tell the world of our newest attributes */ NotifyAttrChanges (o, gpl->gpl_GInfo, 0, GA_ID , G(o)->GadgetID, DTA_VisibleVert , visible , DTA_TotalVert , total , DTA_NominalVert , nomheight , DTA_VertUnit , font->tf_YSize , /* DTA_TopVert , si->si_TopVert , */ DTA_VisibleHoriz , (domain->Width / hunit) , DTA_TotalHoriz , max_linelength / hunit , DTA_NominalHoriz , nomwidth , DTA_HorizUnit , hunit , DTA_TopHoriz , si->si_TopHoriz , DTA_Title , (IPTR)title , DTA_Busy , FALSE , DTA_Sync , TRUE , TAG_DONE); } /* if (bsig == 0) */ } /* if GetDTAttrs(... */ D(bug("AsciiDataType_AsyncLayout: Done. Returning %d\n", total)); return (IPTR)total; }
struct MenuItem * MakeMenuList(struct MinList *list, APTR parent, UBYTE type, ULONG id, struct MenuItem *next) { struct MenuItem *first = NULL, *item, *old = NULL; struct Node *ln; LONG count = 0; if (!parent || !list) return NULL; foreach (list, ln) { if (ln->ln_Name && (item = AllocPooled(pool, sizeof(struct SpecialMenuItem)))) { if (!first) first = item; else old->NextItem = item; if ((item->ItemFill = AllocPooled(pool, sizeof(struct IntuiText))) != 0) { // Find entries with the same name bool equalEntries = false; struct Node *node; foreach (list, node) { if (node != ln && !zstrcmp(node->ln_Name, ln->ln_Name)) { equalEntries = true; break; } } if (equalEntries) { // if there is already an item with the same name, add path // informations so that the items can be differentiated better char t[256], path[25]; { char *pathSource; if (id == SMIM_SESSION) pathSource = ((struct Session *)ln)->s_Path; else pathSource = ((struct Mappe *)ln)->mp_Path; if (pathSource != NULL) stccpy(path, pathSource, sizeof(path)); else path[0] = '\0'; } if (strlen(path) > sizeof(path) - 2) strcpy(path + sizeof(path) - 4, "..."); sprintf(t, "%s (%s)", ln->ln_Name, path); ((struct IntuiText *)item->ItemFill)->IText = AllocString(t); } else ((struct IntuiText *)item->ItemFill)->IText = AllocString(ln->ln_Name); ((struct IntuiText *)item->ItemFill)->TopEdge = 1; item->Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP; ((struct SpecialMenuItem *)item)->smi_Magic = id; ((struct SpecialMenuItem *)item)->smi_Data = count; } old = item; } count++; if (id == SMIM_SESSION && count >= numsessions) break; }