Changeset 28236 for lang/c/librtmp

Show
Ignore:
Timestamp:
01/10/09 10:51:14 (5 years ago)
Author:
itkz
Message:

fixed memory allocation bug

Location:
lang/c/librtmp
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • lang/c/librtmp/Makefile

    r27584 r28236  
    11 
    2 CC = gcc 
     2CC = gcc-4.1 
    33 
    4 CFLAGS = -g -Wall -Ipthread/include 
    5 LDFLAGS = -Lpthread/lib -lwsock32 -lpthreadGC2 
     4CFLAGS = -g -Wall -fmudflap 
     5LDFLAGS = -lpthread -lmudflap 
    66 
    7 TARGET = test.exe 
     7TARGET = test 
    88OBJS = main.o rtmp.o rtmp_packet.o amf_packet.o 
    99 
  • lang/c/librtmp/amf_packet.c

    r28235 r28236  
    2323 
    2424#include <stdio.h> 
     25#include <stdlib.h> 
     26#include <string.h> 
    2527 
    2628#include "amf_packet.h" 
     
    224226        property->next = NULL; 
    225227 
    226         property->key = malloc(sizeof(string_length) + 1); 
     228        property->key = malloc(string_length + 1); 
    227229        memmove(property->key, raw_data + raw_data_position, string_length); 
    228230        property->key[string_length] = '\0'; 
  • lang/c/librtmp/main.c

    r28235 r28236  
    6060    while (count--) { 
    6161        rtmp_client_process_message(rc); 
    62         Sleep(1); 
     62//        Sleep(1); 
    6363    } 
    6464 
  • lang/c/librtmp/rtmp.c

    r26899 r28236  
    5050 
    5151#include <stdio.h> 
     52#include <stdlib.h> 
     53#include <string.h> 
    5254#include <unistd.h> 
    5355 
     
    208210    rtmp_client_t *client; 
    209211    int ret; 
    210     WSADATA data; 
     212//    WSADATA data; 
    211213    struct sockaddr_in conn_sockaddr; 
    212214 
    213     WSAStartup(MAKEWORD(2, 0), &data); 
     215//    WSAStartup(MAKEWORD(2, 0), &data); 
    214216 
    215217    client = (rtmp_client_t*)malloc(sizeof(rtmp_client_t)); 
     
    220222    memset(&conn_sockaddr, 0, sizeof(conn_sockaddr)); 
    221223    conn_sockaddr.sin_family = AF_INET; 
     224    conn_sockaddr.sin_addr.s_addr = inet_addr(host); 
    222225    conn_sockaddr.sin_port = htons(port_number); 
    223226     
    224227/* UNIX!!! 
    225     ret = inet_aton(host, &(client->conn_sockaddr.sin_addr)); 
    226     if (ret == 0) { 
    227     } 
    228 */ 
    229228    conn_sockaddr.sin_addr.s_addr = inet_addr(host); 
    230229    if (conn_sockaddr.sin_addr.s_addr == INADDR_NONE) { 
     
    232231        return NULL; 
    233232    } 
     233*/ 
    234234 
    235235    client->conn_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); 
    236236 
    237 /* UNIX!!! 
    238237    ret = connect( 
    239238        client->conn_sock, &(client->conn_sockaddr), 
    240239        sizeof(client->conn_sockaddr)); 
    241240    if (ret == -1) { 
    242     } 
    243 */ 
     241        return NULL; 
     242    } 
     243/* UNIX!!! 
    244244    ret = connect( 
    245245        client->conn_sock, 
     
    249249        return NULL; 
    250250    } 
     251*/ 
    251252 
    252253    client->received_size = 0; 
     
    260261void rtmp_client_free(rtmp_client_t *client) 
    261262{ 
     263    close(client->conn_sock); 
    262264/* UNIX!!! 
    263     close(client->conn_sock); 
    264 */ 
    265265    closesocket(client->conn_sock); 
    266266    WSACleanup(); 
     267*/ 
    267268} 
    268269 
  • lang/c/librtmp/rtmp.h

    r27584 r28236  
    109109{ 
    110110    int conn_sock; 
     111    struct sockaddr conn_sockaddr; 
    111112    unsigned char received_buffer[RTMP_BUFFER_SIZE]; 
    112113    int received_size; 
  • lang/c/librtmp/rtmp_packet.c

    r27584 r28236  
    2323 
    2424#include <stdio.h> 
     25#include <stdlib.h> 
     26#include <string.h> 
    2527 
    2628#include "rtmp_packet.h"