udp_send_module_handle *UdpSend_init(stream_send_cond_t *src) { if(NULL == src->ip || strlen(src->ip) > RUdpS_IP_LEN) { ERR_PRINTF("ip = [%p]", __TIME__, __func__, __LINE__, src->ip); return NULL; } udp_send_module_handle *p_udp_send_module_hand = NULL; p_udp_send_module_hand = (udp_send_module_handle *)r_malloc(sizeof(udp_send_module_handle)); if(NULL == p_udp_send_module_hand) { ERR_PRINTF("malloc error"); return NULL; } memset(p_udp_send_module_hand, 0, sizeof(udp_send_module_handle)); p_udp_send_module_hand->rtp_hand = (US_RTP_BUILD_HANDLE)UdpSend_rtp_build_init(0, 0); p_udp_send_module_hand->udp_hand.prev_video_time = 0; p_udp_send_module_hand->udp_hand.snd_video_port = src->video_port; p_udp_send_module_hand->udp_hand.snd_audio_port = src->audio_port; p_udp_send_module_hand->udp_hand.src_data = (uint8_t *)r_malloc(UdpSend_Max_Frame_Length); if(NULL == p_udp_send_module_hand->udp_hand.src_data) { ERR_PRINTF("malloc error p_udp_send_module_hand->udp_hand.src_data = [%p]", p_udp_send_module_hand->udp_hand.src_data); return NULL; } sprintf(p_udp_send_module_hand->udp_hand.snd_ip, "%s", src->ip); p_udp_send_module_hand->udp_hand.snd_fd = UdpSend_create_sock(&p_udp_send_module_hand->udp_hand); return p_udp_send_module_hand; }
int main() { #define MB 7 #define R_MALLOC_MAX 1024*1024*MB #if R_ALLOC_USE_STACK char B[R_MALLOC_MAX]; #endif #if R_ALLOC_USE_MMAP int fd = open (".mem", O_CREAT|O_RDWR, 0600); ftruncate (fd, R_MALLOC_MAX); char *B = mmap (NULL, R_MALLOC_MAX, PROT_WRITE|PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0); unlink (".mem"); close (fd); #endif //char *B = sbrk (1024*1024*MB); InitMem (B, R_MALLOC_MAX); char *a = r_malloc (1024); if (!a) { printf ("cant malloc\n"); return 1; } strcpy (a, "hello"); char *b = r_malloc (1024); strcpy (b, "world"); printf ("%s %s\n", a, b); r_free (b); r_free (a); return 0; }
rbuffer_t *r_buffer_create(unsigned long size) { rbuffer_t *buffer; buffer = (rbuffer_t *)r_malloc(sizeof(rbuffer_t)); if (!buffer) return (void*)0; r_memset(buffer, 0, sizeof(*buffer)); if (!(buffer->s = (char *)r_malloc((size + 1) * sizeof(char)))) { r_free(buffer); return (void*)0; } r_memset(buffer->s, 0, size + 1); buffer->size = size; return buffer; }
/** * Cube constructor */ Cube * cube_new(byte start_pos) { Cube *cube; cube = r_malloc(sizeof(Cube)); /* Prepare positions space. */ cube->current_position = start_pos; cube->type = CTYPE_ANGLE; cube->index = 0; cube->x = 0; cube->y = 0; cube->prev_y = -1; cube->water = 0; cube->falling = false; cube->network_integrity = 1; cube->network_size = 0; cube->network = NULL; cube->root = NULL; cube->tick = 0; cube->fade_status = 0; cube->trashed = 0; return cube; }
rex_dfasimulator_t *rex_dfasimulator_create() { rex_dfasimulator_t *si; si = (rex_dfasimulator_t*) r_malloc(sizeof(*si)); si->accepts = r_array_create(sizeof(rex_accept_t)); return si; }
rexcompiler_t *rex_compiler_create() { rexcompiler_t *co; co = (rexcompiler_t *)r_malloc(sizeof(*co)); r_memset(co, 0, sizeof(*co)); r_strncpy(co->blankchars, " \t", sizeof(co->blankchars) - 1); co->stack = r_array_create(sizeof(rexfragment_t*)); co->temptrans = r_array_create(sizeof(rex_transition_t)); return co; }
rpa_compiler_t *rpa_compiler_create() { rpa_compiler_t *co; co = (rpa_compiler_t *)r_malloc(sizeof(*co)); r_memset(co, 0, sizeof(*co)); co->cg = rvm_codegen_create(); co->scope = rvm_scope_create(); co->expressions = r_array_create(sizeof(rpa_ruledef_t)); co->ruleprefs = r_harray_create(sizeof(rpa_rulepref_t)); return co; }
Pipe * pipe_new() { Pipe *pipe; pipe = r_malloc(sizeof(Pipe)); pipe->tick = 0; pipe->status = -1; pipe->mole = NULL; return pipe; }
/** * Set the value (text) for this Text entity. If the text is currently empty * and we are trying to set another empty value, just return. */ void text_set_value(Text *text, char *value) { if (value[0] == '\0' && text->length == 0) return; text->length = strlen((char *)value); r_free(text->value); text->value = r_malloc(text->length + 1); strlcpy((char *)text->value, (char *)value, text->length + 1); text_calculate_size(text); }
void *test_busy_work(void *t) { ruint32 i; RDummy *pDummy; long tid = (long)t; printf("Thread %ld starting...\n", tid); for (i = 0; i < NUM_ITERATIONS; i++) { pDummy = (RDummy*)r_malloc(sizeof(*pDummy)); r_free(pDummy); } printf("Thread %ld done. \n", tid); pthread_exit((void*) t); }
/** 插入节点 */ int append_node(node_t **head, void *data, void *info) { node_t *temp = *head; if(NULL == *head) { *head = (node_t *)r_malloc(sizeof(node_t)); (*head)->data = data; (*head)->info = info; (*head)->next = NULL; } else { while(temp->next != NULL) { temp = temp->next; } temp->next = (node_t *)r_malloc(sizeof(node_t)); temp = temp->next; temp->data = data; temp->info = info; temp->next = NULL; } return 0; }
int rex_dfa_hash(rexdfa_t *dfa, unsigned int hbytes, unsigned int hbits) { if ((REX_DFA_HASHBITS(hbytes, hbits) - 3) > 24) return -1; if (!dfa) return -1; if (dfa->bits) r_free(dfa->bits); dfa->hbytes = hbytes; dfa->hbits = hbits; dfa->hsize = REX_DFA_HASHSIZE(hbytes, hbits) >> 3; dfa->bits = (unsigned char*)r_malloc(dfa->hsize); rex_dfa_statehash(dfa, REX_DFA_STARTSTATE, hbytes - 1, hbits, 0); return 0; }
SDL_Surface * cube_get_surface(Cube *cube) { SDL_Surface *s; SDL_Rect src; SDL_Rect *dst = NULL; int fs = cube->fade_status; /* All cubes are fixed size. Set DestRect and SourceRect. */ src.w = BSIZE; src.h = BSIZE; src.y = cube->current_position * BSIZE; src.x = (cube->type - 1) * BSIZE; s = SDL_CreateRGBSurface(0, BSIZE, BSIZE, screen->format->BitsPerPixel, 0, 0, 0, 0); SDL_FillRect(s, NULL, key); SDL_SetColorKey(s, SDL_SRCCOLORKEY|SDL_RLEACCEL, key); /* If we have a fade_status, we need to crop a smaller area. */ if (fs > 0) { dst = r_malloc(sizeof(SDL_Rect)); dst->x = dst->y = fs; dst->w = dst->h = fs * 2; src.x += fs; src.y += fs; src.w -= fs * 2; src.h -= fs * 2; } SDL_BlitSurface(sprites, &src, s, dst); /* If this cube has water, find the water mask 64px lower or 128px * if this is type 2 water (from the right side). */ if (cube->water) { src.y += BSIZE * 4 * cube->water; SDL_BlitSurface(sprites, &src, s, dst); } r_free(dst); /* Once again, if we are fading this dude, we should greyscale him */ if (fs > 0) gfx_greyscale(s); return s; }
rstr_t *rjs_file_map(const char *filename) { rstr_t *buf = NULL; char *pMappedView = NULL; HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE hMapping = 0; unsigned __int64 fileSize; DWORD sizeLo, sizeHi; buf = (rstr_t*)r_malloc(sizeof(*buf)); if (!buf) return NULL; hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, 0); if (INVALID_HANDLE_VALUE == hFile) goto error; sizeLo = GetFileSize(hFile, &sizeHi); fileSize = (UINT64)sizeLo | ((UINT64)sizeHi << 32); hMapping = CreateFileMapping(hFile, 0, PAGE_READONLY, sizeHi, sizeLo, 0); if (!hMapping) goto error; pMappedView = (char*)MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0); if (NULL == pMappedView) goto error; buf->size = (unsigned long)fileSize; buf->str = (char*)r_zmalloc((unsigned long)fileSize + 1); if (!buf->str) goto error; r_memcpy(buf->str, pMappedView, (unsigned long)fileSize); if (hMapping) CloseHandle(hMapping); if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); if (pMappedView) UnmapViewOfFile(pMappedView); return buf; error: if (hMapping) CloseHandle(hMapping); if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); if (pMappedView) UnmapViewOfFile(pMappedView); r_free(buf->str); r_free(buf); return NULL; }
/** * Add only one char to the value/text of this text. */ void text_add_char(Text *text, char ch) { char *new_prompt; int nlen = text->length + 1; if (nlen >= text->max_length) return; new_prompt = r_malloc(nlen + 1); strlcpy(new_prompt, (char*)text->value, nlen + 1); new_prompt[nlen] = '\0'; new_prompt[nlen - 1] = ch; r_free(text->value); text->value = new_prompt; text->length = nlen; text_calculate_size(text); }
/* * The state must have all transitions in place, otherwise they * will not be added to the dangling array. */ rexfragment_t *rex_fragment_create(rexstate_t *state) { long i; rex_transition_t *t; rexfragment_t *frag; frag = (rexfragment_t*)r_malloc(sizeof(*frag)); r_memset(frag, 0, sizeof(*frag)); frag->dangling = r_array_create(sizeof(rex_transition_t*)); frag->sstate = state; for (i = 0; i < r_array_length(state->trans); i++) { t = (rex_transition_t *)r_array_slot(state->trans, i); if (t->dstuid < 0) r_array_add(frag->dangling, &t); } for (i = 0; i < r_array_length(state->etrans); i++) { t = (rex_transition_t *)r_array_slot(state->etrans, i); if (t->dstuid < 0) r_array_add(frag->dangling, &t); } return frag; }
robject_t *r_map_init(robject_t *obj, ruint32 type, r_object_cleanupfun cleanup, r_object_copyfun copy, unsigned int elt_size, unsigned int nbits) { unsigned long elt_realsize = R_SIZE_ALIGN(elt_size + sizeof(r_mapnode_t), sizeof(ruword)); unsigned long hashsize, i; rmap_t *map = (rmap_t*)obj; if (nbits == 0 || nbits > 16) { R_ASSERT(0); return NULL; } r_object_init(obj, type, cleanup, copy); map->data = r_carray_create(elt_realsize); map->nbits = nbits; map->elt_size = elt_size; r_list_init(&map->active); r_list_init(&map->inactive); hashsize = r_map_hashsize(map); map->hash = (rlist_t*)r_malloc(sizeof(rlist_t) * hashsize); R_ASSERT(map->hash); for (i = 0; i < hashsize; i++) { r_list_init(&map->hash[i]); } return obj; }
/** * @constructor */ Text * text_new(char *value) { Text *text; text = r_malloc(sizeof(Text)); text->x = 0; text->y = 0; text->width = 0; text->height = FONT0_HEIGHT; text->effect = 0; text->fx_fade_data = -255; text->fx_wave_data = 0; text->fx_float_data = -1; text->value = NULL; text->length = -1; text->max_length = 4096; text->line_spacing = 2; text->trashed = false; text->colorized = false; text->color1_r = 0xFF; text->color1_g = 0xFF; text->color1_b = 0xFF; text->font = 1; text->temp = false; text->centered = false; text_set_value(text, value); return text; }
static int32_t send_msg_to_rec_audio_movie(hdb_freame_head_t *fh, stream_handle *M_handle) { int32_t index = 0; int32_t audio_vaild_num = 0; stream_handle *temp_handle = NULL; int return_code = OPERATION_SUCC; int8_t *rec_frame_data = NULL; parse_data_t *rec_frame_head = NULL; m_msgque m_rec_msgque ; if(M_handle->audio_info == NULL) { nslog(NS_ERROR,"IMPORT ERROR, <AUDIO_INTO IS NULL >STREAM ID : %d\n",M_handle->stream_id); return RECEIVE_MALLOC_ERR; } if(M_handle->audio_info->audio_tran_movie_info.stream_num == 0) { nslog(NS_ERROR,"IMPORT ERROR, <MOVIE AUDIO NUM IS 0>STREAM ID : %d\n",M_handle->stream_id); return OPERATION_SUCC; } audio_vaild_num = M_handle->audio_info->audio_tran_movie_info.stream_num; for(index = 0 ;index < audio_vaild_num ;index++) { temp_handle = (stream_handle *)(M_handle->audio_info->audio_tran_movie_info.stream_handle_addr[index]); // nslog(NS_ERROR,"FUCK_GOD_1016_MOVIE, %d %d\n",temp_handle->stream_id ,get_usb_rec_status(temp_handle)); if(START_USB_REC != get_usb_rec_status(temp_handle)) { continue; } rec_frame_data = (int8_t *)r_malloc(fh->m_frame_length); if(NULL == rec_frame_data) { nslog(NS_ERROR, "malloc is error !!!"); return_code = RECEIVE_MALLOC_ERR; return return_code; } rec_frame_head = (parse_data_t *)r_malloc(sizeof(parse_data_t)); if(NULL == rec_frame_head) { if(rec_frame_data) { r_free(rec_frame_data); rec_frame_data = NULL; } return_code = RECEIVE_MALLOC_ERR; return return_code; } r_memcpy(rec_frame_data, M_handle->audio_data, fh->m_frame_length); rec_frame_head->data_type = R_AUDIO; rec_frame_head->code_rate = fh->m_colors; rec_frame_head->sample_rate = fh->m_hight; rec_frame_head->time_tick = M_handle->recv_time_t.time_audio_tick; rec_frame_head->data_len = fh->m_frame_length; rec_frame_head->data = rec_frame_data; rec_frame_data = NULL; rec_frame_head->flags = fh->m_dw_flags; // add zl // rec_frame_head->sindex = M_handle->stream_id - 1; rec_frame_head->sindex = temp_handle->stream_id; rec_frame_head->index = 0; rec_frame_head->audio_sindex = M_handle->stream_id - 1; rec_frame_head->height = fh->m_hight; rec_frame_head->width = fh->m_width; rec_frame_head->blue_flag = !(fh->m_others); // add zl // m_rec_msgque.msgtype = M_handle->stream_id; m_rec_msgque.msgtype = temp_handle->stream_id; m_rec_msgque.msgbuf = (int8_t *)rec_frame_head; M_handle->recv_pri.to_rec = 1; // nslog(NS_ERROR,"FUCK_GOD_1014_MOVIE MSG_TYPE: %d\n",m_rec_msgque.msgtype); return_code = r_msg_send(temp_handle->msg_recv_to_usb_rec, &m_rec_msgque, MsgqueLen - sizeof(long), IPC_NOWAIT); if(0 > return_code) { if(rec_frame_head->data) { r_free(rec_frame_head->data); rec_frame_head->data = NULL; } if(rec_frame_head) { r_free(rec_frame_head); rec_frame_head = NULL; } if(FALSE == IS_FLAG_BIT_TRUE(M_handle->log_flag, RECORD_BIT)) { nslog(NS_WARN, "msgsnd to record failed, msgid = %d, errno = %d, stream_id = %d", M_handle->msg_recv_to_rec, errno, M_handle->stream_id); SET_FLAG_BIT_TRUE(M_handle->log_flag, RECORD_BIT);//置第0位为1. } M_handle->recv_pri.to_rec = 0; return OPERATION_SUCC; } } SET_FLAG_BIT_FALSE(M_handle->log_flag, RECORD_BIT);//置第0位为0. }
static int32_t send_msg_to_live_audio(hdb_freame_head_t *fh, stream_handle *M_handle) { int32_t index = 0; int32_t audio_vaild_num = 0; stream_handle *temp_handle = NULL; int return_code = OPERATION_SUCC; int8_t *live_frame_data = NULL; parse_data_t *live_frame_head = NULL; m_msgque m_live_msgque ; if(M_handle->audio_info == NULL) { nslog(NS_ERROR,"IMPORT ERROR, < LIVE AUDIO_INTO IS NULL >STREAM ID : %d\n",M_handle->stream_id); return RECEIVE_MALLOC_ERR; } if(M_handle->audio_info->audio_tran_live_into.stream_num == 0) { nslog(NS_ERROR,"IMPORT ERROR, <LIVE AUDIO NUM IS 0>STREAM ID : %d\n",M_handle->stream_id); return OPERATION_SUCC; } audio_vaild_num = M_handle->audio_info->audio_tran_live_into.stream_num; // nslog(NS_ERROR,"AUDIO NUM : %d\n",audio_vaild_num); for(index =0 ;index < audio_vaild_num;index ++ ) { // add zl temp_handle = (stream_handle *)(M_handle->audio_info->audio_tran_live_into.stream_handle_addr[index]); if(START_LIVE != get_live_status(temp_handle)) { continue; } // nslog(NS_ERROR,"STREAM_ID : %d\n",temp_handle->stream_id); live_frame_data = (int8_t *)r_malloc(fh->m_frame_length); if(NULL == live_frame_data) { if(live_frame_data) { r_free(live_frame_data); live_frame_data = NULL; } nslog(NS_ERROR, "malloc is error !!!"); return_code = RECEIVE_MALLOC_ERR; return return_code; } live_frame_head = (parse_data_t *)r_malloc(sizeof(parse_data_t)); if(NULL == live_frame_head) { if(live_frame_head) { r_free(live_frame_head); live_frame_head = NULL; } return_code = RECEIVE_MALLOC_ERR; return return_code; } r_memset(live_frame_head, 0, sizeof(parse_data_t)); r_memset(live_frame_data, 0, fh->m_frame_length); r_memcpy(live_frame_data, M_handle->audio_data, fh->m_frame_length); live_frame_head->data_type = R_AUDIO; live_frame_head->code_rate = fh->m_colors; live_frame_head->sample_rate = fh->m_frame_rate; live_frame_head->time_tick = M_handle->recv_time_t.time_audio_tick; live_frame_head->data_len = fh->m_frame_length; live_frame_head->data = live_frame_data; live_frame_data = NULL; live_frame_head->flags = fh->m_dw_flags; // add zl // live_frame_head->sindex = M_handle->stream_id - 1; live_frame_head->sindex = temp_handle->stream_id; live_frame_head->index = 0; live_frame_head->audio_sindex = M_handle->stream_id - 1; live_frame_head->height = fh->m_hight; live_frame_head->width = fh->m_width; live_frame_head->end_flag = M_handle->live_status; live_frame_head->blue_flag = !(fh->m_others); // add zl // m_live_msgque.msgtype = M_handle->stream_id; m_live_msgque.msgtype = temp_handle->stream_id; m_live_msgque.msgbuf = (int8_t *)live_frame_head; M_handle->recv_pri.to_live = 1; return_code = r_msg_send(temp_handle->msg_recv_to_live, &m_live_msgque, MsgqueLen - sizeof(long), IPC_NOWAIT); if(0 > return_code) { if(live_frame_head->data) { r_free(live_frame_head->data); live_frame_head->data = NULL; } if(live_frame_head) { r_free(live_frame_head); live_frame_head = NULL; } if(FALSE == IS_FLAG_BIT_TRUE(M_handle->log_flag, LIVE_BIT)) { nslog(NS_WARN, "msgsnd to live failed, msgid = %d, errno = %d, stream_id=%d", M_handle->msg_recv_to_live, errno, M_handle->stream_id); SET_FLAG_BIT_TRUE(M_handle->log_flag, LIVE_BIT);//置第1位为1. } M_handle->recv_pri.to_live = 0; return -1; } } SET_FLAG_BIT_FALSE(M_handle->log_flag, LIVE_BIT);//置第1位为0. return 0; }
RMemScanResultType r_mem_scan_pattern (rconstpointer mem, rsize size, const rchar * pattern, RMemScanResult ** result) { RMemScanResultType ret; rsize tokens; if (R_UNLIKELY (mem == NULL)) return R_MEM_SCAN_RESULT_INVAL; if (R_UNLIKELY (pattern == NULL)) return R_MEM_SCAN_RESULT_INVAL; if (R_UNLIKELY (result == NULL)) return R_MEM_SCAN_RESULT_INVAL; tokens = r_mem_scan_validate_pattern (pattern); if (R_UNLIKELY (tokens == 0)) return R_MEM_SCAN_RESULT_INVALID_PATTERN; if (R_LIKELY ((*result = r_malloc (sizeof (RMemScanResult) + tokens * sizeof (RMemScanToken))) != NULL)) { RMemScanToken * t; rsize first, i; (*result)->tokens = tokens; /* Setup tokens based on pattern */ for (i = 0; i < tokens && *pattern != 0; i++) { t = &(*result)->token[i]; t->ptr_pattern = pattern; t->ptr_data = NULL; t->type = r_mem_scan_pattern_next_token (pattern, &t->size, &pattern); } if ((first = r_mem_scan_result_next_token (*result, R_MEM_TOKEN_BYTES, 0)) < tokens) { const ruint8 * wrkmem = mem; rsize wsize = size; /* We have some fixed bytes to find first! */ ret = R_MEM_SCAN_RESULT_NOT_FOUND; do { ruint8 * ptr; rsize cur, next; if ((ptr = r_mem_scan_token_bytes (wrkmem, wsize, &(*result)->token[first])) == NULL) goto beach; (*result)->token[first].ptr_data = ptr; wrkmem = ptr + 1; wsize = size - (wrkmem - (const ruint8 *)mem); /* Check preamble */ if (!r_mem_scan_wild_backward (*result, 0, first, mem, ptr)) continue; ptr += (*result)->token[first].size; cur = first + 1; while ((next = r_mem_scan_result_next_token (*result, R_MEM_TOKEN_BYTES, cur)) < tokens) { while (TRUE) { ruint8 * nptr; if ((nptr = r_mem_scan_token_bytes (ptr, wsize - (ptr - wrkmem), &(*result)->token[next])) == NULL) goto beach; (*result)->token[next].ptr_data = nptr; if (r_mem_scan_wild_fill (*result, cur, next, ptr, nptr)) { ptr = nptr + (*result)->token[next].size; break; } ptr = nptr + 1; } cur = next + 1; } if (r_mem_scan_wild_forward (*result, cur, tokens, ptr, wrkmem + wsize)) ret = R_MEM_SCAN_RESULT_OK; } while (wsize > 0 && ret == R_MEM_SCAN_RESULT_NOT_FOUND); } else { if (r_mem_scan_wild_fill (*result, 0, tokens, mem, (ruint8 *)mem + size)) ret = R_MEM_SCAN_RESULT_OK; else ret = R_MEM_SCAN_RESULT_NOT_FOUND; } if (ret == R_MEM_SCAN_RESULT_OK) { (*result)->ptr = (*result)->token[0].ptr_data; (*result)->end = RSIZE_TO_POINTER ( RPOINTER_TO_SIZE ((*result)->token[tokens-1].ptr_data) + (*result)->token[tokens-1].size); } else { r_free (*result); *result = NULL; } } else { ret = R_MEM_SCAN_RESULT_OOM; } beach: return ret; }
static int32_t send_msg_to_live_media(hdb_freame_head_t *fh, stream_handle *M_handle) { int return_code = OPERATION_SUCC; int8_t *live_frame_data = NULL; parse_data_t *live_frame_head = NULL; m_msgque m_live_msgque ; live_frame_data = (int8_t *)r_malloc(fh->m_frame_length); if(NULL == live_frame_data) { if(live_frame_data) { r_free(live_frame_data); live_frame_data = NULL; } nslog(NS_ERROR, "malloc is error !!!"); return_code = RECEIVE_MALLOC_ERR; return return_code; } live_frame_head = (parse_data_t *)r_malloc(sizeof(parse_data_t)); if(NULL == live_frame_head) { if(live_frame_head) { r_free(live_frame_head); live_frame_head = NULL; } return_code = RECEIVE_MALLOC_ERR; return return_code; } r_memset(live_frame_head, 0, sizeof(parse_data_t)); r_memset(live_frame_data, 0, fh->m_frame_length); if(H264_CODEC_TYPE == fh->m_data_codec) { r_memcpy(live_frame_data, M_handle->frame_data, fh->m_frame_length); live_frame_head->data_type = R_VIDEO; live_frame_head->sample_rate = fh->m_frame_rate; live_frame_head->time_tick = M_handle->recv_time_t.time_video_tick; } else if(JPEG_CODEC_TYPE == fh->m_data_codec) { r_memcpy(live_frame_data, M_handle->frame_data, fh->m_frame_length); live_frame_head->data_type = R_JPEG; live_frame_head->time_tick = M_handle->recv_time_t.time_video_tick; } live_frame_head->data_len = fh->m_frame_length; live_frame_head->data = live_frame_data; live_frame_data = NULL; live_frame_head->flags = fh->m_dw_flags; live_frame_head->sindex = M_handle->stream_id - 1; live_frame_head->index = 0; live_frame_head->audio_sindex = M_handle->stream_id - 1; live_frame_head->height = fh->m_hight; live_frame_head->width = fh->m_width; live_frame_head->end_flag = M_handle->live_status; live_frame_head->blue_flag = !(fh->m_others); m_live_msgque.msgtype = M_handle->stream_id; m_live_msgque.msgbuf = (int8_t *)live_frame_head; M_handle->recv_pri.to_live = 1; if(live_frame_head->data_type == R_JPEG) { nslog(NS_ERROR,"FUCK_GOD_1114 SEND TO A JPEG !\n"); } return_code = r_msg_send(M_handle->msg_recv_to_live, &m_live_msgque, MsgqueLen - sizeof(long), IPC_NOWAIT); if(0 > return_code) { if(live_frame_head->data) { r_free(live_frame_head->data); live_frame_head->data = NULL; } if(live_frame_head) { r_free(live_frame_head); live_frame_head = NULL; } if(FALSE == IS_FLAG_BIT_TRUE(M_handle->log_flag, LIVE_BIT)) { nslog(NS_WARN, "msgsnd to live failed, msgid = %d, errno = %d, stream_id=%d", M_handle->msg_recv_to_live, errno, M_handle->stream_id); SET_FLAG_BIT_TRUE(M_handle->log_flag, LIVE_BIT);//置第1位为1. } M_handle->recv_pri.to_live = 0; return -1; } SET_FLAG_BIT_FALSE(M_handle->log_flag, LIVE_BIT);//置第1位为0. return OPERATION_SUCC; }