Mercurial > hg > Members > kono > Cerium
view TaskManager/kernel/ppe/SymTable.cc @ 105:3e331f7576a1
*** empty log message ***
author | gongo |
---|---|
date | Mon, 03 Mar 2008 18:55:28 +0900 |
parents | 31a7ff27ee20 |
children |
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, FuncObject 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::set_func(int id, FuncObject addr) { SymTbPtr tb = &symtb[id]; tb->address = addr; } SymTable::FuncObject 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; }