Mercurial > hg > Members > kono > Cerium
view TaskManager/kernel/ppe/SymTable.cc @ 20:31a7ff27ee20
*** empty log message ***
author | gongo |
---|---|
date | Sun, 10 Feb 2008 13:46:26 +0900 |
parents | 41ccd4b38184 |
children | 3e331f7576a1 |
line wrap: on
line source
#include <string.h> #include "SymTable.h" SymTable::~SymTable(void) { SymTbPtr tb; for (int i = 0; i < symtb_index; i++) { tb = &symtb[i]; delete [] tb->sym; } delete [] symtb; } void SymTable::init(void) { symtb = new SymTb[SYM_MAX_SIZE]; symtb_index = 0; } void SymTable::set_symbol(const char *sym, void *addr) { SymTbPtr tb = &symtb[symtb_index++]; tb->sym = new char[strlen(sym)+1]; memcpy(tb->sym, sym, strlen(sym)+1); tb->address = addr; } void* SymTable::get_address(int fd) { if (fd >= symtb_index) { // Fix me // error process } return symtb[fd].address; } int SymTable::get_fd(const char *sym) { SymTbPtr tb; for (int i = 0; i < SYM_MAX_SIZE; i++) { tb = &symtb[i]; if (strcmp(tb->sym, sym) == 0) { return i; } } return -1; }