Пример #1
0
static __inline__
void addLineInfo ( SegInfo* si,
                   Int      fnmoff,
                   Addr     start,
                   Addr     end,
                   UInt     lineno )
{
   RiLoc loc;
   UInt size = end - start + 1;
#  if 0
   if (size > 10000)
   VG_(printf)( "line %4d: %p .. %p, in %s\n",
                lineno, start, end, 
                &si->strtab[fnmoff] );
#  endif
   /* Sanity ... */
   if (size > 10000) return;

   if (start >= si->start+si->size 
       || end < si->start) return;

   loc.addr      = start;
   loc.size      = (UShort)size;
   loc.lineno    = lineno;
   loc.fnmoff    = fnmoff;
   addLoc ( si, &loc );
}
Пример #2
0
int main()
{
    char menu = ' ';
    int locationsLength = 0;
    int locationIndex = 0;
    printf("This program will a store the name, description, and long/lat coordinates of locations.\n");
    printf("Enter the amount of locations.\n");
    scanf("%d", &locationsLength);
    location *LocationArray = malloc(locationsLength * sizeof(location));
    //test to make sure malloc worked
    if(LocationArray == NULL){
        printf("Heap memory is exhausted.");
        exit(1);
    }

    while(1){
    printf("\nType A to add an additional location.\n");
    printf("Type P to print the current list of locations.\n");
    printf("Type Q to quit the program.\n");
    scanf(" %c", &menu);
    switch (menu) {
        case 'A':
        case 'a':
            if(locationIndex == locationsLength)
                ResizeArray(LocationArray, &locationsLength);
            addLoc(LocationArray, locationIndex);
            locationIndex++;
            break;
        case 'P':
        case 'p':
            printLoc(LocationArray, locationIndex);
            break;
        case 'Q':
        case 'q':
            printf("Exiting Program.\n");
            exit(1);
            break;
        default:
            printf("Choice is invalid. Try Again.\n");
            break;
            }
        }
    return 0;
}