コード例 #1
0
ファイル: ldrdf.c プロジェクト: aosm/nasm
/*
 * add_library()
 *
 * checks that a library can be opened and is in the correct format,
 * then adds it to the linked list of libraries.
 */
void add_library(const char *name)
{
    if (rdl_verify(name)) {
        rdl_perror("ldrdf", name);
        errorcount++;
        return;
    }
    if (!libraries) {
        lastlib = libraries = malloc(sizeof(*libraries));
        if (!libraries) {
            fprintf(stderr, "ldrdf: out of memory\n");
            exit(1);
        }
    } else {
        lastlib->next = malloc(sizeof(*libraries));
        if (!lastlib->next) {
            fprintf(stderr, "ldrdf: out of memory\n");
            exit(1);
        }
        lastlib = lastlib->next;
    }
    lastlib->next = NULL;
    if (rdl_open(lastlib, name)) {
        rdl_perror("ldrdf", name);
        errorcount++;
        return;
    }
}
コード例 #2
0
int rdl_open(struct librarynode *lib, const char *name)
{
    int i = rdl_verify(name);
    if (i)
        return i;

    lib->fp = NULL;
    lib->name = nasm_strdup(name);
    lib->referenced = 0;
    lib->next = NULL;
    return 0;
}