- Timestamp:
- Mar 18, 2003, 4:58:49 AM (22 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 4 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.emx.mak
r33 r35 3 3 4 4 CC = gcc 5 CFLAGS = - I. -I./include -I../kLib/Generic/include \5 CFLAGS = -g -I. -I./include -I../kLib/Generic/include \ 6 6 # -DUSE_KLIB \ 7 -DOS2 -D__i386__ -D__32BIT__ -D MACHINE=\"ibmos2\" -DMACHINE_ARCH=\"x86\" -DMACHINE_CPU=\"386\" \7 -DOS2 -D__i386__ -D__32BIT__ -DNMAKE -DMACHINE=\"ibmos2\" -DMACHINE_ARCH=\"x86\" -DMACHINE_CPU=\"386\" \ 8 8 9 9 OBJDIR=obj.emx … … 54 54 $(OBJDIR)\var.o\ 55 55 $(OBJDIR)\util.o\ 56 $(OBJDIR)\helpers.o\ 56 57 57 58 INCOBJS=\ … … 62 63 63 64 kmk.exe: $(BASEOBJS) $(LSTOBJS) $(INCOBJS) 64 $(CC) $(CFLAGS) $** -o $@ -lregexp65 $(CC) $(CFLAGS) -Zmap $** -o $@ -lregex 65 66 66 67 $(LSTOBJS): lst.lib\$(@B).c list.h lst.h -
trunk/src/kmk/Makefile.icc.mak
r34 r35 3 3 4 4 CC = icc 5 CFLAGS = /Q 6 -DUSE_KLIB -DOS2 -D__i386__ -D__32BIT__ -D MACHINE=\"ibmos2\" -DMACHINE_ARCH=\"x86\" -DMACHINE_CPU=\"386\" \5 CFLAGS = /Q /Ti+ /Ss+ /Ge+ /I. /I./include /I../kLib/Generic/include \ 6 -DUSE_KLIB -DOS2 -D__i386__ -D__32BIT__ -DNMAKE=1 -DMACHINE=\"ibmos2\" -DMACHINE_ARCH=\"x86\" -DMACHINE_CPU=\"386\" \ 7 7 8 8 OBJDIR=obj.icc … … 39 39 $(OBJDIR)\arch.obj\ 40 40 $(OBJDIR)\buf.obj\ 41 #$(OBJDIR)\compat.obj\41 $(OBJDIR)\compat.obj\ 42 42 $(OBJDIR)\cond.obj\ 43 43 $(OBJDIR)\dir.obj\ 44 44 $(OBJDIR)\for.obj\ 45 45 $(OBJDIR)\hash.obj\ 46 #$(OBJDIR)\job.obj\46 $(OBJDIR)\job.obj\ 47 47 $(OBJDIR)\main.obj\ 48 48 $(OBJDIR)\make.obj\ … … 53 53 $(OBJDIR)\var.obj\ 54 54 $(OBJDIR)\util.obj\ 55 $(OBJDIR)\helpers.obj\ 55 56 56 57 INCOBJS=\ … … 61 62 62 63 kmk.exe: $(BASEOBJS) $(LSTOBJS) $(INCOBJS) 63 $(CC) $(CFLAGS) $** /Fm$(@F).map /Fe$@ 64 $(CC) @<< 65 $(CFLAGS) $** /Fm$(@F).map /Fe$@ ..\klib\lib\debug\klib.lib 66 << 64 67 65 68 $(LSTOBJS): lst.lib\$(@B).c list.h lst.h -
trunk/src/kmk/arch.c
r27 r35 162 162 entry != NULL; 163 163 entry = Hash_EnumNext(&search)) 164 free((Address) Hash_GetValue (entry));165 166 free(a->name);164 efree((Address) Hash_GetValue (entry)); 165 166 efree(a->name); 167 167 efree(a->fnametab); 168 168 Hash_DeleteTable(&a->members); 169 free((Address) a);169 efree((Address) a); 170 170 } 171 171 … … 226 226 227 227 if (freeIt) { 228 free(result);228 efree(result); 229 229 } 230 230 cp += length-1; … … 268 268 269 269 if (freeIt) { 270 free(result);270 efree(result); 271 271 } 272 272 cp += length; … … 334 334 335 335 if (gn == NILGNODE) { 336 free(buf);336 efree(buf); 337 337 return(FAILURE); 338 338 } else { … … 342 342 } else if (Arch_ParseArchive(&sacrifice, nodeLst, ctxt)!=SUCCESS) { 343 343 /* 344 * Error in nested call -- free buffer and return FAILURE344 * Error in nested call -- efree buffer and return FAILURE 345 345 * ourselves. 346 346 */ 347 free(buf);347 efree(buf); 348 348 return(FAILURE); 349 349 } … … 351 351 * Free buffer and continue with our work. 352 352 */ 353 free(buf);353 efree(buf); 354 354 } else if (Dir_HasWildcards(memName)) { 355 355 Lst members = Lst_Init(FALSE); … … 367 367 368 368 snprintf(nameBuf, sz, "%s(%s)", libName, member); 369 free(member);369 efree(member); 370 370 gn = Targ_FindNode (nameBuf, TARG_CREATE); 371 371 if (gn == NILGNODE) { 372 free(nameBuf);372 efree(nameBuf); 373 373 return (FAILURE); 374 374 } else { … … 385 385 } 386 386 Lst_Destroy(members, NOFREE); 387 free(nameBuf);387 efree(nameBuf); 388 388 } else { 389 389 size_t sz = strlen(libName) + strlen(memName) + 3; … … 391 391 snprintf(nameBuf, sz, "%s(%s)", libName, memName); 392 392 gn = Targ_FindNode (nameBuf, TARG_CREATE); 393 free(nameBuf);393 efree(nameBuf); 394 394 if (gn == NILGNODE) { 395 395 return (FAILURE); … … 407 407 } 408 408 if (doSubst) { 409 free(memName);409 efree(memName); 410 410 } 411 411 … … 414 414 415 415 /* 416 * If substituted libName, free it now, since we need it no longer.416 * If substituted libName, efree it now, since we need it no longer. 417 417 */ 418 418 if (subLibName) { 419 free(libName);419 efree(libName); 420 420 } 421 421 … … 668 668 Hash_DeleteTable (&ar->members); 669 669 efree(ar->fnametab); 670 free ((Address)ar);670 efree ((Address)ar); 671 671 return (NULL); 672 672 } … … 1129 1129 gn->path = Dir_FindFile (libName, path); 1130 1130 1131 free (libName);1131 efree (libName); 1132 1132 1133 1133 #ifdef LIBRARIES -
trunk/src/kmk/buf.c
r25 r35 188 188 bp->outPtr = newBuf + BUF_UNGET_INC; 189 189 bp->inPtr = bp->outPtr + numBytes; 190 free ((char *)bp->buffer);190 efree ((char *)bp->buffer); 191 191 bp->buffer = newBuf; 192 192 bp->size += BUF_UNGET_INC; … … 232 232 bp->outPtr = newBuf + newBytes; 233 233 bp->inPtr = bp->outPtr + curNumBytes; 234 free ((char *)bp->buffer);234 efree ((char *)bp->buffer); 235 235 bp->buffer = newBuf; 236 236 bp->size += newBytes; … … 446 446 447 447 if (freeData) { 448 free ((char *)buf->buffer);449 } 450 free ((char *)buf);448 efree ((char *)buf->buffer); 449 } 450 efree ((char *)buf); 451 451 } 452 452 -
trunk/src/kmk/compat.c
r27 r35 66 66 #include <sys/wait.h> 67 67 #endif 68 #if defined(__EMX__) 69 #include <sys/process.h> 70 #endif 71 #if defined(OS2) && defined(__IBMC__) 72 #include <process.h> 73 #endif 68 74 #include <ctype.h> 69 75 #include <errno.h> … … 134 140 135 141 } 142 #if !(defined(OS2) && defined(__IBMC__)) 136 143 if (signo == SIGQUIT) 137 144 exit(signo); 145 #endif 138 146 (void) signal(signo, SIG_DFL); 139 147 (void) kill(getpid(), signo); … … 228 236 229 237 if (*cmdStart == '\0') { 230 free(cmdStart);238 efree(cmdStart); 231 239 Error("%s expands to empty string", cmd); 232 240 return(0); … … 329 337 * Fork and execute the single command. If the fork fails, we abort. 330 338 */ 339 #ifdef OS2 //@todo use klib later! 340 cpid = _spawnvp(P_NOWAIT, av[0], av); 341 #else 331 342 cpid = vfork(); 332 343 if (cpid < 0) { … … 345 356 exit(1); 346 357 } 358 #endif 347 359 348 360 /* 349 361 * we need to print out the command associated with this Gnode in 350 362 * Targ_PrintCmd from Targ_PrintGraph when debugging at level g2, 351 * in main(), Fatal() and DieHorribly(), therefore do not free it363 * in main(), Fatal() and DieHorribly(), therefore do not efree it 352 364 * when debugging. 353 365 */ 354 366 if (!DEBUG(GRAPH2)) { 355 free(cmdStart);367 efree(cmdStart); 356 368 Lst_Replace (cmdNode, cmdp); 357 369 } … … 664 676 signal(SIGTERM, CompatInterrupt); 665 677 } 678 #if !(defined(OS2) && defined(__IBMC__)) 666 679 if (signal(SIGHUP, SIG_IGN) != SIG_IGN) { 667 680 signal(SIGHUP, CompatInterrupt); 668 681 } 682 #endif 683 #if !(defined(OS2) && defined(__IBMC__)) 669 684 if (signal(SIGQUIT, SIG_IGN) != SIG_IGN) { 670 685 signal(SIGQUIT, CompatInterrupt); 671 686 } 687 #endif 672 688 673 689 for (cp = "#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) { -
trunk/src/kmk/cond.c
r25 r35 236 236 Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); 237 237 if (doFree) { 238 free(cp2);238 efree(cp2); 239 239 } 240 240 cp += len; … … 383 383 if (path != (char *)NULL) { 384 384 result = TRUE; 385 free(path);385 efree(path); 386 386 } else { 387 387 result = FALSE; … … 529 529 t = EndOfFile; 530 530 break; 531 532 #ifdef NMAKE 533 case '[': 534 //@todo execute this command!!! 535 t = False; 536 condExpr += strlen(condExpr); 537 break; 538 #endif 539 540 541 #ifdef NMAKE 542 case '"': 543 #endif 531 544 case '$': { 532 545 char *lhs; … … 535 548 int varSpecLen; 536 549 Boolean doFree; 550 #ifdef NMAKE 551 Boolean fQuoted = (*condExpr == '"'); 552 if (fQuoted) 553 condExpr++; 554 #endif 537 555 538 556 /* … … 542 560 t = Err; 543 561 lhs = Var_Parse(condExpr, VAR_CMD, doEval,&varSpecLen,&doFree); 562 #ifdef NMAKE 563 if (lhs == var_Error) 564 { 565 //@todo check if actually parsed correctly. 566 doFree = 0; 567 } 568 #else 544 569 if (lhs == var_Error) { 545 570 /* … … 549 574 return(Err); 550 575 } 576 #endif 551 577 condExpr += varSpecLen; 552 578 579 #ifdef NMAKE 580 if ( (fQuoted && *condExpr != '"') 581 || (!fQuoted && !isspace((unsigned char) *condExpr) && strchr("!=><", *condExpr) == NULL) 582 ) 583 #else 553 584 if (!isspace((unsigned char) *condExpr) && 554 strchr("!=><", *condExpr) == NULL) { 585 strchr("!=><", *condExpr) == NULL) 586 #endif 587 { 555 588 Buffer buf; 556 589 char *cp; … … 562 595 563 596 if (doFree) 564 free(lhs); 565 566 for (;*condExpr && !isspace((unsigned char) *condExpr); 567 condExpr++) 597 efree(lhs); 598 599 #ifdef NMAKE 600 for (;*condExpr && (fQuoted ? *condExpr != '"' : !isspace((unsigned char) *condExpr)); condExpr++) 601 #else 602 for (;*condExpr && !isspace((unsigned char) *condExpr); condExpr++) 603 #endif 568 604 Buf_AddByte(buf, (Byte)*condExpr); 569 605 … … 578 614 * Skip whitespace to get to the operator 579 615 */ 616 #ifdef NMAKE 617 if (fQuoted && *condExpr == '"') 618 condExpr++; 619 #endif 580 620 while (isspace((unsigned char) *condExpr)) 581 621 condExpr++; … … 653 693 Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); 654 694 if (freeIt) { 655 free(cp2);695 efree(cp2); 656 696 } 657 697 cp += len - 1; … … 682 722 t = strcmp(lhs, string) ? True : False; 683 723 } 684 free(string);724 efree(string); 685 725 if (rhs == condExpr) { 686 726 if (!qt && *cp == ')') … … 709 749 if (*CondCvtArg(string, &right) != '\0') { 710 750 if (freeIt) 711 free(string);751 efree(string); 712 752 goto do_string_compare; 713 753 } 714 754 if (freeIt) 715 free(string);755 efree(string); 716 756 if (rhs == condExpr) 717 757 condExpr += len; … … 771 811 error: 772 812 if (doFree) 773 free(lhs);813 efree(lhs); 774 814 break; 775 815 } … … 851 891 } 852 892 if (doFree) { 853 free(val);893 efree(val); 854 894 } 855 895 /* … … 898 938 (invert ? False : True) : 899 939 (invert ? True : False)); 900 free(arg);940 efree(arg); 901 941 break; 902 942 } -
trunk/src/kmk/dir.c
r25 r35 469 469 } else { 470 470 next: 471 free(file);471 efree(file); 472 472 } 473 473 start = cp+1; … … 653 653 * Results: 654 654 * The path to the file or NULL. This path is guaranteed to be in a 655 * different part of memory than name and so may be safely free'd.655 * different part of memory than name and so may be safely efree'd. 656 656 * 657 657 * Side Effects: … … 678 678 struct stat stb; /* Buffer for stat, if necessary */ 679 679 Hash_Entry *entry; /* Entry for mtimes table */ 680 681 #ifdef NMAKE 682 cp = name; 683 while ((cp = strchr(cp, '\\')) != 0) 684 *cp = '/'; 685 #endif 680 686 681 687 /* … … 863 869 return (file); 864 870 } else { 865 free (file);871 efree (file); 866 872 } 867 873 } … … 1000 1006 if (gn->type & OP_MEMBER) { 1001 1007 if (fullName != gn->path) 1002 free(fullName);1008 efree(fullName); 1003 1009 return Arch_MemMTime (gn); 1004 1010 } else { … … 1187 1193 1188 1194 Hash_DeleteTable (&p->files); 1189 free((Address)p->name);1190 free((Address)p);1195 efree((Address)p->name); 1196 efree((Address)p); 1191 1197 } 1192 1198 } -
trunk/src/kmk/for.c
r25 r35 201 201 else 202 202 Buf_Destroy(buf, TRUE); 203 free((Address) sub);203 efree((Address) sub); 204 204 205 205 forBuf = Buf_Init(0); … … 301 301 Lst_ForEach(arg.lst, ForExec, (ClientData) &arg); 302 302 303 free((Address)arg.var);304 Lst_Destroy(arg.lst, (void (*) __P((ClientData))) free);303 efree((Address)arg.var); 304 Lst_Destroy(arg.lst, (void (*) __P((ClientData))) efree); 305 305 Buf_Destroy(arg.buf, TRUE); 306 306 } -
trunk/src/kmk/hash.c
r25 r35 144 144 for (h = *hp++; h != NULL; h = nexth) { 145 145 nexth = h->next; 146 free((char *)h);146 efree((char *)h); 147 147 } 148 148 } 149 free((char *)t->bucketPtr);149 efree((char *)t->bucketPtr); 150 150 151 151 /* … … 266 266 * Hash_DeleteEntry -- 267 267 * 268 * Delete the given hash table entry and free memory associated with268 * Delete the given hash table entry and efree memory associated with 269 269 * it. 270 270 * … … 291 291 if (p == e) { 292 292 *hp = p->next; 293 free((char *)p);293 efree((char *)p); 294 294 t->numEntries--; 295 295 return; … … 420 420 } 421 421 } 422 free((char *)oldhp);423 } 422 efree((char *)oldhp); 423 } -
trunk/src/kmk/job.c
r34 r35 990 990 job->node->made = MADE; 991 991 Make_Update(job->node); 992 free((Address)job);992 efree((Address)job); 993 993 } else if (*status != 0) { 994 994 errors += 1; 995 free((Address)job);995 efree((Address)job); 996 996 } 997 997 … … 1240 1240 #endif /* RMT_NO_EXEC */ 1241 1241 1242 #ifdef __EMX__ 1243 if ((cpid = fork()) == -1) { 1244 #else 1242 1245 if ((cpid = vfork()) == -1) { 1246 #endif 1243 1247 Punt("Cannot fork"); 1244 1248 } else if (cpid == 0) { … … 1879 1883 Make_Update(job->node); 1880 1884 } 1881 free((Address)job);1885 efree((Address)job); 1882 1886 return(JOB_FINISHED); 1883 1887 } else { 1884 free((Address)job);1888 efree((Address)job); 1885 1889 return(JOB_ERROR); 1886 1890 } … … 2148 2152 * There's still more in that thar buffer. This time, though, 2149 2153 * we know there's no newline at the end, so we add one of 2150 * our own free will.2154 * our own efree will. 2151 2155 */ 2152 2156 if (*cp != '\0') { … … 2211 2215 * There's still more in that thar buffer. This time, though, 2212 2216 * we know there's no newline at the end, so we add one of 2213 * our own free will.2217 * our own efree will. 2214 2218 */ 2215 2219 (void) fprintf(stdout, "%s", cp); … … 2783 2787 2784 2788 /* 2785 * Do not free up the words themselves, since they might be in use by the2789 * Do not efree up the words themselves, since they might be in use by the 2786 2790 * shell specification... 2787 2791 */ 2788 free(words);2792 efree(words); 2789 2793 return SUCCESS; 2790 2794 } -
trunk/src/kmk/lst.lib/lstConcat.c
r25 r35 45 45 * Function to concatentate two lists. 46 46 */ 47 48 47 #include "lstInt.h" 49 48 … … 119 118 list1->lastPtr->nextPtr = list1->firstPtr; 120 119 } 121 free ((Address)l2);120 efree ((Address)l2); 122 121 } else if (list2->firstPtr != NilListNode) { 123 122 /* -
trunk/src/kmk/lst.lib/lstDestroy.c
r25 r35 45 45 * Nuke a list and all its resources 46 46 */ 47 48 47 #include "lstInt.h" 49 48 … … 84 83 list->lastPtr->nextPtr = NilListNode; 85 84 else { 86 free ((Address)l);85 efree ((Address)l); 87 86 return; 88 87 } … … 92 91 tln = ln->nextPtr; 93 92 (*freeProc) (ln->datum); 94 free ((Address)ln);93 efree ((Address)ln); 95 94 } 96 95 } else { 97 96 for (ln = list->firstPtr; ln != NilListNode; ln = tln) { 98 97 tln = ln->nextPtr; 99 free ((Address)ln);98 efree ((Address)ln); 100 99 } 101 100 } 102 101 103 free ((Address)l);102 efree ((Address)l); 104 103 } -
trunk/src/kmk/lst.lib/lstForEachFrom.c
r25 r35 106 106 107 107 if (tln->flags & LN_DELETED) { 108 free((char *)tln);108 efree((char *)tln); 109 109 } 110 110 tln = next; -
trunk/src/kmk/main.c
r34 r35 322 322 } 323 323 case 'E': 324 p = malloc(strlen(optarg) + 1); 325 if (!p) 326 Punt("make: cannot allocate memory."); 324 p = emalloc(strlen(optarg) + 1); 327 325 (void)strcpy(p, optarg); 328 326 (void)Lst_AtEnd(envFirstVars, (ClientData)p); … … 845 843 #ifdef POSIX 846 844 #ifdef USE_KLIB 847 kEnvSet("MAKEFLAGS", p );845 kEnvSet("MAKEFLAGS", p, TRUE); 848 846 #else 849 847 setenv("MAKEFLAGS", p, 1); … … 851 849 #else 852 850 #ifdef USE_KLIB 853 kEnvSet("MAKE", p );851 kEnvSet("MAKE", p, TRUE); 854 852 #else 855 853 setenv("MAKE", p, 1); … … 887 885 path = cp + 1; 888 886 } while (savec == ':'); 889 (void) free((Address)vpath);887 (void)efree((Address)vpath); 890 888 } 891 889 … … 908 906 char *value; 909 907 if (expandVars) { 910 p1 = malloc(strlen((char *)Lst_Datum(ln)) + 1 + 3); 911 if (!p1) 912 Punt("make: cannot allocate memory."); 908 p1 = emalloc(strlen((char *)Lst_Datum(ln)) + 1 + 3); 913 909 /* This sprintf is safe, because of the malloc above */ 914 910 (void)sprintf(p1, "${%s}", (char *)Lst_Datum(ln)); … … 920 916 printf("%s\n", value ? value : ""); 921 917 if (p1) 922 free(p1);918 efree(p1); 923 919 } 924 920 } … … 961 957 Lst_Destroy(variables, NOFREE); 962 958 Lst_Destroy(makefiles, NOFREE); 963 Lst_Destroy(create, (void (*) __P((ClientData))) free);959 Lst_Destroy(create, (void (*) __P((ClientData))) efree); 964 960 965 961 /* print the graph now it's been processed if the user requested it */ … … 1093 1089 * Fork 1094 1090 */ 1091 #ifdef __EMX__ 1092 switch (cpid = fork()) { 1093 #else 1095 1094 switch (cpid = vfork()) { 1095 #endif 1096 1096 case 0: 1097 1097 /* … … 1108 1108 (void) close(fds[1]); 1109 1109 1110 #ifdef OS2 1111 { 1112 const char *psz = getenv("COMSPEC"); 1113 if (!psz) 1114 psz = getenv("OS2_SHELL"); 1115 if (!psz) 1116 psz = "c:\\os2\\cmd.exe"; 1117 (void) execv(psz, args); 1118 } 1119 #else 1110 1120 (void) execv("/bin/sh", args); 1121 #endif 1111 1122 _exit(1); 1112 1123 /*NOTREACHED*/ … … 1378 1389 1379 1390 /* 1391 * efree -- 1392 * efree, no change. 1393 */ 1394 void 1395 efree(ptr) 1396 void *ptr; 1397 { 1398 if (ptr) 1399 free(ptr); 1400 } 1401 1402 /* 1380 1403 * enomem -- 1381 1404 * die when out of memory. … … 1397 1420 struct stat st; 1398 1421 1422 #ifdef __EMX__ 1423 if (stat(file, &st) == -1) 1424 #else 1399 1425 if (lstat(file, &st) == -1) 1426 #endif 1400 1427 return -1; 1401 1428 -
trunk/src/kmk/nonints.h
r25 r35 74 74 char *estrdup __P((const char *)); 75 75 void *emalloc __P((size_t)); 76 /* efree(x) works when x==NULL. STDC behavior, may need some different 77 * definition for cross-builds on deficient systems */ 78 #define efree free 76 void efree __P((void *)); 79 77 void *erealloc __P((void *, size_t)); 80 78 void enomem __P((void)); -
trunk/src/kmk/parse.c
r30 r35 252 252 static void ParseUnreadc __P((int)); 253 253 static void ParseHasCommands __P((ClientData)); 254 static void ParseDoInclude __P((char * ));254 static void ParseDoInclude __P((char *, char)); 255 255 static void ParseDoError __P((char *)); 256 256 #ifdef SYSVINCLUDE … … 540 540 * If we have noted the existence of a .MAIN, it means we need 541 541 * to add the sources of said target to the list of things 542 * to create. The string 'src' is likely to be free, so we542 * to create. The string 'src' is likely to be efree, so we 543 543 * must make a new copy of it. Note that this will only be 544 544 * invoked if the user didn't specify a target on the command … … 765 765 766 766 if (freeIt) { 767 free(result);767 efree(result); 768 768 } 769 769 cp += length-1; … … 1454 1454 1455 1455 Var_Set(line, cp, ctxt); 1456 free(cp);1456 efree(cp); 1457 1457 } else if (type == VAR_SHELL) { 1458 1458 Boolean freeCmd = FALSE; /* TRUE if the command needs to be freed, i.e. … … 1472 1472 res = Cmd_Exec(cp, &err); 1473 1473 Var_Set(line, res, ctxt); 1474 free(res);1474 efree(res); 1475 1475 1476 1476 if (err) … … 1478 1478 1479 1479 if (freeCmd) 1480 free(cp);1480 efree(cp); 1481 1481 } else { 1482 1482 /* … … 1605 1605 */ 1606 1606 static void 1607 ParseDoInclude (file )1607 ParseDoInclude (file, chPre) 1608 1608 char *file; /* file specification */ 1609 char chPre; /* Preprocessor char */ 1609 1610 { 1610 1611 char *fullname; /* full pathname of file */ … … 1621 1622 } 1622 1623 1624 #ifndef NMAKE 1623 1625 if ((*file != '"') && (*file != '<')) { 1624 1626 Parse_Error (PARSE_FATAL, 1625 " .include filename must be delimited by '\"' or '<'");1627 "%cinclude filename must be delimited by '\"' or '<'", chPre); 1626 1628 return; 1627 1629 } 1630 #endif 1628 1631 1629 1632 /* … … 1637 1640 } else { 1638 1641 isSystem = FALSE; 1642 #ifdef NMAKE 1643 if (*file == '"') 1644 endc = '"'; 1645 else 1646 { 1647 endc = '\0'; 1648 file--; 1649 } 1650 #else 1639 1651 endc = '"'; 1652 #endif 1640 1653 } 1641 1654 … … 1647 1660 } 1648 1661 1662 #ifdef NMAKE 1663 if (endc && *cp != endc) { 1664 #else 1649 1665 if (*cp != endc) { 1666 #endif 1650 1667 Parse_Error (PARSE_FATAL, 1651 1668 "Unclosed %cinclude filename. '%c' expected", 1652 '.', endc);1669 chPre, endc); 1653 1670 return; 1654 1671 } … … 1692 1709 fullname = Dir_FindFile(newName, dirSearchPath); 1693 1710 } 1694 free (newName);1711 efree (newName); 1695 1712 *prefEnd = '/'; 1696 1713 } else { 1697 1714 fullname = (char *)NULL; 1698 1715 } 1699 free (Fname);1716 efree (Fname); 1700 1717 } else { 1701 1718 fullname = (char *)NULL; … … 1725 1742 if (fullname == (char *) NULL) { 1726 1743 *cp = endc; 1727 Parse_Error (PARSE_FATAL, "Could not find %s", file);1744 Parse_Error (PARSE_FATAL, "Could not find '%s'", file); 1728 1745 return; 1729 1746 } 1730 1747 1731 free(file);1748 efree(file); 1732 1749 1733 1750 /* … … 1882 1899 fullname = Dir_FindFile(newName, dirSearchPath); 1883 1900 } 1884 free (newName);1901 efree (newName); 1885 1902 *prefEnd = '/'; 1886 1903 } else { … … 1977 1994 1978 1995 ifile = (IFile *) Lst_DeQueue (includes); 1979 free ((Address) fname);1996 efree ((Address) fname); 1980 1997 fname = ifile->fname; 1981 1998 lineno = ifile->lineno; … … 1983 2000 (void) fclose (curFILE); 1984 2001 if (curPTR) { 1985 free((Address) curPTR->str);1986 free((Address) curPTR);2002 efree((Address) curPTR->str); 2003 efree((Address) curPTR); 1987 2004 } 1988 2005 curFILE = ifile->F; 1989 2006 curPTR = ifile->p; 1990 free ((Address)ifile);2007 efree ((Address)ifile); 1991 2008 return (CONTINUE); 1992 2009 } … … 2083 2100 Buf_AddByte(buf, (Byte)'\0'); 2084 2101 line = (char *)Buf_GetAll(buf, &lineLength); 2102 #ifdef NMAKE 2103 } while (skip == 1 && line[0] != '.' && line[0] != '!'); 2104 #else 2085 2105 } while (skip == 1 && line[0] != '.'); 2106 #endif 2086 2107 2087 2108 Buf_Destroy(buf, FALSE); … … 2328 2349 */ 2329 2350 do { 2330 free (line);2351 efree (line); 2331 2352 line = ParseSkipLine(1); 2332 2353 } while (line && Cond_Eval(line) != COND_PARSE); … … 2335 2356 /*FALLTHRU*/ 2336 2357 case COND_PARSE: 2337 free ((Address) line);2358 efree ((Address) line); 2338 2359 line = ParseReadLine(); 2339 2360 break; … … 2341 2362 if (For_Eval(line)) { 2342 2363 int ok; 2343 free(line);2364 efree(line); 2344 2365 do { 2345 2366 /* … … 2353 2374 } 2354 2375 ok = For_Eval(line); 2355 free(line);2376 efree(line); 2356 2377 } 2357 2378 while (ok); … … 2430 2451 while ((line = ParseReadLine ()) != NULL) { 2431 2452 //debugkso: fprintf(stderr, "%s(%d): inLine=%d line=%s\n", fname, lineno, inLine, line); 2453 #ifdef NMAKE 2454 if (*line == '.' || *line == '!') { 2455 #else 2432 2456 if (*line == '.') { 2457 #endif 2433 2458 /* 2434 2459 * Lines that begin with the special character are either … … 2439 2464 } 2440 2465 if (strncmp (cp, "include", 7) == 0) { 2441 ParseDoInclude (cp + 7 );2466 ParseDoInclude (cp + 7, *line); 2442 2467 goto nextLine; 2443 2468 } else if (strncmp (cp, "error", 5) == 0) { … … 2553 2578 2554 2579 cp = Var_Subst (NULL, line, VAR_CMD, TRUE); 2555 free (line);2580 efree (line); 2556 2581 line = cp; 2557 2582 … … 2573 2598 nextLine: 2574 2599 2575 free (line);2600 efree (line); 2576 2601 } 2577 2602 /* … … 2614 2639 Parse_End() 2615 2640 { 2616 Lst_Destroy(targCmds, (void (*) __P((ClientData))) free);2641 Lst_Destroy(targCmds, (void (*) __P((ClientData))) efree); 2617 2642 if (targets) 2618 2643 Lst_Destroy(targets, NOFREE); -
trunk/src/kmk/str.c
r25 r35 75 75 if (argv) { 76 76 if (argv[0]) 77 free(argv[0]);78 free((Address) argv);77 efree(argv[0]); 78 efree((Address) argv); 79 79 } 80 80 if (buffer) 81 free(buffer);81 efree(buffer); 82 82 } 83 83 … … 120 120 memcpy(result + len1, s2, len2 + 1); 121 121 122 /* free original strings */122 /* efree original strings */ 123 123 if (flags & STR_DOFREE) { 124 (void) free(s1);125 (void) free(s2);124 (void)efree(s1); 125 (void)efree(s2); 126 126 } 127 127 return(result); … … 155 155 if ((len = strlen(str) + 1) > curlen) { 156 156 if (buffer) 157 free(buffer);157 efree(buffer); 158 158 buffer = emalloc(curlen = len); 159 159 } -
trunk/src/kmk/suff.c
r25 r35 137 137 struct _Src *parent; /* The Src for which this is a source */ 138 138 GNode *node; /* The node describing the file */ 139 int children; /* Count of existing children (so we don't free139 int children; /* Count of existing children (so we don't efree 140 140 * this thing too early or never nuke it) */ 141 141 #ifdef DEBUG_SRC … … 359 359 Lst_Destroy (s->searchPath, Dir_Destroy); 360 360 361 free ((Address)s->name);362 free ((Address)s);361 efree ((Address)s->name); 362 efree ((Address)s); 363 363 } 364 364 … … 614 614 * New specification for transformation rule. Just nuke the old list 615 615 * of commands so they can be filled in again... We don't actually 616 * free the commands themselves, because a given command can be616 * efree the commands themselves, because a given command can be 617 617 * attached to several different transformations. 618 618 */ … … 905 905 906 906 Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL); 907 free(ptr);907 efree(ptr); 908 908 Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL); 909 free(ptr);909 efree(ptr); 910 910 911 911 Lst_Destroy(inIncludes, Dir_Destroy); … … 1081 1081 * 1082 1082 * Side Effects: 1083 * The memory is free'd.1083 * The memory is efree'd. 1084 1084 *---------------------------------------------------------------------- 1085 1085 */ … … 1105 1105 s = (Src *) Lst_Datum (ln); 1106 1106 if (s->children == 0) { 1107 free ((Address)s->file);1107 efree ((Address)s->file); 1108 1108 if (!s->parent) 1109 free((Address)s->pref);1109 efree((Address)s->pref); 1110 1110 else { 1111 1111 #ifdef DEBUG_SRC … … 1117 1117 } 1118 1118 #ifdef DEBUG_SRC 1119 printf(" free: [l=%x] p=%x %d\n", l, s, s->children);1119 printf("efree: [l=%x] p=%x %d\n", l, s, s->children); 1120 1120 Lst_Destroy(s->cp, NOFREE); 1121 1121 #endif 1122 1122 Lst_Remove(l, ln); 1123 free ((Address)s);1123 efree ((Address)s); 1124 1124 t |= 1; 1125 1125 Lst_Close(l); … … 1187 1187 printf("remove %x from %x\n", s, srcs); 1188 1188 #endif 1189 free(ptr);1189 efree(ptr); 1190 1190 break; 1191 1191 } … … 1268 1268 * Hot Damn! Create a new Src structure to describe 1269 1269 * this transformation (making sure to duplicate the 1270 * source node's name so Suff_FindDeps can free it1270 * source node's name so Suff_FindDeps can efree it 1271 1271 * again (ick)), and return the new structure. 1272 1272 */ … … 1401 1401 1402 1402 if (doFree) { 1403 free(junk);1403 efree(junk); 1404 1404 } 1405 1405 } else if (*cp == '\\' && *cp != '\0') { … … 1444 1444 * Free the result 1445 1445 */ 1446 free((char *)cp);1446 efree((char *)cp); 1447 1447 } 1448 1448 /* … … 1603 1603 tname = str_concat(s->name, t->name, 0); 1604 1604 ln = Lst_Find(transforms, (ClientData)tname, SuffGNHasNameP); 1605 free(tname);1605 efree(tname); 1606 1606 1607 1607 if (ln == NILLNODE) { … … 2354 2354 * 2355 2355 * Side Effects: 2356 * The memory is free'd.2356 * The memory is efree'd. 2357 2357 *---------------------------------------------------------------------- 2358 2358 */ -
trunk/src/kmk/targ.c
r25 r35 213 213 214 214 215 free(gn->name);215 efree(gn->name); 216 216 efree(gn->path); 217 217 … … 224 224 Lst_Destroy(gn->context, NOFREE); 225 225 Lst_Destroy(gn->commands, NOFREE); 226 free((Address)gn);226 efree((Address)gn); 227 227 } 228 228 -
trunk/src/kmk/util.c
r25 r35 52 52 return NULL; 53 53 len = strlen(str) + 1; 54 if ((p = malloc(len)) == NULL)54 if ((p = emalloc(len)) == NULL) 55 55 return NULL; 56 56 … … 60 60 #endif 61 61 62 #if defined(sun) || defined(__hpux) || defined(__sgi) 62 #if defined(sun) || defined(__hpux) || defined(__sgi) || defined(__EMX__) || (defined(OS2) && defined(__IBMC__)) 63 63 64 64 int … … 70 70 register char *p; 71 71 int len = strlen(name) + strlen(value) + 2; /* = \0 */ 72 char *ptr = (char*) malloc(len);72 char *ptr = (char*) emalloc(len); 73 73 74 74 (void) dum; … … 90 90 91 91 len = putenv(ptr); 92 /* free(ptr); */ 92 efree(ptr); 93 93 return len; 94 94 } -
trunk/src/kmk/var.c
r30 r35 412 412 { 413 413 Var *v = (Var *) vp; 414 free(v->name);414 efree(v->name); 415 415 Buf_Destroy(v->val, TRUE); 416 free((Address) v);416 efree((Address) v); 417 417 } 418 418 … … 505 505 if (ctxt == VAR_CMD) { 506 506 #ifdef USE_KLIB 507 kEnvSet(name, val );507 kEnvSet(name, val, TRUE); 508 508 #else 509 509 setenv(name, val, 1); … … 593 593 return(FALSE); 594 594 } else if (v->flags & VAR_FROM_ENV) { 595 free(v->name);595 efree(v->name); 596 596 Buf_Destroy(v->val, TRUE); 597 free((char *)v);597 efree((char *)v); 598 598 } 599 599 return(TRUE); … … 626 626 if (v->flags & VAR_FROM_ENV) { 627 627 Buf_Destroy(v->val, FALSE); 628 free((Address) v);628 efree((Address) v); 629 629 *frp = p; 630 630 } … … 1168 1168 regerror(err, pat, errbuf, errlen); 1169 1169 Error("%s: %s", str, errbuf); 1170 free(errbuf);1170 efree(errbuf); 1171 1171 } 1172 1172 … … 1422 1422 Buf_AddBytes(buf, strlen(cp2), (Byte *) cp2); 1423 1423 if (freeIt) 1424 free(cp2);1424 efree(cp2); 1425 1425 cp += len - 1; 1426 1426 } else { … … 1535 1535 Boolean err; /* TRUE if undefined variables are an error */ 1536 1536 int *lengthPtr; /* OUT: The length of the specification */ 1537 Boolean *freePtr; /* OUT: TRUE if caller should free result */1537 Boolean *freePtr; /* OUT: TRUE if caller should efree result */ 1538 1538 { 1539 1539 register char *tstr; /* Pointer into str */ … … 1630 1630 Buf_AddBytes(buf, strlen(rval), (Byte *) rval); 1631 1631 if (rfree) 1632 free(rval);1632 efree(rval); 1633 1633 } 1634 1634 tstr += rlen - 1; … … 1708 1708 /* 1709 1709 * Resulting string is dynamically allocated, so 1710 * tell caller to free it.1710 * tell caller to efree it. 1711 1711 */ 1712 1712 *freePtr = TRUE; … … 1936 1936 } 1937 1937 if (copy) { 1938 free(pattern);1938 efree(pattern); 1939 1939 } 1940 1940 break; … … 1990 1990 Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); 1991 1991 if (freeIt) { 1992 free(cp2);1992 efree(cp2); 1993 1993 } 1994 1994 cp += len - 1; … … 2014 2014 *lengthPtr = cp - start + 1; 2015 2015 if (*freePtr) { 2016 free(str);2016 efree(str); 2017 2017 } 2018 2018 Buf_Destroy(buf, TRUE); … … 2061 2061 cp += len - 1; 2062 2062 if (freeIt) { 2063 free(cp2);2063 efree(cp2); 2064 2064 } 2065 2065 } else if (*cp == '&') { … … 2079 2079 *lengthPtr = cp - start + 1; 2080 2080 if (*freePtr) { 2081 free(str);2081 efree(str); 2082 2082 } 2083 2083 Buf_Destroy(buf, TRUE); … … 2108 2108 * Free the two strings. 2109 2109 */ 2110 free(pattern.lhs);2111 free(pattern.rhs);2110 efree(pattern.lhs); 2111 efree(pattern.rhs); 2112 2112 break; 2113 2113 } … … 2129 2129 *lengthPtr = cp - start + 1; 2130 2130 if (*freePtr) 2131 free(str);2131 efree(str); 2132 2132 if (delim != '\0') 2133 2133 Error("Unclosed substitution for %s (%c missing)", … … 2138 2138 if ((pattern.replace = VarGetPattern(ctxt, err, &cp, 2139 2139 delim, NULL, NULL, NULL)) == NULL){ 2140 free(re);2140 efree(re); 2141 2141 2142 2142 /* was: goto cleanup */ 2143 2143 *lengthPtr = cp - start + 1; 2144 2144 if (*freePtr) 2145 free(str);2145 efree(str); 2146 2146 if (delim != '\0') 2147 2147 Error("Unclosed substitution for %s (%c missing)", … … 2165 2165 2166 2166 error = regcomp(&pattern.re, re, REG_EXTENDED); 2167 free(re);2167 efree(re); 2168 2168 if (error) { 2169 2169 *lengthPtr = cp - start + 1; 2170 2170 VarREError(error, &pattern.re, "RE substitution error"); 2171 free(pattern.replace);2171 efree(pattern.replace); 2172 2172 return (var_Error); 2173 2173 } … … 2183 2183 (ClientData) &pattern); 2184 2184 regfree(&pattern.re); 2185 free(pattern.replace);2186 free(pattern.matches);2185 efree(pattern.replace); 2186 efree(pattern.matches); 2187 2187 break; 2188 2188 } … … 2327 2327 2328 2328 if (*freePtr) { 2329 free (str);2329 efree (str); 2330 2330 } 2331 2331 str = newStr; … … 2357 2357 } else { 2358 2358 /* 2359 * Returning the value unmodified, so tell the caller to free2359 * Returning the value unmodified, so tell the caller to efree 2360 2360 * the thing. 2361 2361 */ … … 2363 2363 } 2364 2364 Buf_Destroy(v->val, destroy); 2365 free((Address)v);2365 efree((Address)v); 2366 2366 } else if (v->flags & VAR_JUNK) { 2367 2367 /* 2368 * Perform any free'ing needed and set *freePtr to FALSE so the caller2369 * doesn't try to free a static pointer.2368 * Perform any efree'ing needed and set *freePtr to FALSE so the caller 2369 * doesn't try to efree a static pointer. 2370 2370 */ 2371 2371 if (*freePtr) { 2372 free(str);2372 efree(str); 2373 2373 } 2374 2374 *freePtr = FALSE; 2375 2375 Buf_Destroy(v->val, TRUE); 2376 free((Address)v);2376 efree((Address)v); 2377 2377 if (dynamic) { 2378 2378 str = emalloc(*lengthPtr + 1); … … 2541 2541 Buf_AddBytes (buf, strlen (val), (Byte *)val); 2542 2542 if (doFree) { 2543 free ((Address)val);2543 efree ((Address)val); 2544 2544 } 2545 2545 }
Note:
See TracChangeset
for help on using the changeset viewer.