• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /var/www/html/cnasolution/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/index.php
Line: 315
Function: require_once

I want to initialize a Circular Doubly Linked List next/previous pointers to point at the address of a statically allocated element used as sentinel/first element. In this way, I can simplify the list operations. I tried the following code:

struct ErrorDataElement {     struct ErrorDataElement *next;     struct ErrorDataElement *prev;          enum ErrorType type;     int code;     char **messages;     char *file;     char *function;     int line; } _errorList = { &_errorList, &_errorList, 0, -1, NULL, NULL, NULL, 0 }; 

When I print &_errorList memory address (in a sub-function called from main() function) I get a different address from _errorList.next and _errorList.prev.

_errorList.next and _errorList.prev have coherently the same value.

If I inspect using the following code:

printf("%d %d", _errorList.code, _errorList.next->code); 

I see that _errorList.code = -1 as expected, while _errorList.next->code = 1001, indicating to me that the value of _errorList.next has been initialized to some incorrect memory address. I suspect this is due to relative/absolute memory addressing during function initialization, but I can't figure out exactly and how to correctly initialize the static element, or whether or not is even possible such initialization.

Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]