int main() { system("clear"); for(int i=0;i<2;i++){ map_init(&gScreenBuffer[i]); map_new(&gScreenBuffer[i],35,16); } map_init(&gAlienModel); map_load(&gAlienModel,"alien.dat"); map_init(&gPlasmaModel); map_load(&gPlasmaModel,"plasma.dat"); map_init(&gAlienModel); map_load(&gAlienModel,"alien.dat"); double TablePosition[] = {0,6.0}; for(int i=0;i<2;i++) { _S_ALIEN_OBJECT *pObj = &gAlienObjects[i]; alien_init(pObj,&gAlienModel); pObj->m_fXpos = 0;: pObj->m_fYpos = 2; pObj->m_nFSM = 1; }
int main() { _S_MAP_OBJECT screenBuf; map_init(&screenBuf); map_new(&screenBuf,16,16); map_PutTile(&screenBuf,6,5,4); map_PutTile(&screenBuf,5,5,4); map_PutTile(&screenBuf,4,5,4); map_PutTile(&screenBuf,6,6,4); map_PutTile(&screenBuf,5,6,4); map_PutTile(&screenBuf,4,6,4); map_PutTile(&screenBuf,6,7,4); map_PutTile(&screenBuf,5,7,4); map_PutTile(&screenBuf,4,7,4); _S_MAP_OBJECT humanObj; map_init(&humanObj); map_load(&humanObj,"human.dat"); puts("\r\n-------------------------"); map_drawTile_trn(&humanObj,5,5,&screenBuf); map_dump(&screenBuf,Default_Tilepalete); //map_dump(&carObj,Tilepalette); //map_dump(&screenBuffer,Tilepalette); return 0; }
int main() { system("clear"); for(int i=0;i<2;i++) { map_init(&gScreenBuf[i]); map_new(&gScreenBuf[i],35,16); } map_init(&gPlayer); map_load(&gPlayer,"plane1.dat"); Plane_init(&gPlayerObject,&gPlayer,17,10); set_conio_terminal_mode(); acc_tick = last_tick = 0; while(bLoop) { //타이밍처리 clock_gettime(CLOCK_MONOTONIC,&work_timer); double cur_tick = work_timer.tv_sec + (double)(work_timer.tv_nsec * 1e-9); double delta_tick = cur_tick - last_tick; last_tick = cur_tick; //실시간입력 if(kbhit() != 0) { char ch = getch(); if(ch == 'q') { bLoop = 0; puts("bye~\r"); } //gPlayerObject.fpApply(&gPlayerObject,delta_tick,ch); gPlayerObject.fpApply(&gPlayerObject,delta_tick,ch); } //타이밍계산 acc_tick += delta_tick; if(acc_tick > 0.1) { //puts("tick...\r"); gotoxy(0,0); map_drawTile(&gScreenBuf[0],0,0,&gScreenBuf[1]); gPlayerObject.fpDraw(&gPlayerObject,&gScreenBuf[1]); //Plane_Draw(&gPlayerObject,&gScreenBuf[1]); map_dump(&gScreenBuf[1],Default_Tilepalete); acc_tick = 0; } } return 0; }
void parse_init(void) { expr_init(); scanner_init(); chunkpool_init(s->atom_pool, sizeof(struct atom)); chunkpool_init(s->vec_pool, sizeof(struct vec)); map_init(s->sym_table); named_buffer_init(s->named_buffer); map_init(s->initial_symbols); named_buffer_init(s->initial_named_buffer); }
int main(void) { _S_MAP_OBJECT test_map; _S_MAP_OBJECT test_map2; map_init(&test_map); map_init(&test_map2); map_new(&test_map, 8, 8); map_dump(&test_map); map_new(&test_map2, 4, 4); map_dump(&test_map2); return 0; }
int main(int argc, char** argv) { printf("before if"); if(argc < 2) { printf("zero arg"); map_init ("./map"); } else { printf("non zero"); map_init(argv[1]); } return (EXIT_SUCCESS); }
value_t map_remove(struct map* m, key_t k) { struct map* curr = m; struct map* prev = NULL; struct map* temp = m; value_t ret = NULL; while (curr != NULL) { if (curr->key != k) { prev = curr; curr = curr->next; } else { if (curr->next != NULL) temp = curr->next; if (prev != NULL) prev->next = temp; if (curr != m) { ret = curr->value; free (curr); curr = temp; } else map_init(m); } } return ret; }
int main(int argc, char **argv) { FILE * fp = NULL; token_t token = {0}; map = map_init(); init_lexical(map); switch(argc) { case 2: fp = fopen(argv[1], "r"); break; default: print_help(); goto exit; } while (token_scanner(fp, &token) != R_END) { switch(token.type) { case T_INTEGER: printf("%d %d\n", token.value.Int, token.type); break; case T_DOUBLE: break; default: printf("%s %d\n", token.value.String, token.type); } } exit: return 0; }
void map_remove_if(struct map* m, bool (*cond)(key_t k, value_t v, int aux), int aux) { struct map* curr = m; struct map* prev = NULL; struct map* temp = m; while (curr != NULL) { if (!cond(curr->key, curr->value, aux)) { prev = curr; curr = curr->next; } else { if (curr->next != NULL) temp = curr->next; if (prev != NULL) prev->next = temp; if (curr != m) { free (curr); curr = temp; } else map_init(m); } } }
//跑1代实验(多线程) void lab_run_more(PLAB_THREAD_PARAM_GROUP tpg) { //逐个在N个地图上跑实验 for(int m=0;m<gConfig.lab_more_count;m++) { //随机生成地图 map_init(tpg->map); //DEBUG("map %d: %s", m+1, tpg->map); //在该地图上分线程跑这批机器人 if(tpg->params != NULL) { //WRITE("main set ready"); gLabThreadsRunningCount = tpg->num; for(int i=1;i<=tpg->num;i++) { SetEvent(gLabThreadsEvents[i]); } } if(tpg->rem_param != NULL) //主线程处理多余的部分 { lab_run_more_thread(tpg->rem_param); } if(tpg->params != NULL) { //主线程等待各线程执行结束 //WRITE("main wait: %ld", gLabThreadsRunningCount); WaitForSingleObject(gLabThreadsEvents[0], INFINITE); //WRITE("main wait ok: %ld", gLabThreadsRunningCount); } } }
/** * * rct2: 0x0068E8DA */ void title_load() { if (RCT2_GLOBAL(0x009DEA6E, uint8) & 1) RCT2_CALLPROC_X(0x00667C15, 0, 1, 0, 0, 0, 0, 0); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TITLE_DEMO; reset_park_entrances(); reset_saved_strings(); RCT2_CALLPROC_EBPSAFE(0x0069EB13); ride_init_all(); window_guest_list_init_vars_a(); RCT2_CALLPROC_EBPSAFE(0x006BD3A4); map_init(); park_init(); date_reset(); RCT2_CALLPROC_X(0x006C45ED, 0, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); window_new_ride_init_vars(); window_guest_list_init_vars_b(); window_staff_init_vars(); RCT2_CALLPROC_EBPSAFE(0x0068AFFD); RCT2_CALLPROC_EBPSAFE(0x0069EBE4); viewport_init_all(); news_item_init_queue(); title_create_windows(); title_init_showcase(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, uint16) = 0; }
int main() { _S_MAP_OBJECT ScreenBuf; map_init(&ScreenBuf); map_new(&ScreenBuf,35,17); system("clear"); gotoxy(0,0); double angle=0; for(int i=0;i<35;i++){ angle=(double)i*(180/35); //printf("%f\r\n",sin((i/180)*PI)); double my=sin((angle/180)*PI)*8.0; map_PutTile(&ScreenBuf,i,8+my,1); my=cos((angle/180)*PI)*8; map_PutTile(&ScreenBuf,i,8+my,2); } map_dump(&ScreenBuf,Default_Tilepalete); return 0; }
static void init_streams_for_device (struct ptx_device *ptx_dev, int concurrency) { int i; struct ptx_stream *null_stream = GOMP_PLUGIN_malloc (sizeof (struct ptx_stream)); null_stream->stream = NULL; null_stream->host_thread = pthread_self (); null_stream->multithreaded = true; null_stream->d = (CUdeviceptr) NULL; null_stream->h = NULL; map_init (null_stream); ptx_dev->null_stream = null_stream; ptx_dev->active_streams = NULL; pthread_mutex_init (&ptx_dev->stream_lock, NULL); if (concurrency < 1) concurrency = 1; /* This is just a guess -- make space for as many async streams as the current device is capable of concurrently executing. This can grow later as necessary. No streams are created yet. */ ptx_dev->async_streams.arr = GOMP_PLUGIN_malloc (concurrency * sizeof (struct ptx_stream *)); ptx_dev->async_streams.size = concurrency; for (i = 0; i < concurrency; i++) ptx_dev->async_streams.arr[i] = NULL; }
void map_editor_push(state_stack* stack, void *udata) { (void) udata; state_desc editor = { GAME_MAP_EDITOR, nullptr, nullptr, nullptr, &map_editor_input, nullptr, &map_editor_render, &map_editor_destroy, nullptr, nullptr, false, }; map_editor *mapEditor = (map_editor*) malloc(sizeof(map_editor)); map_init(); mapEditor->m_bDragMap = false; mapEditor->m_iActiveTile = 2; mapEditor->m_iMapEditorState = MAPEDITOR_EDIT; mapEditor->m_cMapWalk = WALK_NONE; mapEditor->m_bGrid = false; for (int i = 0; i < IN_MAX; i++) { if (g_keybinds[i].m_type == IN_NONE) { break; } mapEditor->m_savedKeybinds[i] = g_keybinds[i]; } input_load_defaults(); // TODO: Stuff the map into the map editor properly. editor.m_pData = mapEditor; table_append(stack, &editor); }
void create_init(void) { uint8_t *j, *e; udata.u_top = PROGLOAD + 512; /* Plenty for the boot */ init_process = ptab_alloc(); udata.u_ptab = init_process; init_process->p_top = udata.u_top; map_init(); /* wipe file table */ e = udata.u_files + UFTSIZE; for (j = udata.u_files; j < e; ++j) *j = NO_FILE; makeproc(init_process, &udata); init_process->p_status = P_RUNNING; udata.u_insys = 1; init_process->p_status = P_RUNNING; /* Poke the execve arguments into user data space so _execve() can read them back */ /* Some systems only have a tiny window we can use at boot as most of this space is loaded with common memory */ argptr = PROGLOAD; progptr = PROGLOAD + 256; uzero((void *)progptr, 32); add_argument("/init"); }
int main() { //printf("Some random hashes:\n"); //printf("\tBazinga: %d\n", map_hash_key("Bazinga")); //printf("\tFlabagoobie: %d\n", map_hash_key("Flabagoobie")); //printf("\tScooby: %d\n", map_hash_key("Scooby")); //printf("\tMcDooby: %d\n", map_hash_key("McDooby")); //printf("\tagnizaB: %d\n", map_hash_key("agnizaB")); Map map; map_init(&map); map_set(&map, "bazinga", "bazonga"); map_set(&map, "zabinga", "zabonga"); map_set(&map, "zabniga", "maponya"); map_set(&map, "kabanooga", "daboogawoofa"); MapItem *item; print_map(&map); map_get(&map, "abzinga"); printf("================================\n"); print_map(&map); map_free(&map); }
int main() { map m; int items_number = 10; int total_items_number = 10; char *unknown, *unknown_substring; //~const char *keys[] = {"aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj"}; //~const char *values[] = {"foo", "bar", "toto", "tata", "something", "10", "truc", "3.14", "moi", "vous"}; const char *keys[] = {"ddd", "aaa", "ggg", "ccc", "eee", "fff", "bbb", "jjj", "iii", "hhh"}; const char *values[] = {"foo", "bar", "toto", "tata", "something", "10", "truc", "3.14", "moi", "vous"}; map_init(&m, total_items_number); int i; for (i = 0; i < items_number; i++) { map_add_entry(keys[i], (char *) values[i], &m); printf("map_get_entry access: key: %s, value %s\n", keys[i], (char *) map_get_entry(keys[i], &m)); } // try to add an element in a full map if (map_add_entry("11th", (char *) "unwanted value", &m) == MAP_FULL) { printf("Map full while trying to insert %s\n", "11th"); } // try to get an unexisting element unknown = (char *) map_get_entry("uuu", &m); if (unknown != NULL) { printf("%s\n", unknown); } else { printf("'uuu' is not in the map\n"); } printf("before, for the key 'ddd', the value was '%s'\n", (char *) map_get_entry("ddd", &m)); map_add_entry("ddd", (char *) "new ddd", &m); printf("and after, for the key 'ddd', the value is '%s'\n", (char *) map_get_entry("ddd", &m)); map_delete_entry("aaa", &m); unknown = (char *) map_get_entry("aaa", &m); if (unknown != NULL) { printf("\"aaa\" is still in the map\n"); } else { printf("'aaa' is not in the map\n"); } // e is the beginning of the key eee unknown_substring = (char *) map_get_entry("e", &m); if (unknown_substring != NULL) { printf("\"e\" is in the map\n"); } else { printf("e' is not in the map\n"); } map_free(&m); return 0; }
void create_init(void) { uint8_t *j; /* userspace: 0x100+ 0 1 2 3 4 5 6 7 8 9 A B C */ const char arg[] = { '/', 'i', 'n', 'i', 't', 0, 0, 1, 1, 0, 0, 0, 0 }; init_process = ptab_alloc(); udata.u_ptab = init_process; udata.u_top = 4096; /* Plenty for the boot */ map_init(); newproc(init_process); init_process->p_status = P_RUNNING; /* wipe file table */ for (j = udata.u_files; j < (udata.u_files + UFTSIZE); ++j) { *j = NO_FILE; } /* Poke the execve arguments into user data space so _execve() can read them back */ uput(arg, PROGBASE, sizeof(arg)); /* Set up things to look like the process is calling _execve() */ udata.u_argn = (uint16_t) PROGBASE; /* FIXME - should be relative to PROGBASE... */ udata.u_argn1 = 0x107; /* Arguments (just "/init") */ udata.u_argn2 = 0x10b; /* Environment (none) */ }
void map_init_copy(map_t* pt_mapdest, const map_t* cpt_mapsrc) { assert(pt_mapdest != NULL && cpt_mapsrc != NULL); assert( pt_mapdest->_t_pair._t_firsttypesize == cpt_mapsrc->_t_pair._t_firsttypesize && pt_mapdest->_t_pair._t_secondtypesize == cpt_mapsrc->_t_pair._t_secondtypesize); assert( strncmp( pt_mapdest->_t_pair._sz_firsttypename, cpt_mapsrc->_t_pair._sz_firsttypename, _ELEM_TYPE_NAME_SIZE) == 0 && strncmp( pt_mapdest->_t_pair._sz_secondtypename, cpt_mapsrc->_t_pair._sz_secondtypename, _ELEM_TYPE_NAME_SIZE) == 0); /* initialize dest map with src map attribute */ map_init(pt_mapdest); /* insert all element from src to dest */ if(!map_empty(cpt_mapsrc)) { map_insert_range(pt_mapdest, map_begin(cpt_mapsrc), map_end(cpt_mapsrc)); } }
int main() { { struct map map; map_init(&map); char key1[] = "This is a really long key.", key2[] = "Another key."; assertError("map_set (1)", map_set(&map, key1, sizeof key1, (void*)123)); assertEq("Key is now retrievable", map_get(&map, key1, sizeof key1), (void*)123); assertError("map_set (2)", map_set(&map, key2, sizeof key2, (void*)456)); assertEq("New key is now retrievable", map_get(&map, key2, sizeof key2), (void*)456); assertEq("Old key is still retrievable (1)", map_get(&map, key1, sizeof key1), (void*)123); assertError("map_set existing", map_set(&map, key1, sizeof key1, (void*)789)); assertEq("Key has updated value", map_get(&map, key1, sizeof key1), (void*)789); assertEq("Old key is still retrievable (2)", map_get(&map, key2, sizeof key2), (void*)456); assertError("map_set small key (1)", map_set(&map, (void*)1, 0, (void*)10)); assertError("map_set small key (2)", map_set(&map, (void*)2, 0, (void*)20)); assertEq("Can retrieve short key (1)", map_get(&map, (void*)1, 0), (void*)10); assertEq("Can retrieve short key (2)", map_get(&map, (void*)2, 0), (void*)20); map_free(&map); } }
void create_init(void) { uint8_t *j; init_process = ptab_alloc(); udata.u_ptab = init_process; udata.u_top = PROGLOAD + 4096; /* Plenty for the boot */ init_process->p_top = udata.u_top; map_init(); newproc(init_process); udata.u_insys = 1; init_process->p_status = P_RUNNING; /* wipe file table */ for (j = udata.u_files; j < (udata.u_files + UFTSIZE); ++j) { *j = NO_FILE; } /* Poke the execve arguments into user data space so _execve() can read them back */ argptr = PROGLOAD; progptr = PROGLOAD + 2048; uzero((void *)progptr, 32); add_argument("/init"); }
/** * * rct2: 0x0068E8DA */ void title_load() { if (RCT2_GLOBAL(0x009DEA6E, uint8) & 1) RCT2_CALLPROC_X(0x00667C15, 0, 1, 0, 0, 0, 0, 0);//Game pause toggle RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TITLE_DEMO; reset_park_entrances(); user_string_clear_all(); reset_sprite_list(); ride_init_all(); window_guest_list_init_vars_a(); sub_6BD3A4(); // RCT2_CALLPROC_EBPSAFE(0x006BD3A4); map_init(); park_init(); date_reset(); climate_reset(CLIMATE_COOL_AND_WET); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); window_new_ride_init_vars(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); map_update_tile_pointers(); //RCT2_CALLPROC_EBPSAFE(0x0068AFFD); reset_0x69EBE4();// RCT2_CALLPROC_EBPSAFE(0x0069EBE4); viewport_init_all(); news_item_init_queue(); title_create_windows(); title_init_showcase(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, uint16) = 0; }
/* **copie file to struct map in the variable mem. */ void ft_count_clone_file(map *mp, int fd, char *buf) { int count; int i; int countfind; i = 0; count = 0; countfind = 0; map_init(mp); while ((read(fd, buf, BUFFSIZE))) { if (count == 0) { mp->mem = cut_first_line_take_char(buf, mp); count = 1; } else { map_count(mp, buf); mp->mem = ft_strstr(mp->mem, buf); i++; } printf("mp.mem:%s\n", mp->mem); } if (close(fd)) mp->error = 1; ft_map_max(mp); }
/** * * rct2: 0x006729FD */ void trackmanager_load() { rct_window *mainWindow; object_unload_all(); map_init(); set_all_land_owned(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); reset_park_entrances(); reset_saved_strings(); reset_sprite_list(); ride_init_all(); window_guest_list_init_vars_a(); sub_6BD3A4(); park_init(); finance_init(); date_reset(); window_guest_list_init_vars_b(); window_staff_list_init_vars(); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_MANAGER; RCT2_GLOBAL(0x0141F570, uint8) = 0; window_new_ride_init_vars(); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); mainWindow->flags &= ~WF_SCROLLING_TO_LOCATION; RCT2_CALLPROC_EBPSAFE(0x006837E3); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; rct2_endupdate(); }
/* * map_strategy: * open always succeeds, I/O always fails, other functions * perform their function */ int mapstrategy(RP rp) { switch (rp->rp_cmd) { case CMDInit: return map_init(rp); case CMDClose: return map_close(rp); case CMDOpen: return map_open(); case CMDShutdown: return map_shutdown(); case CMDGenIOCTL: return map_ioctl(rp); case CMDINPUT: case CMDOUTPUT: RWCNT(rp) = 0; return RPDONE; case CMDOUTPUTV: case CMDInputF: case CMDOutputF: case CMDInputS: case CMDOutputS: default: return RP_EBAD; } }
void* textures_load(char* path) { void* map = map_init(); chdir(path); DIR* dir = opendir("."); if (!dir) { fprintf(stderr, "cannot open dir: %s\n", path); return map; } struct dirent* file; while ((file = readdir(dir)) != NULL) { char* name = file->d_name; size_t length = strlen(name); if (length > 4 && strcmp(".png", &name[length - 4]) == 0) { char file_path[80]; strcat(file_path, path); texture_t* texture = malloc(sizeof(texture_t)); texture_load(texture, name); map = map_set(map, strtok(name, "."), texture); } } chdir(".."); return map; }
/** * * rct2: 0x00672957 */ void trackdesigner_load() { rct_window *mainWindow; RCT2_CALLPROC_EBPSAFE(0x006A9CE8); map_init(); set_all_land_owned(); RCT2_CALLPROC_EBPSAFE(0x006B9CB0); RCT2_CALLPROC_EBPSAFE(0x00667104); RCT2_CALLPROC_EBPSAFE(0x006C4209); RCT2_CALLPROC_EBPSAFE(0x0069EB13); ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); park_init(); RCT2_CALLPROC_EBPSAFE(0x0069DEFB); date_reset(); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TRACK_DESIGNER; RCT2_GLOBAL(0x0141F570, uint8) = 0; RCT2_CALLPROC_EBPSAFE(0x006ACA58); viewport_init_all(); news_item_init_queue(); RCT2_CALLPROC_EBPSAFE(0x0066EF38); // window_main_editor_create mainWindow = window_get_main(); window_scroll_to_location(mainWindow, 2400, 2400, 112); mainWindow->flags &= ~0x08; RCT2_CALLPROC_EBPSAFE(0x006837E3); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, sint16) = 0; rct2_endupdate(); }
/** * * rct2: 0x0068E8DA */ void title_load() { if (RCT2_GLOBAL(0x009DEA6E, uint8) & 1) RCT2_CALLPROC_X(0x00667C15, 0, 1, 0, 0, 0, 0, 0); RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) = SCREEN_FLAGS_TITLE_DEMO; RCT2_CALLPROC_EBPSAFE(0x00667104); RCT2_CALLPROC_EBPSAFE(0x006C4209); RCT2_CALLPROC_EBPSAFE(0x0069EB13); ride_init_all(); RCT2_CALLPROC_EBPSAFE(0x0068F083); // window_guest_list_init_vars_a RCT2_CALLPROC_EBPSAFE(0x006BD3A4); map_init(); park_init(); date_reset(); RCT2_CALLPROC_X(0x006C45ED, 0, 0, 0, 0, 0, 0, 0); RCT2_CALLPROC_EBPSAFE(0x006DFEE4); RCT2_CALLPROC_EBPSAFE(0x006ACA58); RCT2_CALLPROC_EBPSAFE(0x0068F050); // window_guest_list_init_vars_b RCT2_CALLPROC_EBPSAFE(0x006BD39C); RCT2_CALLPROC_EBPSAFE(0x0068AFFD); RCT2_CALLPROC_EBPSAFE(0x0069EBE4); viewport_init_all(); news_item_init_queue(); title_create_windows(); title_init_showcase(); gfx_invalidate_screen(); RCT2_GLOBAL(0x009DEA66, uint16) = 0; }
static int Map_init(Map *self, PyObject *args, PyObject *kwds) { int size_pixels; double size_meters; PyObject * py_bytes = NULL; static char * argnames[] = {"size_pixels", "size_meters", "bytes", NULL}; if(!PyArg_ParseTupleAndKeywords(args, kwds,"id|O", argnames, &size_pixels, &size_meters, &py_bytes)) { return error_on_raise_argument_exception("Map"); } map_init(&self->map, size_pixels, size_meters); if (py_bytes && !bad_mapbytes(py_bytes, size_pixels, "__init__")) { map_set(&self->map, PyByteArray_AsString(py_bytes)); } return 0; }
map_s *elf_set_breakpoints(proc_s *proc) { elf_info_s *elf = elf_symbols(proc->fd); map_s *brkp = map_init(32, cmp_addr); for (size_t i = 0; i < elf->replt_count; ++i) { void *ret; GElf_Rel rel; GElf_Rela rela; const char *name; GElf_Sym sym; GElf_Addr addr; /* local relocation entries */ if (elf->replt->d_type == ELF_T_REL) { ret = gelf_getrel(elf->replt, i, &rel); rela.r_offset = rel.r_offset; rela.r_info = rel.r_info; rela.r_addend = 0; } /* external relocation entries */ else ret = gelf_getrela(elf->replt, i, &rela); gelf_getsym(elf->dynsym, ELF64_R_SYM(rela.r_info), &sym); name = elf->dynstr + sym.st_name; addr = elf->plt_addr + (i + 1) * 16; breakpoint_create(brkp, addr, name, proc->pid); } return brkp; }