User Profile

Collapse

Profile Sidebar

Collapse
akadayifci
akadayifci
Last Activity: Feb 14 '16, 01:34 PM
Joined: Dec 7 '15
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • akadayifci
    replied to Finding out Segmentation Fault Problem
    in C
    Maybe i wrote it in the search function in a wrong manner, i simply want to search for the strings that are in the r->element[j]->str by looking to isExists string. I've defined the pch as char *pch in the same function. Since r->element[j] contains the responses that i want to look for i want to make a comparison with every element.

    Could you have any suggestion to to that because it is my first time to use these string manipulation...
    See more | Go to post

    Leave a comment:


  • akadayifci
    replied to Finding out Segmentation Fault Problem
    in C
    I've changed malloc(sizeof(i sExists)) to malloc(sizeof(c har));
    There is no error for these lines actually.

    When i run the code without comments (İ'm trying this string search function now it runs one time and gives a segfault)

    if(r->type == REDIS_REPLY_ARR AY){
    memcpy(buffer,r ,sizeof(redisRe ply));
    //printf("%d",r->elements);
    for(int j =0; j<r->elements;j++ )...
    See more | Go to post

    Leave a comment:


  • akadayifci
    replied to Finding out Segmentation Fault Problem
    in C
    I'm using GCC compiler on ubuntu with an option of std=C99.

    In fact it is weird that when the API gets value (where r is a pointer of message reply) it prints out the response without any problem with this loop whenever i want to use another function like strstr it crashes.

    void listenChannel(r edisAsyncContex t *c, void *reply,void *privdata)
    {
    redisReply *r = reply;
    if (reply == NULL) return;...
    See more | Go to post

    Leave a comment:


  • akadayifci
    replied to Finding out Segmentation Fault Problem
    in C
    Actually when i'm going to dig into the API library i found out that this structure holds a struct for the reply that is coming for the answer.
    So i guess arguments of the each element is not a const char according to this structure below. You think being not a const as a problem when it is being used by strstr ?


    typedef struct redisReply {
    int type; /* REDIS_REPLY_* */
    long long integer; /* The integer...
    See more | Go to post

    Leave a comment:


  • akadayifci
    replied to Finding out Segmentation Fault Problem
    in C
    isExists is simply "eNB" string whereas the pointer with elements array is described as like this in this API. When we get a response with the type of REDIS_REPLY_ARR AY, we use that expression. I would also put the API's website just in case.

    https://github.com/redis/hiredis

    REDIS_REPLY_ARR AY:

    A multi bulk reply. The number of elements in the multi bulk reply is stored in reply->elements. Every...
    See more | Go to post

    Leave a comment:


  • akadayifci
    replied to Finding out Segmentation Fault Problem
    in C
    I really appreciate your answers that helped to understand a lot. Finally i realized to find out where the program gives memory dump it is here:

    Code:
     if (reply == NULL)
        return;
     
        printf("Client successfully subscribed to channel !\n");
        if(r->type == REDIS_REPLY_ARRAY){
     
            for(int j =0; j<r->elements;j++)
            {
                printf("Printing Redis
    ...
    See more | Go to post

    Leave a comment:


  • akadayifci
    started a topic Finding out Segmentation Fault Problem
    in C

    Finding out Segmentation Fault Problem

    Dear Bytes community,

    I would like to get your opinion on how to identify a segmentation fault problem in my code which is written in C language. I would share my code for your valuable comments,

    Kindly regards.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <stddef.h>
    #include <signal.h>
    #include <assert.h>
    ...
    See more | Go to post

  • akadayifci
    started a topic Working with libevent library
    in C

    Working with libevent library

    Hello dear members;

    I'd like to get your opinion how to get work libevent library on my C projects. I'm not able to use with my event based project. I'd like to use either along with the Xcode or Visual Studio. On the MAC it seems installed but xcode does not see event.h at all any suggestions ?

    Thanks in advance
    See more | Go to post

  • akadayifci
    replied to Basic struct serialization operation on C
    in C
    Thanks for the response i corrected the code now it works !
    See more | Go to post

    Leave a comment:


  • akadayifci
    replied to Basic struct serialization operation on C
    in C
    Thanks for the answer, but while i am debugging my code i can't recover elements of my struct data. Type casting should work for serialization.
    See more | Go to post

    Leave a comment:


  • akadayifci
    started a topic Basic struct serialization operation on C
    in C

    Basic struct serialization operation on C

    I would like to store my struct data by converting as a char typed data. In order to do that I've tried to write a serialization program but whenever i debug i see different values on my data structure. Could some expert can make a comment on this i can't see what i am missing here.

    Thanks in advance.


    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <signal.h>
    ...
    See more | Go to post
    Last edited by zmbd; Dec 8 '15, 12:18 AM. Reason: [z{please format script using the [CODE/] tool }]
No activity results to display
Show More
Working...